-
-
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: enable -Wcast-qual
, fix or silence compiler warnings
#16142
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
-cast-qual
-cast-qual
, fix issues
-cast-qual
, fix issues-cast-qual
, fix issues
-cast-qual
, fix issues-cast-qual
, fix issues
-cast-qual
, fix issues-Wcast-qual
, fix or silence compiler warnings
bc699e6
to
227dae2
Compare
jay
reviewed
Mar 4, 2025
…ace with CURL_UNCONST and undropping const
…ace with CURL_UNCONST and undropping const fixup try 1 gcc-12, 13, 14 do not like this: ``` /Users/runner/work/curl/curl/lib/vtls/sectransp.c: In function 'CopyIdentityWithLabel': /Users/runner/work/curl/curl/lib/curl_setup.h:984:34: error: cast from function call of type 'const void *' to non-matching type 'long unsigned int' [-Werror=bad-function-cast] 984 | #define CURL_UNCONST(p) ((void *)(CURL_UNCONST_TYPE)(const void *)(p)) | ^ /Users/runner/work/curl/curl/lib/vtls/sectransp.c:540:27: note: in expansion of macro 'CURL_UNCONST' 540 | (SecIdentityRef)CURL_UNCONST(CFArrayGetValueAtIndex(keys_list, i)); | ^~~~~~~~~~~~ ``` https://github.com/curl/curl/actions/runs/13644166834/job/38139876978?pr=16142#step:9:20
This reverts commit 2b24b5c.
… use and close to stdint.h
This reverts commit 4670900.
Thank you all for the feedback and review! This is merged now. |
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.
The issues found fell into these categories, with the applied fixes:
const was accidentally stripped.
Adjust code to not cast or cast with const.
const/volatile missing from arguments, local variables.
Constify arguments or variables, adjust/delete casts. Small code
changes in a few places.
const must be stripped because an API dependency requires it.
Strip
const
withCURL_UNCONST()
macro to silence the warning outof our control. These happen at API boundaries. Sometimes they depend
on dependency version, which this patch handles as necessary. Also
enable const support for the zlib API, using
ZLIB_CONST
. Supportedby zlib 1.2.5.2 and newer.
const must be stripped because a curl API requires it.
Strip
const
withCURL_UNCONST()
macro to silence the warning outof our immediate control. For example we promise to send a non-const
argument to a callback, though the data is const internally.
other cases where we may avoid const stripping by code changes.
Also silenced with
CURL_UNCONST()
.there are 3 places where
CURL_UNCONST()
is cast again to const.To silence this type of warning:
There may be a better solution, but I couldn't find it.
These cases are handled in separate subcommits, but without further
markup. They seem fairly easily distinguishable (let me know if not!).
If you see a
-Wcast-qual
warning in curl, we appreciate your reportabout it.
CURL_UNCONST()
by mapping to(void *)
. With maybe a way to customize the interim integer type.ZLIB_CONST
?→ formatting changes merged via tidy-up: alphasort lists, indentation/whitespace, pp #16490
HAVE_STDINT_H
in autotools, and make it explicit and publish from CMake.