-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: fix compiler warnings in feature detections #16287
Closed
Closed
Conversation
This file contains 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
This was referenced Feb 10, 2025
069b2ef
to
95e7eff
Compare
vszakats
added a commit
that referenced
this pull request
Feb 11, 2025
A deprecation error prevented correct detection in MSVC UWP builds: ``` curl\\bld\\CMakeFiles\\CMakeScratch\\TryCompile-ks2aa4\\CheckSymbolExists.c(8,19): error C4996: 'SSL_CTX_set_srp_username': Since OpenSSL 3.0 ``` Ref: https://github.com/curl/curl/actions/runs/13242285473/job/36960223663#step:8:898 It seems to be caused by different default warning levels used by the toolchain (or CMake?): `/W3` for UWP and `/W1` for Windows desktop. https://github.com/curl/curl/actions/runs/13242285473/job/36960223663#step:8:893 UWP https://github.com/curl/curl/actions/runs/13242285473/job/36960223262#step:8:445 desktop Fix by passing the OpenSSL macro suppressing its deprecation warnings. Cherry-picked from #16287 Closes #16293
95e7eff
to
6e53c61
Compare
a22a048
to
dde1a7d
Compare
32ea31a
to
a81bb2d
Compare
To make it listed in the picky-warning log message, and to apply to feature detections, to make them more robust and compile under the same conditions as the source code. The hope is this helps catching issues faster. It also improves code quality of feature tests.
``` /cygdrive/d/a/curl/curl/CMake/CurlTests.c: In function 'check': /cygdrive/d/a/curl/curl/CMake/CurlTests.c:298:17: error: unused parameter 'c' [-Werror=unused-parameter] 298 | void check(char c) {} | ~~~~~^ ``` https://github.com/curl/curl/actions/runs/13209220246/job/36879343197#step:7:4493 CurlTests.c: fix more compiler warnings
MSVC: ``` D:\\a\\curl\\curl\\CMake\\CurlTests.c(171,17): warning C4189: 'flags': local variable is initialized but not referenced [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_41ff3.vcxproj] ``` https://github.com/curl/curl/actions/runs/13215270720/job/36893785298?pr=16238#step:7:7204
``` D:\\a\\curl\\curl\\CMake\\CurlTests.c(133,6): warning C4127: conditional expression is constant [D:\\a\\curl\\curl\\bld\\CMakeFiles\\CMakeTmp\\cmTC_1d26c.vcxproj] ``` https://github.com/curl/curl/actions/runs/13216319022/job/36896009461?pr=16238#step:8:7888
``` D:/a/curl/curl/CMake/CurlTests.c:286:3: warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt] ``` https://github.com/curl/curl/actions/runs/13226709122/job/36921490343?pr=16278
``` D:/a/curl/curl/CMake/CurlTests.c:154:5: warning: no previous extern declaration for non-static variable 'off_t_is_large' [-Wmissing-variable-declarations] 154 | int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 | ^ D:/a/curl/curl/CMake/CurlTests.c:154:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit 154 | int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 | ^ ``` https://github.com/curl/curl/actions/runs/13226709122/job/36921490343?pr=16278#step:8:3911
``` /d/a/curl/curl/CMake/CurlTests.c:80:23: warning: unused variable ‘hdata’ [-Wunused-variable] 80 | struct hostent_data hdata; | ^~~~~ ``` https://github.com/curl/curl/actions/runs/13226709122/job/36921489357?pr=16278#step:8:3941 (msys2) https://github.com/curl/curl/actions/runs/13226709122/job/36921488213?pr=16278#step:7:3952 (cygwin)
mingw gcc: ``` D:/a/curl/curl/CMake/CurlTests.c:61:12: error: "_REENTRANT" redefined 61 | # define _REENTRANT | ^~~~~~~~~~ <command-line>: note: this is the location of the previous definition ``` https://github.com/curl/curl/actions/runs/13226709122/job/36921490162?pr=16278#step:8:3751
``` D:/a/curl/curl/CMake/CurlTests.c:155:12: warning: unused variable 'off_t_is_large' [-Wunused-variable] ```
``` conftest.c:161:38: warning: redundant redeclaration of 'gethostname' [-Wredundant-decls] 161 | extern int FUNCALLCONV gethostname(char *, int); | ^~~~~~~~~~~ In file included from conftest.c:127: D:/a/_temp/msys64/mingw64/include/winsock2.h:1040:34: note: previous declaration of 'gethostname' with type 'int(char *, int)' 1040 | WINSOCK_API_LINKAGE int WSAAPI gethostname(char *name,int namelen); | ^~~~~~~~~~~ conftest.c:161:38: warning: 'gethostname' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] 161 | extern int FUNCALLCONV gethostname(char *, int); | ^~~~~~~~~~~ ```
…ixup 1 AmigaOS: ``` warning: excess elements in struct initializer ```
…inter target type [-Wdiscarded-qualifiers] (AmigaOS)
…edness [-Wpointer-sign]
… option" This reverts commit 856ee80.
``` conftest.c(38): error: #error directive: force compilation error #error force compilation error ^ conftest.c(40): warning curl#1011: missing return statement at end of non-void function "main" } ^ ```
MS-DOS: ``` /home/runner/work/curl/curl/CMake/CurlTests.c:324:25: warning: excess elements in struct initializer 324 | struct timespec ts = {0, 0}; | ^ ``` AmigaOS: ``` /home/runner/work/curl/curl/CMake/CurlTests.c:324:24: warning: missing braces around initializer [-Wmissing-braces] struct timespec ts = {0, 0}; ^ ```
This allows to avoid the unused variable warning when the struct is not available.
This reverts commit 554a65a.
a81bb2d
to
65140bd
Compare
vszakats
added a commit
that referenced
this pull request
Feb 21, 2025
Silence compiler warnings (200 of them across the main CI workflows): ``` warning #2193: null argument provided for parameter marked with attribute "nonnull" warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker] warning: Null pointer passed to 2nd parameter expecting 'nonnull' [core.NonNullParamChecker] warning: argument 1 null where non-null expected [-Wnonnull] warning: argument 2 null where non-null expected [-Wnonnull] warning: comparison of unsigned expression in '< 0' is always false [-Wtype-limits] warning: null argument where non-null required (argument 1) [-Wnonnull] ``` Also drop `if ... can be linked` feature checks that were identical to `if ... is compilable` checks, for: `closesocket`, `ioctlsocket`, `socket`, `freeaddrinfo`, `getaddrinfo`, `gethostname`, `getpeername`, `getsockname`, `CloseSocket` (AmigaOS), `IoctlSocket` (AmigaOS). Another option is to really do the link checks. But, if they weren't missed so far, it seems safer to drop than risk a detection failure, as was the case with AmigaOS functions while working on this PR. There remain 22 `-Wnonnull` warnings in `gethostbyname_r()`, `getpeername()` `getsockname()`. Most of the rest is necessary for detection, or originate from autotools and CMake detection code templates. Some still fixable, like duplicate libs. Follow-up to ca2f49d #16287 Closes #16377
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.
Fix or silence compiler warnings happening in feature detections
to reduce log noise. Warnings may also get promoted to errors in certain
cases, causing missed detections.
It reduces the number of warnings by 4500+ across the linux, linux-old,
macos, non-native and windows GHA workflows (~142 jobs).
Also move picky warning logic for MSVC/Borland to
`CMake/PickyWarnings.cmake. To make them listed in the picky-warnings
log output, and to also apply to feature detections to make them compile
under the same conditions as source code. The hope is to help catching
issues faster. It also improves code quality of feature tests.
Fixed/silenced:
w/o whitespace: https://github.com/curl/curl/pull/16287/files?w=1
Warnings possibly fixable, but not fixed in this PR: