On Mon, 24 Feb 2025 14:10:39 +0800
Junlong Wang <wang.junlo...@zte.com.cn> wrote:
> Hi maintainer,
>     Do these warnings need to be resolved?

These warnings do need to be resolved, but not necessarily a blocker for 
inclusing now.

> 
>     The usage of this code is also supported by the standard C language,
No VLA is a GNU extension.

>     and other drivers also have this usage;
The DPDK maintainers are slowly eliminating them.

> 
>     At the same time, why does the compilation still have [- Wvla] warning
>     when adding cflags += no_wvla_cflag in zxdh meson.build

Right but MS C compiler does not support VLA's and VLA's not the whole tree
has been converted.

If you can fix it now, then that would be best. If not, then it will get
changed when other drivers are addressed.

> 
>     Thanks
> 
>     I will submit a new version that includes Enable assertions failed、
>     Enable address sanitizer for undefined checks、Extra memset and cast,
>     and [RFC,0/5] net/zxdh: possible changes you submited.
> 
>     and sorry for not modifying the cover scan and PVS issue in a timely 
> manner.
>     I will make the necessary changes later
> 
> 
> >    ✘ Enable extra warnings (edit meson.build) for
> >        -Wvla, -Wformat-truncation, -Waddress-of-packed-member
> >
> >[1600/3244] Compiling C object 
> >drivers/libtmp_rte_net_zxdh.a.p/net_zxdh_zxdh_queue.c.o
> >.../drivers/net/zxdh/zxdh_queue.c: In function 
> >‘zxdh_dev_rx_queue_setup_finish’:
> >.../drivers/net/zxdh/zxdh_queue.c:357:24: warning: ISO C90 forbids variable 
> >length array ‘new_pkts’ [-Wvla]
> >  357 |                 struct rte_mbuf *new_pkts[free_cnt];
> >      |                        ^~~~~~~~
> >[1603/3244] Compiling C object 
> >drivers/libtmp_rte_net_zxdh.a.p/net_zxdh_zxdh_rxtx.c.o
> >.../drivers/net/zxdh/zxdh_rxtx.c: In function ‘zxdh_recv_pkts_packed’:
> >.../drivers/net/zxdh/zxdh_rxtx.c:903:24: warning: ISO C90 forbids variable 
> >length array ‘new_pkts’ [-Wvla]
> >  903 |                 struct rte_mbuf *new_pkts[free_cnt];
> >      |                        ^~~~~~~~
> >[1616/3244] Compiling C object 
> >drivers/libtmp_rte_net_zxdh.a.p/net_zxdh_zxdh_ethdev_ops.c.o
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c: In function 
> >‘zxdh_dev_xstats_get_names’:
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:1983:26: warning: ‘%s’ directive 
> >output may be truncated writing up to 1359 bytes into a region of size 64 
> >[-Wformat-truncation=]
> > 1983 |                         "%s", zxdh_np_stat_strings[i].name);
> >      |                          ^~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:1982:25: note: ‘snprintf’ output 
> >between 1 and 1360 bytes into a destination of size 64
> > 1982 |                         snprintf(xstats_names[count].name, 
> > sizeof(xstats_names[count].name),
> >      |                         
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 1983 |                         "%s", zxdh_np_stat_strings[i].name);
> >      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:1989:34: warning: ‘%s’ directive 
> >output may be truncated writing up to 2991 bytes into a region of size 64 
> >[-Wformat-truncation=]
> > 1989 |                                 "%s", zxdh_mac_stat_strings[i].name);
> >      |                                  ^~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:1988:33: note: ‘snprintf’ output 
> >between 1 and 2992 bytes into a destination of size 64
> > 1988 |                                 snprintf(xstats_names[count].name, 
> > sizeof(xstats_names[count].name),
> >      |                                 
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 1989 |                                 "%s", zxdh_mac_stat_strings[i].name);
> >      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:1994:34: warning: ‘%s’ directive 
> >output may be truncated writing up to 271 bytes into a region of size 64 
> >[-Wformat-truncation=]
> > 1994 |                                 "%s", 
> > zxdh_mac_bytes_strings[i].name);
> >      |                                  ^~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:1993:33: note: ‘snprintf’ output 
> >between 1 and 272 bytes into a destination of size 64
> > 1993 |                                 snprintf(xstats_names[count].name, 
> > sizeof(xstats_names[count].name),
> >      |                                 
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 1994 |                                 "%s", 
> > zxdh_mac_bytes_strings[i].name);
> >      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:2000:26: warning: ‘%s’ directive 
> >output may be truncated writing up to 339 bytes into a region of size 64 
> >[-Wformat-truncation=]
> > 2000 |                         "%s", zxdh_vqm_stat_strings[i].name);
> >      |                          ^~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:1999:25: note: ‘snprintf’ output 
> >between 1 and 340 bytes into a destination of size 64
> > 1999 |                         snprintf(xstats_names[count].name, 
> > sizeof(xstats_names[count].name),
> >      |                         
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 2000 |                         "%s", zxdh_vqm_stat_strings[i].name);
> >      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:2010:41: warning: ‘%s’ directive 
> >output may be truncated writing up to 1359 bytes into a region of size 
> >between 54 and 58 [-Wformat-truncation=]
> > 2010 |                                 "rx_q%u_%s", i, 
> > zxdh_rxq_stat_strings[t].name);
> >      |                                         ^~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:2009:33: note: ‘snprintf’ output 
> >between 7 and 1370 bytes into a destination of size 64
> > 2009 |                                 snprintf(xstats_names[count].name, 
> > sizeof(xstats_names[count].name),
> >      |                                 
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 2010 |                                 "rx_q%u_%s", i, 
> > zxdh_rxq_stat_strings[t].name);
> >      |                                 
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:2022:41: warning: ‘%s’ directive 
> >output may be truncated writing up to 1291 bytes into a region of size 
> >between 54 and 58 [-Wformat-truncation=]
> > 2022 |                                 "tx_q%u_%s", i, 
> > zxdh_txq_stat_strings[t].name);
> >      |                                         ^~
> >.../drivers/net/zxdh/zxdh_ethdev_ops.c:2021:33: note: ‘snprintf’ output 
> >between 7 and 1302 bytes into a destination of size 64
> > 2021 |                                 snprintf(xstats_names[count].name, 
> > sizeof(xstats_names[count].name),
> >      |                                 
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 2022 |                                 "tx_q%u_%s", i, 
> > zxdh_txq_stat_strings[t].name);
> >      |                                 
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  

I am not sure what causes this, it is likely that C compiler sees that the 
maximum possible value for i is quite
large and the stat_strings have large possible length. Not a big issue, but 
worth looking at.

Reply via email to