common/wireaddr: fix GCC 15 const-qualifier errors#9075
Open
vincenzopalazzo wants to merge 1 commit intoElementsProject:masterfrom
Open
common/wireaddr: fix GCC 15 const-qualifier errors#9075vincenzopalazzo wants to merge 1 commit intoElementsProject:masterfrom
vincenzopalazzo wants to merge 1 commit intoElementsProject:masterfrom
Conversation
7af7c64 to
d4dc427
Compare
GCC 15 propagates the const qualifier through strchr/strrchr, so the
result of strchr(const char *, c) is const char *. Declaring the locals
as char * triggers -Werror=discarded-qualifiers:
common/wireaddr.c: In function 'separate_address_and_port':
common/wireaddr.c:297:29: error: initialization discards 'const'
qualifier from pointer target type [-Werror=discarded-qualifiers]
common/wireaddr.c:304:27: error: assignment discards 'const'
qualifier from pointer target type [-Werror=discarded-qualifiers]
Make portcolon and end const char * to match; both are only read.
Fixes: ElementsProject#9074
Changelog-Fixed: build: fix build errors with GCC 15 (Arch Linux).
d4dc427 to
d1c142c
Compare
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.
Summary
constqualifier throughstrchr/strrchr, so the result ofstrchr(const char *, c)isconst char *. The two locals inseparate_address_and_portwere declared aschar *, tripping-Werror=discarded-qualifierson Arch Linux / GCC 15.2.1.portcolonandendtoconst char *. Both are only read (pointer arithmetic and comparisons), so no behavior change.Fixes #9074.
Test plan
make common/wireaddr.o— compiles cleanlymake common/test/run-ip_port_parsing && common/test/run-ip_port_parsing— passes