[jpirko-mlxsw:petrm_soft_counters 9/10] net/core/rtnetlink.c:5509:51: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int')

From: kernel test robot
Date: Fri Dec 10 2021 - 06:05:09 EST


tree: https://github.com/jpirko/linux_mlxsw petrm_soft_counters
head: 38ca0aa04554a994a5ab769f0c07b37484b5f4c9
commit: 0839ffb5b56fb6f5e67545c77bf6151fe606835d [9/10] wip
config: i386-randconfig-r026-20211210 (https://download.01.org/0day-ci/archive/20211210/202112101827.NH71OPJw-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 097a1cb1d5ebb3a0ec4bcaed8ba3ff6a8e33c00a)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/jpirko/linux_mlxsw/commit/0839ffb5b56fb6f5e67545c77bf6151fe606835d
git remote add jpirko-mlxsw https://github.com/jpirko/linux_mlxsw
git fetch --no-tags jpirko-mlxsw petrm_soft_counters
git checkout 0839ffb5b56fb6f5e67545c77bf6151fe606835d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash net/core/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> net/core/rtnetlink.c:5509:51: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
printk(KERN_WARNING "if_nlmsg_stats_size %ld\n", size);
~~~ ^~~~
%u
include/linux/printk.h:446:60: note: expanded from macro 'printk'
#define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/printk.h:418:19: note: expanded from macro 'printk_index_wrap'
_p_func(_fmt, ##__VA_ARGS__); \
~~~~ ^~~~~~~~~~~
1 warning generated.


vim +5509 net/core/rtnetlink.c

5442
5443 static size_t if_nlmsg_stats_size(const struct net_device *dev,
5444 const struct rtnl_stats_dump_filters *filters)
5445 {
5446 size_t size = NLMSG_ALIGN(sizeof(struct if_stats_msg));
5447 unsigned int filter_mask = filters->mask[0];
5448
5449 if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_64, 0))
5450 size += nla_total_size_64bit(sizeof(struct rtnl_link_stats64));
5451
5452 if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_XSTATS, 0)) {
5453 const struct rtnl_link_ops *ops = dev->rtnl_link_ops;
5454 int attr = IFLA_STATS_LINK_XSTATS;
5455
5456 if (ops && ops->get_linkxstats_size) {
5457 size += nla_total_size(ops->get_linkxstats_size(dev,
5458 attr));
5459 /* for IFLA_STATS_LINK_XSTATS */
5460 size += nla_total_size(0);
5461 }
5462 }
5463
5464 if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_XSTATS_SLAVE, 0)) {
5465 struct net_device *_dev = (struct net_device *)dev;
5466 const struct rtnl_link_ops *ops = NULL;
5467 const struct net_device *master;
5468
5469 /* netdev_master_upper_dev_get can't take const */
5470 master = netdev_master_upper_dev_get(_dev);
5471 if (master)
5472 ops = master->rtnl_link_ops;
5473 if (ops && ops->get_linkxstats_size) {
5474 int attr = IFLA_STATS_LINK_XSTATS_SLAVE;
5475
5476 size += nla_total_size(ops->get_linkxstats_size(dev,
5477 attr));
5478 /* for IFLA_STATS_LINK_XSTATS_SLAVE */
5479 size += nla_total_size(0);
5480 }
5481 }
5482
5483 if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_OFFLOAD_XSTATS, 0)) {
5484 u32 off_filter_mask;
5485
5486 off_filter_mask = filters->mask[IFLA_STATS_LINK_OFFLOAD_XSTATS];
5487 size += rtnl_get_offload_stats_size(dev, off_filter_mask);
5488 }
5489
5490 if (stats_attr_valid(filter_mask, IFLA_STATS_AF_SPEC, 0)) {
5491 struct rtnl_af_ops *af_ops;
5492
5493 /* for IFLA_STATS_AF_SPEC */
5494 size += nla_total_size(0);
5495
5496 rcu_read_lock();
5497 list_for_each_entry_rcu(af_ops, &rtnl_af_ops, list) {
5498 if (af_ops->get_stats_af_size) {
5499 size += nla_total_size(
5500 af_ops->get_stats_af_size(dev));
5501
5502 /* for AF_* */
5503 size += nla_total_size(0);
5504 }
5505 }
5506 rcu_read_unlock();
5507 }
5508
> 5509 printk(KERN_WARNING "if_nlmsg_stats_size %ld\n", size);
5510 return size;
5511 }
5512

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx