build: address some -Weverything warnings, update picky warnings#18477
Closed
vszakats wants to merge 88 commits intocurl:masterfrom
Closed
build: address some -Weverything warnings, update picky warnings#18477vszakats wants to merge 88 commits intocurl:masterfrom
-Weverything warnings, update picky warnings#18477vszakats wants to merge 88 commits intocurl:masterfrom
Conversation
-Weverything warnings
Member
Author
|
Standing at: |
Member
Author
|
Down to They are addressed via pending #18343. |
-Weverything warnings-Weverything warnings
-Weverything warnings-Weverything warnings
-Weverything warnings-Weverything warnings
-Weverything warnings-Weverything warnings
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Sep 7, 2025
It's a `-Weverything` warning that appeared in llvm/clang 21.
```
lib/openldap.c:1297:19: warning: duplicate declaration of 'ldapsb_tls' is invalid in C++ [-Wtentative-definition-compat]
1297 | static Sockbuf_IO ldapsb_tls =
| ^
lib/openldap.c:499:19: note: previous declaration is here
499 | static Sockbuf_IO ldapsb_tls;
| ^
```
Reported-by: correctmost on github
Fixes curl#18470
Cherry-picked from curl#18477
vszakats
added a commit
that referenced
this pull request
Sep 7, 2025
It's a `-Weverything` warning that appeared in llvm/clang 21.
```
lib/openldap.c:1297:19: warning: duplicate declaration of 'ldapsb_tls' is invalid in C++ [-Wtentative-definition-compat]
1297 | static Sockbuf_IO ldapsb_tls =
| ^
lib/openldap.c:499:19: note: previous declaration is here
499 | static Sockbuf_IO ldapsb_tls;
| ^
```
Reported-by: correctmost on github
Fixes #18470
Cherry-picked from #18477
Closes #18485
Member
Author
|
Azure Ubuntu mirrors superslow again. |
-Weverything warnings-Weverything warnings
Member
Author
|
Some interesting edge cases and weird fallouts after enabling
|
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Sep 14, 2025
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Sep 14, 2025
1cd641b to
e6a3420
Compare
```
/Users/runner/work/curl/curl/lib/asyn-ares.c:72:9: error: macro is not used [clang-diagnostic-unused-macros,-warnings-as-errors]
72 | #define HAVE_CARES_IPV6 1
| ^
/Users/runner/work/curl/curl/lib/asyn-ares.c:111:9: error: macro is not used [clang-diagnostic-unused-macros,-warnings-as-errors]
111 | #define HAPPY_EYEBALLS_DNS_TIMEOUT 5000
| ^
2 warnings generated.
```
https://github.com/curl/curl/actions/runs/17561982725/job/49880306836?pr=18477#step:11:32
…-identifier`
sync with lib/netrc.c
```
src/tool_findfile.c:27:8: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
27 | #undef __NO_NET_API /* required for AmigaOS to declare getpwuid() */
| ^
src/tool_findfile.c:29:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
29 | #define __NO_NET_API
| ^
```
This reverts commit 272fbc4.
This reverts commit fa0d3db.
This reverts commit d2c2429. Still too noisy. - lib/vauth/ntlm.c: some `NTLMFLAG_*` macros are only used when `DEBUG_ME` is defined. - lib/md5.c: `USE_OPENSSL_MD5` and `USE_WOLFSSL_MD5` can be defined without being used in MultiSSL builds. - lib/asyn-ares.c: `HAVE_CARES_IPV6` is defined but not used. easy to fix, but it'd be better to bump minimum c-ares to 1.6.1. - lib/vtls/wolfssl.c: `WOLFSSL_OPTIONS_IGNORE_SYS` defined, detected as unused. Workaround is ugly by moving this to the command-line.
Using the flag as a regex, and a + (as in c++) in it makes this break.
llvm/clang 21 introduces warning flags with '+' signs in them.
```
-- CMake platform flags: UNIX
CMake Error at CMake/PickyWarnings.cmake:335 (if):
if given arguments:
"_ccmatch" "AND" "-O1 -fno-omit-frame-pointer -gline-tables-only -Wno-error=incompatible-function-pointer-types -Wno-error=int-conversion -Wno-error=deprecated-declarations -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=unknown-warning-option -Wno-error=vla-cxx-extension -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link " "MATCHES" "-Wno-c++-hidden-decl " "AND" "NOT" "_ccopt" "STREQUAL" "-Wall" "AND" "NOT" "_ccopt" "MATCHES" "^-Wno-"
Regular expression "-Wno-c++-hidden-decl " cannot compile
Call Stack (most recent call first):
CMakeLists.txt:272 (include)
RegularExpression::compile(): Nested *?+.
RegularExpression::compile(): Error in compile.
-- Configuring incomplete, errors occurred!
ninja: build stopped: subcommand failed.
```
-Weverything warnings-Weverything warnings, update picky warnings
vszakats
added a commit
that referenced
this pull request
Dec 9, 2025
Explicitly disable these warnings to allow using `-Weverything`. There are around 600 of them across the codebase. Silencing them has some drawbacks: - enums (`CURLcode` mostly) would have to be cast to int to avoid different signedness depending on C compiler. (llvm/gcc: unsigned, MSVC/clang-cl: signed by default) - hex masks need casts to unsigned to avoid the warning. - fixing remaining warnings is annoying without fixing the above. - without fixing all warnings the option cannot be enabled, to keep the codebase warning free. Ref: #18343 (silenced all warnings, but without the enum cast) Follow-up to 92f215f #18477 Closes #19907
1 task
vszakats
added a commit
that referenced
this pull request
Feb 15, 2026
To fix potential `-Wdisabled-macro-expansion` warnings when using these
macros within other macros. Fixing for example:
```
lib/doh.c:328:3: error: disabled expansion of recursive macro [clang-diagnostic-disabled-macro-expansion,-warnings-as-errors]
328 | ERROR_CHECK_SETOPT(CURLOPT_URL, url);
| ^
lib/doh.c:271:14: note: expanded from macro 'ERROR_CHECK_SETOPT'
271 | result = curl_easy_setopt((CURL *)doh, x, y); \
| ^
include/curl/curl.h:3332:44: note: expanded from macro 'curl_easy_setopt'
3332 | #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
| ^
[...]
```
Also update comments on why curl continues to disable
`-Wdisabled-macro-expansion` and `-Wused-but-marked-unused` warnings.
Follow-up to 92f215f #18477
Closes #20597
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-Weverythingis not enabled by curl, and not recommended by LLVM,because it may enable experimental options, and will result in new
fallouts after toolchain upgrades. This patch aims to fix/silence as much
as possible as found with llvm/clang 21.1.0. It also permanently enables
warnings that were fixed in source and deemed manageable in the future.
-Wformatwarnings are addressed separately via #18343.Fix/silence warnings in the source:
-Wreserved-identifier.-Wcast-function-type-strict.For llvm 16+ or Apple clang 16+.
HAPPY_EYEBALLS_DNS_TIMEOUTto old c-ares versions.-Wc++-hidden-decl.-Wc++-keyword.-Wreserved-identifier.-Wreserved-identifier.break;afterreturn;.-Wconditional-uninitialized.-Wimplicit-int-enum-cast.-Wc++-keyword.OSSL_UI_METHOD_CASTto avoid unused macro warning.break;afterreturn;orbreak;.Not normally enabled because it doesn't work with unity.
clang 17.0.2: No "unreachable code" warning if source file included in another source file llvm/llvm-project#71046
-Wc++-keyword.-Wunsafe-buffer-usage.-Wformat-non-iso.-Wreserved-identifier.-Wconditional-uninitialized.Enable the above clang warnings permanently in picky mode:
-Wc++-hidden-decl-Wc++-keyword(except for Windows, where it collides withwchar_t)-Wcast-function-type-strict-Wcast-function-type-Wconditional-uninitialized-Wformat-non-iso(except for clang-cl)-Wreserved-identifier-Wtentative-definition-compatSilence problematic
-Weverythingwarnings globally (in picky mode):-Wused-but-marked-unused(88000+ hits) and-Wdisabled-macro-expansion(2600+ hits).Triggered by
typecheck-gcc.hwhen building with clang 14+.Maybe there exists a way to fix within that header?
Ref: https://discourse.llvm.org/t/removing-wused-but-marked-unused/55310
-Wunsafe-buffer-usage. clang 16+. 7000+ hits.May be useful in theory, but such high volume of hits makes it
impractical to review and possibly address. Meant for C++.
Ref: https://clang.llvm.org/docs/SafeBuffers.html
Ref: https://stackoverflow.com/questions/77017567/how-to-fix-code-to-avoid-warning-wunsafe-buffer-usage
Ref: https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734
Ref: [-Wunsafe-buffer-usage] Add user documentation. llvm/llvm-project#111624
-Wimplicit-void-ptr-cast. clang 21+. 1700+ hits.C++ warning, deemed pure noise.
Ref: -Wtentative-definition-compat warning in openldap.c with clang 21 #18470 (comment)
-Wswitch-default(180+ hits),-Wswitch-enum(190+ hits),-Wcovered-switch-default(20+ hits).Next to impossible to fix cleanly, esp. when the covered
casebranches depend on compile-time options.
-Wdocumentation-unknown-command(8+ hits).Triggered in a few sources. Seems arbitrary and bogus.
-Wpadded(550+ hits).-Wc++-keywordon Windows, where it collides withwchar_t.(100+ hits)
Ref: Incorrect warning about wchar_t in C llvm/llvm-project#155988
-Wreserved-macro-identifier. clang 13+. 5+ hits.Sometimes it's necessary to set external macros that use
the reserved namespace. E.g.
_CRT_NONSTDC_NO_DEPRECATE,__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__,__NO_NET_API,possibly
_REENTRANT, and more.It's not worth trying to silence them individually.
-Wnonportable-system-include-pathwithclang-cl.It'd be broken by doing what the warning suggests.
-Wformat-non-isofor clang-cl.CMake
PICKY_COMPILER=ON(the default) or./configure--enable-warnings(not the default) is required to enable thesesilencing rules.
Also:
Ref: https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
-Warray-comparefor clang 20+.Follow-up to 4b7accd build: enable gcc-12/13+, clang-10+ picky warnings #17196
-Wmissing-variable-declarationsat an earlierclang version.
+inthem.
into
CMAKE_C_FLAGSfor custom-disabled warnings.Follow-up to b85cb8c #18485
w/o sp https://github.com/curl/curl/pull/18477/files?w=1
-Wcast-function-type-strictglobally? → Leaving them there for "awareness". But, there seems to be no way to fix these in most cases, because the callback types are either part of the public curl APIs, or part of public external APIs. Inurl.cit may be possible to wrap fwrite/fread in internal functions to match the signature exactly, but it's even more noise (and runtime perf hit) with no benefit for current code.