Skip to contentSkip to conversation

libxtables: fix discards 'const' qualifier

PATCH New Rudi Heitbaum 1 participant 1 message Feb 20 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 libxtables: fix discards 'const' qualifier

next is used as the return from strchr(loop) which is a const char. Declare next as a const char * pointer for use addressing the warning.

Fixes:
libxtables/xtables.c: In function 'xtables_ipparse_multiple':
libxtables/xtables.c:1767:22: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1767 | next = strchr(loop, ',');
| ^
libxtables/xtables.c: In function 'xtables_ip6parse_multiple':
libxtables/xtables.c:2066:22: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2066 | next = strchr(loop, ',');
| ^

---
 libxtables/xtables.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
libxtables/xtables.c +4 -2
index f872cc69..51706dc4 100644
@@ -1747,7 +1747,8 @@ void xtables_ipparse_multiple(const char *name, struct in_addr **addrpp,
                               struct in_addr **maskpp, unsigned int *naddrs)
 {
 	struct in_addr *addrp;
-	char buf[256], *p, *next;
+	char buf[256], *p;
+	const char *next;
 	unsigned int len, i, j, n, count = 1;
 	const char *loop = name;
 
@@ -2046,7 +2047,8 @@ xtables_ip6parse_multiple(const char *name, struct in6_addr **addrpp,
 {
 	static const struct in6_addr zero_addr;
 	struct in6_addr *addrp;
-	char buf[256], *p, *next;
+	char buf[256], *p;
+	const char *next;
 	unsigned int len, i, j, n, count = 1;
 	const char *loop = name;
 
Signature · 1 line
2.51.0