Skip to contentSkip to conversation

setpci: Fix discards const from pointer target

PATCH In review Rudi Heitbaum 1 participant 1 message Feb 22 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 setpci: Fix discards const from pointer target

Since glibc-2.43, and for ISO C23, the function strchr that return pointer 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.

The char *e is only used as a pointer to const char **opts, and only used for comparisons, so declare *e as const to address warning.

Fixes:
setpci.c: In function 'parse_options':
setpci.c:513:19: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
513 | if (e = strchr(opts, *c))
| ^

---
 setpci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
setpci.c +1 -1
index 9ce2ed6..b833250 100644
@@ -488,7 +488,7 @@ parse_options(int argc, char **argv)
     {
       char *c = argv[i++] + 1;
       char *d = c;
-      char *e;
+      const char *e;
       while (*c)
 	switch (*c)
 	  {
Signature · 1 line
2.51.0