[RFC 3/6] ethdev: remove VLA warnings
Morten Brørup
mb at smartsharesystems.com
Fri Apr 19 14:06:21 CEST 2024
> From: Konstantin Ananyev [mailto:konstantin.v.ananyev at yandex.ru]
> Sent: Thursday, 18 April 2024 12.33
>
> From: Konstantin Ananyev <konstantin.ananyev at huawei.com>
>
> 1) ./lib/ethdev/rte_ethdev.c:3244:16: warning: ISO C90 forbids variable length
> array ‘xstats_names’ [-Wvla]
> 2) ./lib/ethdev/rte_ethdev.c:3345:17: warning: ISO C90 forbids variable length
> array ‘ids_copy’ [-Wvla]
> 3) ./lib/ethdev/rte_ethdev.c:3538:16: warning: ISO C90 forbids variable length
> array ‘xstats’ [-Wvla]
> 4) ./lib/ethdev/rte_ethdev.c:3554:17: warning: ISO C90 forbids variable length
> array ‘ids_copy’ [-Wvla]
>
> For 1) and 3) - just replaced VLA with arrays allocated from heap.
> As I understand xstats extraction belongs to control-path, so extra
> calloc/free is jopefully acceptable.
> Also ethdev xstats already doing that within
> rte_eth_xstats_get_id_by_name().
Getting names and getting values are two different things.
I would slightly prefer alloca() as VLA replacement for "xstats".
> For 2) and 4) changed the code to use fixed size array and call
> appropriate devops function several times, if needed.
>
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
> ---
With or without suggested change...
Acked-by: Morten Brørup <mb at smartsharesystems.com>
Thank you very much for your work on getting rid of VLAs, Konstantin!
More information about the dev
mailing list