diff options
| author | Rudi Heitbaum <rudi@heitbaum.com> | 2026-02-20 09:37:46 +0000 |
|---|---|---|
| committer | Florian Westphal <fw@strlen.de> | 2026-02-22 19:07:47 +0100 |
| commit | 342291e0ff56fb33bc62f9131ce2eab18d0b357d (patch) | |
| tree | 42f18fb6ea19fcf1d589a3c8342994addfb6adab | |
| parent | b176df1c23b458b4510034281a86f0a96341d7a1 (diff) | |
src: fix discards 'const' qualifier
argv is passed by parse_change_counters_rule and do_parse to parse_rule_range
as a const char. parse_rule_range modifies thepassed in argv, so pass as
non const so that it can be modified without warning.
Fixes:
iptables/xshared.c: In function 'parse_rule_range':
iptables/xshared.c:912:23: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
912 | char *colon = strchr(argv, ':'), *buffer;
| ^~~~~~
p is used as the return from strchr(sctp_chunk_names[i].valid_flags)
which is a const char. Declare p as a const char * pointer for use
addressing the warning.
Fixes:
extensions/libxt_sctp.c: In function 'parse_sctp_chunk':
extensions/libxt_sctp.c:211:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
211 | if ((p = strchr(sctp_chunk_names[i].valid_flags,
| ^
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, ',');
| ^
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
| -rw-r--r-- | extensions/libxt_sctp.c | 2 | ||||
| -rw-r--r-- | iptables/xshared.c | 2 | ||||
| -rw-r--r-- | libxtables/xtables.c | 6 |
3 files changed, 6 insertions, 4 deletions
diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c index 6b002402..895a3e8a 100644 --- a/extensions/libxt_sctp.c +++ b/extensions/libxt_sctp.c @@ -205,7 +205,7 @@ parse_sctp_chunk(struct xt_sctp_info *einfo, if (chunk_flags) { DEBUGP("Chunk flags %s\n", chunk_flags); for (j = 0; j < strlen(chunk_flags); j++) { - char *p; + const char *p; int bit; if ((p = strchr(sctp_chunk_names[i].valid_flags, diff --git a/iptables/xshared.c b/iptables/xshared.c index b941b8df..26e91e37 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -907,7 +907,7 @@ static int parse_rulenumber(const char *rule) return rulenum; } -static void parse_rule_range(struct xt_cmd_parse *p, const char *argv) +static void parse_rule_range(struct xt_cmd_parse *p, char *argv) { char *colon = strchr(argv, ':'), *buffer; diff --git a/libxtables/xtables.c b/libxtables/xtables.c index f872cc69..51706dc4 100644 --- a/libxtables/xtables.c +++ b/libxtables/xtables.c @@ -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; |
