Re: [PATCH net-next] iavf: Avoid a memory allocation in iavf_print_link_message()
From: Jesse Brandeburg
Date: Tue Oct 03 2023 - 19:01:45 EST
On 10/3/2023 1:33 PM, Christophe JAILLET wrote:
kasprintf() is much better.
cool! I just sent the patches and cc'd you earlier today.
your patch still shows these errors
I built-tested the patch before sending, so this is strange.
However, I got a similar feedback from Greg KH and the "kernel test
robot" for another similar patch.
What version of gcc do you use?
I use 12.3.0, and I suspect that the value range algorithm or how the
diagnostic is done has been improved in recent gcc.
Fedora gcc 12.3.1, with W=1 flag
gcc version 12.3.1 20230508 (Red Hat 12.3.1-1) (GCC)
[linux]$ make W=1 M=drivers/net/ethernet/intel/iavf
CC [M] drivers/net/ethernet/intel/iavf/iavf_main.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_ethtool.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_virtchnl.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_fdir.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_adv_rss.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_txrx.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_common.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_adminq.o
CC [M] drivers/net/ethernet/intel/iavf/iavf_client.o
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c: In function
‘iavf_virtchnl_completion’:
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1446:60: warning: ‘%s’
directive output may be truncated writing 4 bytes into a region of size
between 1 and 11 [-Wformat-truncation=]
1446 | snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%d %s",
| ^~
1447 | link_speed_mbps, "Mbps");
| ~~~~~~
In function ‘iavf_print_link_message’,
inlined from ‘iavf_virtchnl_completion’ at
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1965:4:
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1446:17: note:
‘snprintf’ output between 7 and 17 bytes into a destination of size 13
1446 | snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%d %s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1447 | link_speed_mbps, "Mbps");
| ~~~~~~~~~~~~~~~~~~~~~~~~