Skip to contentSkip to conversation

wireguard-tools: retain const qualifier from pointer

PATCH New Rudi Heitbaum 1 participant 1 message Feb 8

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wireguard-tools: retain const qualifier from pointer

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);
| ^

---
 src/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/config.c +2 -1
index 6b8aa58..cd65d7e 100644
@@ -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. */
Signature · 1 line
2.51.0