Linux block layer
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: tj@kernel.org, axboe@kernel.dk, josef@toxicpanda.com, shli@fb.com
Cc: linux-block@vger.kernel.org, cgroups@vger.kernel.org,
	John Garry <john.g.garry@oracle.com>
Subject: [PATCH] blk-throttle: Fix W=1 build issue in tg_prfill_limit()
Date: Mon, 25 Mar 2024 12:19:05 +0000	[thread overview]
Message-ID: <20240325121905.2869271-1-john.g.garry@oracle.com> (raw)

For when using gcc 8 and above, the following warnings can be seen when
compiling blk-throttle.c with W=1:

block/blk-throttle.c: In function ‘tg_prfill_limit’:
block/blk-throttle.c:1539:53: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
    snprintf(idle_time, sizeof(idle_time), " idle=%lu",
                                                     ^
block/blk-throttle.c:1539:4: note: ‘snprintf’ output between 8 and 27 bytes into a destination of size 26
    snprintf(idle_time, sizeof(idle_time), " idle=%lu",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     tg->idletime_threshold_conf);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
block/blk-throttle.c:1546:15: error: ‘%lu’ directive output may be truncated writing between 1 and 20 bytes into a region of size 17 [-Werror=format-truncation=]
     " latency=%lu", tg->latency_target_conf);
               ^~~
block/blk-throttle.c:1546:5: note: directive argument in the range [0, 18446744073709551614]
     " latency=%lu", tg->latency_target_conf);
     ^~~~~~~~~~~~~~
block/blk-throttle.c:1545:4: note: ‘snprintf’ output between 11 and 30 bytes into a destination of size 26
    snprintf(latency_time, sizeof(latency_time),
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     " latency=%lu", tg->latency_target_conf);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [scripts/Makefile.build:244: block/blk-throttle.o] Error 1

Increase idle_time[] and latency_time[] sizes to clear the warnings.

Fixes: ec80991d6fc2c ("blk-throttle: add interface for per-cgroup target latency")
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 block/blk-throttle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index f4850a6f860b..ece272937792 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -1497,8 +1497,8 @@ static u64 tg_prfill_limit(struct seq_file *sf, struct blkg_policy_data *pd,
 	char bufs[4][21] = { "max", "max", "max", "max" };
 	u64 bps_dft;
 	unsigned int iops_dft;
-	char idle_time[26] = "";
-	char latency_time[26] = "";
+	char idle_time[27] = "";
+	char latency_time[30] = "";
 
 	if (!dname)
 		return 0;
-- 
2.31.1


             reply	other threads:[~2024-03-25 12:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 12:19 John Garry [this message]
2024-03-26  7:03 ` [PATCH] blk-throttle: Fix W=1 build issue in tg_prfill_limit() Christoph Hellwig
2024-03-26  8:46   ` John Garry
2024-03-26 14:49     ` Christoph Hellwig
2024-03-26 14:57       ` John Garry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240325121905.2869271-1-john.g.garry@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=shli@fb.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox