From nobody Fri Jan 2 20:53:01 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B343E95A8B for ; Sun, 8 Oct 2023 01:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344315AbjJHBsS (ORCPT ); Sat, 7 Oct 2023 21:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344257AbjJHBsP (ORCPT ); Sat, 7 Oct 2023 21:48:15 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id E940B92; Sat, 7 Oct 2023 18:48:12 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 1CD25604A13E3; Sun, 8 Oct 2023 09:48:06 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui Cc: Su Hui , tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] blk-throttle: silence truncated string warning Date: Sun, 8 Oct 2023 09:47:52 +0800 Message-Id: <20231008014751.423133-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org using gcc and w=3D1, there are some warnings like these: block/blk-throttle.c:1531:53: error: =E2=80=98snprintf=E2=80=99 output may be truncated before the last format c= haracter [-Werror=3Dformat-truncation=3D] 1531 | snprintf(idle_time, sizeof(idle_time), " idle=3D%lu", | ^ block/blk-throttle.c:1531:4: note: =E2=80=98snprintf=E2=80=99 output betwee= n 8 and 27 bytes into a destination of size 26 1531 | snprintf(idle_time, sizeof(idle_time), " idle=3D%lu", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1532 | tg->idletime_threshold_conf); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ block/blk-throttle.c:1538:15: error: =E2=80=98%lu=E2=80=99 directive output may be truncated writing between 1 a= nd 20 bytes into a region of size 17 [-Werror=3Dformat-truncation=3D] 1538 | " latency=3D%lu", tg->latency_target_conf); | ^~~ "%lu" can up to 21, so string " idle=3D%lu" can up to 27. But 'idle_time' only has 26 Bytes. It's same for 'latency_time' whose size should be 30 rather than 26 because string " latency=3D%lu" can up to 30. Signed-off-by: Su Hui --- 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 38a881cf97d0..dfc5c0d3d9c1 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1489,8 +1489,8 @@ static u64 tg_prfill_limit(struct seq_file *sf, struc= t blkg_policy_data *pd, char bufs[4][21] =3D { "max", "max", "max", "max" }; u64 bps_dft; unsigned int iops_dft; - char idle_time[26] =3D ""; - char latency_time[26] =3D ""; + char idle_time[27] =3D ""; + char latency_time[30] =3D ""; =20 if (!dname) return 0; --=20 2.30.2