Skip to content

Fix: Discarded-qualifiers errors in string searching functions#531

Merged
nook24 merged 1 commit intonaemon:masterfrom
nook24:issue-530
Mar 31, 2026
Merged

Fix: Discarded-qualifiers errors in string searching functions#531
nook24 merged 1 commit intonaemon:masterfrom
nook24:issue-530

Conversation

@nook24
Copy link
Copy Markdown
Member

@nook24 nook24 commented Mar 29, 2026

Currently Naemon uses a mix of (char *) and (const char *) as input for different string functions such as strpbrk() or strchr(). Modern compilers and stricter build flags (-Werror) throw errors when the result of string searching functions like strpbrk() or strchr() is assigned to a non-const pointer, especially when the input was cast to const char*.

This commit adds explicit (char *) casts to the return values of strpbrk and strchr to ensure compatibility across different compiler versions and to satisfy -Werror=discarded-qualifiers.

Affected functions:

  • strpbrk
  • strchr

Issues:

Currently Naemon uses a mix of (char *) and (const char *) as input
for different string functions such as strpbrk() or strchr().
Modern compilers and stricter build flags (-Werror)
throw errors when the result of string searching functions like
strpbrk() or strchr() is assigned to a non-const pointer,
especially when the input was cast to const char*.

This commit adds explicit (char *) casts to the return values of
strpbrk and strchr to ensure compatibility across different
compiler versions and to satisfy -Werror=discarded-qualifiers.

Affected functions:
- strpbrk
- strchr

Issues:
- naemon#530
- naemon#522

Signed-off-by: nook24 <info@nook24.eu>
@nook24 nook24 mentioned this pull request Mar 29, 2026
Copy link
Copy Markdown

@merdely merdely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed the build for me! Thank you!

@nook24 nook24 merged commit 8ba152d into naemon:master Mar 31, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants