[3/3] examples/ipsec-secgw: compilation fix for GCC-12
Checks
Commit Message
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
> 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
@@ -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);
}
/*