[PATCH] examples/ipsec-secgw: fix discarded-qualifers warnings

Kevin Traynor ktraynor at redhat.com
Fri Mar 13 11:35:23 CET 2026


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, '/');
      |             ^

Cc: stable at dpdk.org

Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
---
 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(-)

diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index cb463c704f..29c4d3cb3d 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -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, '/');
diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 86aeb25a49..a1a996dee8 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -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;
diff --git a/examples/ipsec-secgw/sp4.c b/examples/ipsec-secgw/sp4.c
index fc4101a4a2..9c0badd062 100644
--- a/examples/ipsec-secgw/sp4.c
+++ b/examples/ipsec-secgw/sp4.c
@@ -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;
diff --git a/examples/ipsec-secgw/sp6.c b/examples/ipsec-secgw/sp6.c
index ebc47dfe49..8aff843812 100644
--- a/examples/ipsec-secgw/sp6.c
+++ b/examples/ipsec-secgw/sp6.c
@@ -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;
-- 
2.53.0



More information about the dev mailing list