linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Pavel Machek <pavel@ucw.cz>, Bryan Wu <bryan.wu@canonical.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Jamie Iles <jamie@jamieiles.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-leds@vger.kernel.org
Subject: Re: [PATCH] leds: trigger: ledtrig-cpu:: Fix a warning when compiling with W=1
Date: Thu, 28 Sep 2023 14:09:58 +0100	[thread overview]
Message-ID: <20230928130958.GH9999@google.com> (raw)
In-Reply-To: <3f4be7a99933cf8566e630da54f6ab913caac432.1695453322.git.christophe.jaillet@wanadoo.fr>

On Sat, 23 Sep 2023, Christophe JAILLET wrote:

> In order to teach the compiler that 'trig->name' will never be truncated,
> we need to tell it that 'cpu' is not negative.
> 
> When building with W=1, this fixes the following warnings:
> 
>   drivers/leds/trigger/ledtrig-cpu.c: In function ‘ledtrig_cpu_init’:
>   drivers/leds/trigger/ledtrig-cpu.c:155:56: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 5 [-Werror=format-truncation=]
>     155 |                 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
>         |                                                        ^~
>   drivers/leds/trigger/ledtrig-cpu.c:155:52: note: directive argument in the range [-2147483648, 7]
>     155 |                 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
>         |                                                    ^~~~~~~
>   drivers/leds/trigger/ledtrig-cpu.c:155:17: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 8
>     155 |                 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
>         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Fixes: 8f88731d052d ("led-triggers: create a trigger for CPU activity")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/leds/trigger/ledtrig-cpu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

I made the subject line less generic and applied it, thanks.

-- 
Lee Jones [李琼斯]

      parent reply	other threads:[~2023-09-28 13:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-23  7:15 [PATCH] leds: trigger: ledtrig-cpu:: Fix a warning when compiling with W=1 Christophe JAILLET
2023-09-28 13:09 ` (subset) " Lee Jones
2023-09-28 13:09 ` Lee Jones [this message]

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=20230928130958.GH9999@google.com \
    --to=lee@kernel.org \
    --cc=bryan.wu@canonical.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=jamie@jamieiles.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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;
as well as URLs for NNTP newsgroup(s).