[PATCH 2/5] vpn-provider: Fix issue with const return value from strrchr
Rudi Heitbaum <[email protected]> Thu, 12 Feb 2026 13:26:25 +0000
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <aY3VAds7frDakWxu@01676446e9f4> |
When compiling with recent gcc and glibc-2.43 the --Wdiscarded-qualifiers
warning occurs because with ISO C23, the function strrrchr that return
pointers into their input arrays now have definitions as macros that
return a pointer to a const-qualified type when the input argument is
a pointer to a const-qualified type.
../vpn/vpn-provider.c: In function 'get_ident':
../vpn/vpn-provider.c:1658:13: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1658 | pos = strrchr(path, '/');
| ^
---
vpn/vpn-provider.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 4bcb8373..dafdaffa 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -1648,9 +1648,9 @@ static void connection_removed_signal(struct vpn_provider *provider)
dbus_message_unref(signal);
}
-static char *get_ident(const char *path)
+static const char *get_ident(const char *path)
{
- char *pos;
+ const char *pos;
if (*path != '/')
return NULL;
@@ -1665,7 +1665,7 @@ static char *get_ident(const char *path)
int __vpn_provider_remove(const char *path)
{
struct vpn_provider *provider;
- char *ident;
+ const char *ident;
DBG("path %s", path);
--
2.51.0