Skip to contentSkip to conversation

examples/ipsec-secgw: fix discarded-qualifers warnings

PATCH Applied Kevin Traynor 3 participants 3 messages Mar 13 – Mar 17

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/ipsec-secgw: fix discarded-qualifers warnings

glibc 2.42 has const-preserving functions.

This leads to warnings when there is a const argument and an assignment to a non-const variable.

Example with GCC 16.0.1 and glibc 2.43 on Fedora Rawhide (F45).

/examples/ipsec-secgw/parser.c: In function ‘parse_ipv4_addr’:
../examples/ipsec-secgw/parser.c:53:13:
warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
53 | pch = strchr(token, '/');
| ^

---
 examples/ipsec-secgw/parser.c | 4 ++--
 examples/ipsec-secgw/sa.c     | 2 +-
 examples/ipsec-secgw/sp4.c    | 2 +-
 examples/ipsec-secgw/sp6.c    | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
examples/ipsec-secgw/parser.c +2 -2
index cb463c704f..29c4d3cb3d 100644
@@ -49,5 +49,5 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask)
 {
 	char ip_str[INET_ADDRSTRLEN] = {0};
-	char *pch;
+	const char *pch;
 
 	pch = strchr(token, '/');
@@ -79,5 +79,5 @@ parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6, uint32_t *mask)
 {
 	char ip_str[256] = {0};
-	char *pch;
+	const char *pch;
 
 	pch = strchr(token, '/');
examples/ipsec-secgw/sa.c +1 -1
index 86aeb25a49..a1a996dee8 100644
@@ -1676,5 +1676,5 @@ sa_spi_present(struct sa_ctx *sa_ctx, uint32_t spi, int inbound)
 {
 	uint32_t num;
-	struct ipsec_sa *sa;
+	const struct ipsec_sa *sa;
 	struct ipsec_sa tmpl;
 	const struct ipsec_sa *sar;
examples/ipsec-secgw/sp4.c +1 -1
index fc4101a4a2..9c0badd062 100644
@@ -611,5 +611,5 @@ sp4_spi_present(uint32_t spi, int inbound, struct ip_addr ip_addr[2],
 {
 	uint32_t num;
-	struct acl4_rules *rule;
+	const struct acl4_rules *rule;
 	const struct acl4_rules *acr;
 	struct acl4_rules tmpl;
examples/ipsec-secgw/sp6.c +1 -1
index ebc47dfe49..8aff843812 100644
@@ -755,5 +755,5 @@ sp6_spi_present(uint32_t spi, int inbound, struct ip_addr ip_addr[2],
 {
 	uint32_t num;
-	struct acl6_rules *rule;
+	const struct acl6_rules *rule;
 	const struct acl6_rules *acr;
 	struct acl6_rules tmpl;
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kevin Traynor

glibc 2.42 has const-preserving functions.

This leads to warnings when there is a const argument and an assignment to a non-const variable.

Example with GCC 16.0.1 and glibc 2.43 on Fedora Rawhide (F45).

/examples/ipsec-secgw/parser.c: In function ‘parse_ipv4_addr’:
../examples/ipsec-secgw/parser.c:53:13:
warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Quoted 7 lines
    53 |         pch = strchr(token, '/');
       |             ^

---

#2 lore raw

16/03/2026 11:12, Radu Nicolau:

Quoted 3 lines · Kevin Traynor
Quoted 1 line

glibc 2.42 has const-preserving functions.

It is in glibc 2.43.

Quoted 13 lines
Quoted 13 lines

This leads to warnings when there is a const argument and an assignment to a non-const variable.

Example with GCC 16.0.1 and glibc 2.43 on Fedora Rawhide (F45).

/examples/ipsec-secgw/parser.c: In function ‘parse_ipv4_addr’:
../examples/ipsec-secgw/parser.c:53:13:
warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

    53 |         pch = strchr(token, '/');
       |             ^
Quoted 5 lines
Quoted 4 lines

---

Applied, thanks.