[3/3] examples/ipsec-secgw: compilation fix for GCC-12

Message ID 20220823105742.2276506-3-amitprakashs@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [1/3] net/i40e: compilation fix for GCC-12 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Amit Prakash Shukla Aug. 23, 2022, 10:57 a.m. UTC
  GCC 12 raises the following warning:

meson --werror --buildtype=debugoptimized --cross-file
	config/arm/arm64_armv8_linux_gcc -Ddefault_library=shared
	-Dexamples=all build
ninja -C build

In file included from ../examples/ipsec-secgw/ipsec_lpm_neon.h:9,
                 from ../examples/ipsec-secgw/ipsec_worker.c:16:
In function 'send_multi_pkts',
    inlined from 'route6_pkts_neon' at
../examples/ipsec-secgw/ipsec_lpm_neon.h:170:2,
    inlined from 'ipsec_poll_mode_wrkr_inl_pr' at
../examples/ipsec-secgw/ipsec_worker.c:1257:4:
../examples/ipsec-secgw/ipsec_neon.h:261:21: error: 'dst_port' may be used
uninitialized [-Werror=maybe-uninitialized]
  261 |                 dlp = dst_port[i - 1];
      |                 ~~~~^~~~~~~~~~~~~~~~~
In file included from ../examples/ipsec-secgw/ipsec_worker.c:16:
../examples/ipsec-secgw/ipsec_worker.c: In function
'ipsec_poll_mode_wrkr_inl_pr':
../examples/ipsec-secgw/ipsec_lpm_neon.h:118:17:
	note: 'dst_port' declared here
  118 |         int32_t dst_port[MAX_PKT_BURST];
      |                 ^~~~~~~~

Fixes: ce23f7ceec6b (examples/ipsec-secgw: add support of NEON with poll mode)
Cc: stable@dpdk.org

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
 examples/ipsec-secgw/ipsec_lpm_neon.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
  

Comments

