Skip to contentSkip to conversation

openconnect: Fix issue with const return value from strchr

PATCH New Grant Erickson 1 participant 1 message Nov 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 openconnect: Fix issue with const return value from strchr

When compiling with recent GCC or clang/LLVM and glibc 2.43 or later, such as on Ubuntu 26.04 ('Resolute'), the -Wdiscarded-qualifiers (GCC) or -Wincompatible-pointer-types-discards-qualifiers (clang/LLVM) warning occurs, and is an error when --enable-maintainer-mode is asserted, because with ISO C23, the function strchr, which returns a pointer into its input array, is now defined as a macro that returns a pointer to a const-qualified type when the input argument is a pointer to a const-qualified type:

vpn/plugins/openconnect.c:331:29: error: assignment discards
'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

'sep' is only read through, so it is simply made 'const char *'.

---
 vpn/plugins/openconnect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
vpn/plugins/openconnect.c +1 -1
index fb63a1a303d0..fcf384c5765c 100644
@@ -325,7 +325,7 @@ static int oc_notify(DBusMessage *msg, struct vpn_provider *provider)
 			netmask = g_strdup(value);
 
 		if (!strcmp(key, "INTERNAL_IP6_NETMASK")) {
-			char *sep;
+			const char *sep;
 
 			/* The netmask contains the address and the prefix */
 			sep = strchr(value, '/');
Signature · 1 line
2.52.0