> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-boun...@osuosl.org> On Behalf Of Jesse 
> Brandeburg
> Sent: Wednesday, October 4, 2023 12:06 AM
> To: intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Lobakin, Aleksander 
> <aleksander.loba...@intel.com>; Christophe JAILLET 
> <christophe.jail...@wanadoo.fr>; Brandeburg, Jesse 
> <jesse.brandeb...@intel.com>; Kitszel, Przemyslaw 
> <przemyslaw.kits...@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 1/2] intel: fix string 
> truncation warnings
>
> Fix -Wformat-truncated warnings to complete the intel directories' W=1
> clean efforts. The W=1 recently got enhanced with a few new flags and
> this brought up some new warnings.
>
> Switch to using kasprintf() when possible so we always allocate the
> right length strings.
>
> summary of warnings:
> drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1425:60: warning: ‘%s’ 
> directive output may be truncated writing 4 bytes into a region of size 
> between 1 and 11 [-Wformat-truncation=]
> drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1425:17: note: ‘snprintf’ 
> output between 7 and 17 bytes into a destination of size 13
> drivers/net/ethernet/intel/ice/ice_ptp.c:43:27: warning: ‘%s’ directive 
> output may be truncated writing up to 479 bytes into a region of size 64 
> [-Wformat-truncation=]
> drivers/net/ethernet/intel/ice/ice_ptp.c:42:17: note: ‘snprintf’ output 
> between 1 and 480 bytes into a destination of size 64
> drivers/net/ethernet/intel/igb/igb_main.c:3092:53: warning: ‘%d’ directive 
> output may be truncated writing between 1 and 5 bytes into a region of size 
> between 1 and 13 [-Wformat-truncation=]
> drivers/net/ethernet/intel/igb/igb_main.c:3092:34: note: directive argument 
> in the range [0, 65535]
> drivers/net/ethernet/intel/igb/igb_main.c:3092:34: note: directive argument 
> in the range [0, 65535]
> drivers/net/ethernet/intel/igb/igb_main.c:3090:25: note: ‘snprintf’ output 
> between 23 and 43 bytes into a destination of size 32
>
> Suggested-by: Alexander Lobakin <aleksander.loba...@intel.com>
> Reviewed-by: Przemek Kitszel <przemyslaw.kits...@intel.com>
> Signed-off-by: Jesse Brandeburg <jesse.brandeb...@intel.com>
> ---
> I thought this was fine to go to -next since there isn't really urgency
> to drive this change.
> ---
> /linux/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c: In function 
> ‘iavf_virtchnl_completion’:
> /linux/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1425:60: warning: ‘%s’ 
> directive output may be truncated writing 4 bytes into a region of size 
> between 1 and 11 [-Wformat-truncation=]
>  1425 |                 snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%d %s",
>      |                                                            ^~
>  1426 |                          link_speed_mbps, "Mbps");
>       |                                           ~~~~~~
> /linux/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1425:17: note: 
> ‘snprintf’ output between 7 and 17 bytes into a destination of size 13
>  1425 |                 snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%d %s",
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1426 |                          link_speed_mbps, "Mbps");
>       |                          ~~~~~~~~~~~~~~~~~~~~~~~~
> /linux/drivers/net/ethernet/intel/ice/ice_ptp.c: In function 
> ‘ice_get_sma_config_e810t’:
> /linux/drivers/net/ethernet/intel/ice/ice_ptp.c:43:27: warning: ‘%s’ 
> directive output may be truncated writing up to 479 bytes into a region of 
> size 64 [-Wformat-truncation=]
>    43 |                          "%s", ice_pin_desc_e810t[i].name);
>       |                           ^~
> /linux/drivers/net/ethernet/intel/ice/ice_ptp.c:42:17: note: ‘snprintf’ 
> output between 1 and 480 bytes into a destination of size 64
>    42 |                 snprintf(ptp_pins[i].name, sizeof(ptp_pins[i].name),
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    43 |                          "%s", ice_pin_desc_e810t[i].name);
>       |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /linux/drivers/net/ethernet/intel/igb/igb_main.c: In function 
> ‘igb_set_fw_version’:
> /linux/drivers/net/ethernet/intel/igb/igb_main.c:3092:53: warning: ‘%d’ 
> directive output may be truncated writing between 1 and 5 bytes into a region 
> of size between 1 and 13 [-Wformat-truncation=]
>  3092 |                                  "%d.%d, 0x%08x, %d.%d.%d",
>       |                                                     ^~
> /linux/drivers/net/ethernet/intel/igb/igb_main.c:3092:34: note: directive 
> argument in the range [0, 65535]
>  3092 |                                  "%d.%d, 0x%08x, %d.%d.%d",
>       |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
> /linux/drivers/net/ethernet/intel/igb/igb_main.c:3092:34: note: directive 
> argument in the range [0, 65535]
> /linux/drivers/net/ethernet/intel/igb/igb_main.c:3090:25: note: ‘snprintf’ 
> output between 23 and 43 bytes into a destination of size 32
>  3090 |                         snprintf(adapter->fw_version,
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  3091 |                                  sizeof(adapter->fw_version),
>       |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  3092 |                                  "%d.%d, 0x%08x, %d.%d.%d",
>       |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
>  3093 |                                  fw.eep_major, fw.eep_minor, 
> fw.etrack_id,
>       |                                  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  3094 |                                  fw.or_major, fw.or_build, 
> fw.or_patch);
>       |                                  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ---
>  .../net/ethernet/intel/iavf/iavf_ethtool.c    |  4 +-
>  .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 22 ++++-------
>  drivers/net/ethernet/intel/ice/ice_ptp.c      |  4 +-
>  drivers/net/ethernet/intel/igb/igb_main.c     | 37 +++++++++----------
>  4 files changed, 30 insertions(+), 37 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pu...@intel.com> (A 
Contingent worker at Intel)

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Reply via email to