Akhil Goyal Aug. 23, 2022, 1:12 p.m. UTC | #1
> GCC 12 raises the following warning:
> 
> meson --werror --buildtype=debugoptimized --cross-file
> 	config/arm/arm64_armv8_linux_gcc -Ddefault_library=shared
> 	-Dexamples=all build
> ninja -C build
> 
> In file included from ../examples/ipsec-secgw/ipsec_lpm_neon.h:9,
>                  from ../examples/ipsec-secgw/ipsec_worker.c:16:
> In function 'send_multi_pkts',
>     inlined from 'route6_pkts_neon' at
> ../examples/ipsec-secgw/ipsec_lpm_neon.h:170:2,
>     inlined from 'ipsec_poll_mode_wrkr_inl_pr' at
> ../examples/ipsec-secgw/ipsec_worker.c:1257:4:
> ../examples/ipsec-secgw/ipsec_neon.h:261:21: error: 'dst_port' may be used
> uninitialized [-Werror=maybe-uninitialized]
>   261 |                 dlp = dst_port[i - 1];
>       |                 ~~~~^~~~~~~~~~~~~~~~~
> In file included from ../examples/ipsec-secgw/ipsec_worker.c:16:
> ../examples/ipsec-secgw/ipsec_worker.c: In function
> 'ipsec_poll_mode_wrkr_inl_pr':
> ../examples/ipsec-secgw/ipsec_lpm_neon.h:118:17:
> 	note: 'dst_port' declared here
>   118 |         int32_t dst_port[MAX_PKT_BURST];
>       |                 ^~~~~~~~
> 
> Fixes: ce23f7ceec6b (examples/ipsec-secgw: add support of NEON with poll
> mode)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
> ---
>  examples/ipsec-secgw/ipsec_lpm_neon.h | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/examples/ipsec-secgw/ipsec_lpm_neon.h b/examples/ipsec-
> secgw/ipsec_lpm_neon.h
> index 959a5a8666..25f0abcaf3 100644
> --- a/examples/ipsec-secgw/ipsec_lpm_neon.h
> +++ b/examples/ipsec-secgw/ipsec_lpm_neon.h
> @@ -115,7 +115,7 @@ static inline void
>  route6_pkts_neon(struct rt_ctx *rt_ctx, struct rte_mbuf **pkts, int nb_rx)
>  {
>  	uint8_t dst_ip6[MAX_PKT_BURST][16];
> -	int32_t dst_port[MAX_PKT_BURST];
> +	uint16_t dst_port[MAX_PKT_BURST];
>  	struct rte_ether_hdr *eth_hdr;
>  	struct rte_ipv6_hdr *ipv6_hdr;
>  	int32_t hop[MAX_PKT_BURST];
> @@ -157,17 +157,15 @@ route6_pkts_neon(struct rt_ctx *rt_ctx, struct
> rte_mbuf **pkts, int nb_rx)
>  		pkt = pkts[i];
>  		if (pkt->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
>  			/* Read hop from the SA */
> -			dst_port[i] = get_hop_for_offload_pkt(pkt, 1);
> +			dst_port[i] = (uint16_t)get_hop_for_offload_pkt(pkt,
> 1);
>  		} else {
>  			/* Need to use hop returned by lookup */
> -			dst_port[i] = hop[lpm_pkts++];
> +			dst_port[i] = (uint16_t)hop[lpm_pkts++];
>  		}
> -		if (dst_port[i] == -1)
> -			dst_port[i] = BAD_PORT;

get_hop_for_offload_pkt is returning -1, can you also return BAD_PORT from that
if there is error. And you would not need to typecast it explicitly to uin16_t.

>  	}
> 
>  	/* Send packets */
> -	send_multi_pkts(pkts, (uint16_t *)dst_port, nb_rx, 0, 0, false);
> +	send_multi_pkts(pkts, dst_port, nb_rx, 0, 0, false);
>  }
> 
>  /*
> --
> 2.25.1
  

Patch

diff --git a/examples/ipsec-secgw/ipsec_lpm_neon.h b/examples/ipsec-secgw/ipsec_lpm_neon.h
index 959a5a8666..25f0abcaf3 100644
--- a/examples/ipsec-secgw/ipsec_lpm_neon.h
+++ b/examples/ipsec-secgw/ipsec_lpm_neon.h
@@ -115,7 +115,7 @@  static inline void
 route6_pkts_neon(struct rt_ctx *rt_ctx, struct rte_mbuf **pkts, int nb_rx)
 {
 	uint8_t dst_ip6[MAX_PKT_BURST][16];
-	int32_t dst_port[MAX_PKT_BURST];
+	uint16_t dst_port[MAX_PKT_BURST];
 	struct rte_ether_hdr *eth_hdr;
 	struct rte_ipv6_hdr *ipv6_hdr;
 	int32_t hop[MAX_PKT_BURST];
@@ -157,17 +157,15 @@  route6_pkts_neon(struct rt_ctx *rt_ctx, struct rte_mbuf **pkts, int nb_rx)
 		pkt = pkts[i];
 		if (pkt->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
 			/* Read hop from the SA */
-			dst_port[i] = get_hop_for_offload_pkt(pkt, 1);
+			dst_port[i] = (uint16_t)get_hop_for_offload_pkt(pkt, 1);
 		} else {
 			/* Need to use hop returned by lookup */
-			dst_port[i] = hop[lpm_pkts++];
+			dst_port[i] = (uint16_t)hop[lpm_pkts++];
 		}
-		if (dst_port[i] == -1)
-			dst_port[i] = BAD_PORT;
 	}
 
 	/* Send packets */
-	send_multi_pkts(pkts, (uint16_t *)dst_port, nb_rx, 0, 0, false);
+	send_multi_pkts(pkts, dst_port, nb_rx, 0, 0, false);
 }
 
 /*