[PATCH 21.11] net/softnic: fix maybe-uninitialized warning
Kevin Traynor
ktraynor at redhat.com
Fri Sep 13 11:05:38 CEST 2024
On 11/09/2024 15:12, Kevin Traynor wrote:
> In pmd_mtr_stats_read() 'struct rte_mtr_stats s' is initialized
> during the call to mtr_stats_convert() but on some systems it
> is triggering a compiler warning. e.g.
>
> drivers/net/softnic/rte_eth_softnic_meter.c:916:25: error: 's'
> may be used uninitialized [-Werror=maybe-uninitialized]
>
> Initialize the struct in pmd_mtr_stats_read() to avoid warnings.
>
> Reported-by: Ali Alnubani <alialnu at nvidia.com>
> Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
> ---
> drivers/net/softnic/rte_eth_softnic_meter.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c
> index 6b02f43e31..fea26f9c14 100644
> --- a/drivers/net/softnic/rte_eth_softnic_meter.c
> +++ b/drivers/net/softnic/rte_eth_softnic_meter.c
> @@ -904,5 +904,5 @@ pmd_mtr_stats_read(struct rte_eth_dev *dev,
> /* Stats format conversion. */
> if (stats || stats_mask) {
> - struct rte_mtr_stats s;
> + struct rte_mtr_stats s = {0};
Even though I checked in godbolt, this failed CI for rhel7 gcc 4.8.5
because of the added -Wall, so I will, change to "= {};", re-run CI and
apply with that change if all good.
> uint64_t s_mask = 0;
>
More information about the stable
mailing list