drivers/net/ethernet/freescale/enetc/enetc.c:2713:3: warning: 'snprintf' will always be truncated; specified size is 80, but format string expands to at least 110

From: kernel test robot
Date: Sun Jan 07 2024 - 00:56:12 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 52b1853b080a082ec3749c3a9577f6c71b1d4a90
commit: 800db2d125c2bc22c448e2386c3518e663d6db71 net: enetc: ensure we always have a minimum number of TXQs for stack
date: 11 months ago
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20240107/202401071345.gs4ThqGA-lkp@xxxxxxxxx/config)
compiler: clang version 18.0.0git (https://github.com/llvm/llvm-project 7e186d366d6c7def0543acc255931f617e76dff0)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240107/202401071345.gs4ThqGA-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401071345.gs4ThqGA-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/freescale/enetc/enetc.c:2713:3: warning: 'snprintf' will always be truncated; specified size is 80, but format string expands to at least 110 [-Wformat-truncation]
2713 | NL_SET_ERR_MSG_FMT_MOD(extack,
| ^
include/linux/netlink.h:131:2: note: expanded from macro 'NL_SET_ERR_MSG_FMT_MOD'
131 | NL_SET_ERR_MSG_FMT((extack), KBUILD_MODNAME ": " fmt, ##args)
| ^
include/linux/netlink.h:116:6: note: expanded from macro 'NL_SET_ERR_MSG_FMT'
116 | if (snprintf(__extack->_msg_buf, NETLINK_MAX_FMTMSG_LEN, \
| ^
1 warning generated.


vim +/snprintf +2713 drivers/net/ethernet/freescale/enetc/enetc.c

2703
2704 static int enetc_setup_xdp_prog(struct net_device *ndev, struct bpf_prog *prog,
2705 struct netlink_ext_ack *extack)
2706 {
2707 int num_xdp_tx_queues = prog ? num_possible_cpus() : 0;
2708 struct enetc_ndev_priv *priv = netdev_priv(ndev);
2709 bool extended;
2710
2711 if (priv->min_num_stack_tx_queues + num_xdp_tx_queues >
2712 priv->num_tx_rings) {
> 2713 NL_SET_ERR_MSG_FMT_MOD(extack,
2714 "Reserving %d XDP TXQs does not leave a minimum of %d TXQs for network stack (total %d available)",
2715 num_xdp_tx_queues,
2716 priv->min_num_stack_tx_queues,
2717 priv->num_tx_rings);
2718 return -EBUSY;
2719 }
2720
2721 extended = !!(priv->active_offloads & ENETC_F_RX_TSTAMP);
2722
2723 /* The buffer layout is changing, so we need to drain the old
2724 * RX buffers and seed new ones.
2725 */
2726 return enetc_reconfigure(priv, extended, enetc_reconfigure_xdp_cb, prog);
2727 }
2728

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki