mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* block/blk-throttle.c:1498:43: warning: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 17
@ 2023-11-19 10:37 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-11-19 10:37 UTC (permalink / raw)
  To: Shaohua Li; +Cc: oe-kbuild-all, linux-kernel, Jens Axboe

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   037266a5f7239ead1530266f7d7af153d2a867fa
commit: ec80991d6fc2cb17abfc5427ac1512d2ccd40589 blk-throttle: add interface for per-cgroup target latency
date:   7 years ago
config: x86_64-randconfig-r031-20230816 (https://download.01.org/0day-ci/archive/20231119/202311191805.T3V1HGnn-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231119/202311191805.T3V1HGnn-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311191805.T3V1HGnn-lkp@intel.com/

All warnings (new ones prefixed by >>):

   block/blk-throttle.c: In function 'tg_prfill_limit':
   block/blk-throttle.c:1491:74: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    1491 |                         snprintf(idle_time, sizeof(idle_time), " idle=%lu",
         |                                                                          ^
   block/blk-throttle.c:1491:25: note: 'snprintf' output between 8 and 27 bytes into a destination of size 26
    1491 |                         snprintf(idle_time, sizeof(idle_time), " idle=%lu",
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1492 |                                 tg->idletime_threshold);
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~
>> block/blk-throttle.c:1498:43: warning: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 17 [-Wformat-truncation=]
    1498 |                                 " latency=%lu", tg->latency_target);
         |                                           ^~~
   block/blk-throttle.c:1498:33: note: directive argument in the range [0, 18446744073709551614]
    1498 |                                 " latency=%lu", tg->latency_target);
         |                                 ^~~~~~~~~~~~~~
   block/blk-throttle.c:1497:25: note: 'snprintf' output between 11 and 30 bytes into a destination of size 26
    1497 |                         snprintf(latency_time, sizeof(latency_time),
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1498 |                                 " latency=%lu", tg->latency_target);
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +1498 block/blk-throttle.c

  1443	
  1444	static u64 tg_prfill_limit(struct seq_file *sf, struct blkg_policy_data *pd,
  1445				 int off)
  1446	{
  1447		struct throtl_grp *tg = pd_to_tg(pd);
  1448		const char *dname = blkg_dev_name(pd->blkg);
  1449		char bufs[4][21] = { "max", "max", "max", "max" };
  1450		u64 bps_dft;
  1451		unsigned int iops_dft;
  1452		char idle_time[26] = "";
  1453		char latency_time[26] = "";
  1454	
  1455		if (!dname)
  1456			return 0;
  1457	
  1458		if (off == LIMIT_LOW) {
  1459			bps_dft = 0;
  1460			iops_dft = 0;
  1461		} else {
  1462			bps_dft = U64_MAX;
  1463			iops_dft = UINT_MAX;
  1464		}
  1465	
  1466		if (tg->bps_conf[READ][off] == bps_dft &&
  1467		    tg->bps_conf[WRITE][off] == bps_dft &&
  1468		    tg->iops_conf[READ][off] == iops_dft &&
  1469		    tg->iops_conf[WRITE][off] == iops_dft &&
  1470		    (off != LIMIT_LOW ||
  1471		     (tg->idletime_threshold == tg->td->dft_idletime_threshold &&
  1472		      tg->latency_target == DFL_LATENCY_TARGET)))
  1473			return 0;
  1474	
  1475		if (tg->bps_conf[READ][off] != bps_dft)
  1476			snprintf(bufs[0], sizeof(bufs[0]), "%llu",
  1477				tg->bps_conf[READ][off]);
  1478		if (tg->bps_conf[WRITE][off] != bps_dft)
  1479			snprintf(bufs[1], sizeof(bufs[1]), "%llu",
  1480				tg->bps_conf[WRITE][off]);
  1481		if (tg->iops_conf[READ][off] != iops_dft)
  1482			snprintf(bufs[2], sizeof(bufs[2]), "%u",
  1483				tg->iops_conf[READ][off]);
  1484		if (tg->iops_conf[WRITE][off] != iops_dft)
  1485			snprintf(bufs[3], sizeof(bufs[3]), "%u",
  1486				tg->iops_conf[WRITE][off]);
  1487		if (off == LIMIT_LOW) {
  1488			if (tg->idletime_threshold == ULONG_MAX)
  1489				strcpy(idle_time, " idle=max");
  1490			else
  1491				snprintf(idle_time, sizeof(idle_time), " idle=%lu",
  1492					tg->idletime_threshold);
  1493	
  1494			if (tg->latency_target == ULONG_MAX)
  1495				strcpy(latency_time, " latency=max");
  1496			else
  1497				snprintf(latency_time, sizeof(latency_time),
> 1498					" latency=%lu", tg->latency_target);
  1499		}
  1500	
  1501		seq_printf(sf, "%s rbps=%s wbps=%s riops=%s wiops=%s%s%s\n",
  1502			   dname, bufs[0], bufs[1], bufs[2], bufs[3], idle_time,
  1503			   latency_time);
  1504		return 0;
  1505	}
  1506	

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-19 10:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-19 10:37 block/blk-throttle.c:1498:43: warning: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 17 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®