[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMuHMdW-hp9q_vGsbxwy1s6__Y8BoCQbPAzpzAojM9s0QNaRrg@mail.gmail.com>
Date: Mon, 20 Jan 2025 09:41:51 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Marek Vasut <marek.vasut@...lbox.org>
Cc: kernel test robot <lkp@...el.com>, Marek Vasut <marek.vasut+renesas@...lbox.org>,
oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Stephen Boyd <sboyd@...nel.org>
Subject: Re: drivers/clk/clk-renesas-pcie.c:178:31: warning: '%d' directive
output may be truncated writing between 1 and 4 bytes into a region of size 2
On Mon, Jan 20, 2025 at 8:19 AM Marek Vasut <marek.vasut@...lbox.org> wrote:
> On 1/20/25 12:45 AM, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 9528d418de4d83c7ada69314ddd8d4427b1f703a
> > commit: cd9a5c97dfdaeb9c8ac02e14d7ccbd445e8b5265 clk: rs9: Replace model check with bitshift from chip data
> > date: 1 year, 1 month ago
> > config: s390-randconfig-r111-20250120 (https://download.01.org/0day-ci/archive/20250120/202501200756.HycDH8wZ-lkp@intel.com/config)
> > compiler: s390-linux-gcc (GCC) 14.2.0
> > reproduce: (https://download.01.org/0day-ci/archive/20250120/202501200756.HycDH8wZ-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@...el.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202501200756.HycDH8wZ-lkp@intel.com/
> >
> > All warnings (new ones prefixed by >>):
> >
> > drivers/clk/clk-renesas-pcie.c: In function 'rs9_probe':
> >>> drivers/clk/clk-renesas-pcie.c:178:31: warning: '%d' directive output may be truncated writing between 1 and 4 bytes into a region of size 2 [-Wformat-truncation=]
> > 178 | snprintf(name, 5, "DIF%d", idx);
> > | ^~
> > In function 'rs9_get_output_config',
> > inlined from 'rs9_probe' at drivers/clk/clk-renesas-pcie.c:305:9:
> > drivers/clk/clk-renesas-pcie.c:178:27: note: directive argument in the range [-250, 63]
I'm wondering how the compiler arrives at this range?
> > 178 | snprintf(name, 5, "DIF%d", idx);
> > | ^~~~~~~
> > drivers/clk/clk-renesas-pcie.c:178:9: note: 'snprintf' output between 5 and 8 bytes into a destination of size 5
> > 178 | snprintf(name, 5, "DIF%d", idx);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> I can extend the name variable to length 8 to mitigate this warning, but
> there is some 8 DIF outputs maximum on this hardware, so it is known
> this %d field would not be longer than 1 decimal number. Shall I send
> such a patch ?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists