[PATCH] wireguard-tools: retain const qualifier from pointer
Rudi Heitbaum <[email protected]> Sat, 7 Feb 2026 05:12:27 +0000
| Newsgroups | com.zx2c4.lists.wireguard |
|---|---|
| Message-ID | <aYbJJ86gqdWvmD-j@c9fca329e4d7> |
Since glibc-2.43:
For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers
into their input arrays now have definitions as macros that return a
pointer to a const-qualified type when the in put argument is a pointer
to a const-qualified type.
https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html
Resolves the following warning:
config.c: In function 'config_read_line':
config.c:513:17: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
513 | comment = strchr(input, COMMENT_CHAR);
| ^
Signed-off-by: Rudi Heitbaum <[email protected]>
---
src/config.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/config.c b/src/config.c
index 6b8aa58..cd65d7e 100644
--- a/src/config.c
+++ b/src/config.c
@@ -506,7 +506,8 @@ error:
bool config_read_line(struct config_ctx *ctx, const char *input)
{
size_t len, cleaned_len = 0;
- char *line, *comment;
+ const char *comment;
+ char *line;
bool ret = true;
/* This is what strchrnul is for, but that isn't portable. */
--
2.51.0