* 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
@ 2025-01-19 23:45 kernel test robot
2025-01-20 7:19 ` Marek Vasut
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2025-01-19 23:45 UTC (permalink / raw)
To: Marek Vasut; +Cc: oe-kbuild-all, linux-kernel, Stephen Boyd
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@intel.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]
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +178 drivers/clk/clk-renesas-pcie.c
603df193ec5174 Alexander Stein 2023-03-10 165
892e0ddea1aa6f Marek Vasut 2022-02-26 166 static int rs9_get_output_config(struct rs9_driver_data *rs9, int idx)
892e0ddea1aa6f Marek Vasut 2022-02-26 167 {
892e0ddea1aa6f Marek Vasut 2022-02-26 168 struct i2c_client *client = rs9->client;
603df193ec5174 Alexander Stein 2023-03-10 169 u8 dif = rs9_calc_dif(rs9, idx);
892e0ddea1aa6f Marek Vasut 2022-02-26 170 unsigned char name[5] = "DIF0";
892e0ddea1aa6f Marek Vasut 2022-02-26 171 struct device_node *np;
892e0ddea1aa6f Marek Vasut 2022-02-26 172 int ret;
892e0ddea1aa6f Marek Vasut 2022-02-26 173 u32 sr;
892e0ddea1aa6f Marek Vasut 2022-02-26 174
892e0ddea1aa6f Marek Vasut 2022-02-26 175 /* Set defaults */
603df193ec5174 Alexander Stein 2023-03-10 176 rs9->clk_dif_sr |= dif;
892e0ddea1aa6f Marek Vasut 2022-02-26 177
892e0ddea1aa6f Marek Vasut 2022-02-26 @178 snprintf(name, 5, "DIF%d", idx);
892e0ddea1aa6f Marek Vasut 2022-02-26 179 np = of_get_child_by_name(client->dev.of_node, name);
892e0ddea1aa6f Marek Vasut 2022-02-26 180 if (!np)
892e0ddea1aa6f Marek Vasut 2022-02-26 181 return 0;
892e0ddea1aa6f Marek Vasut 2022-02-26 182
892e0ddea1aa6f Marek Vasut 2022-02-26 183 /* Output clock slew rate */
892e0ddea1aa6f Marek Vasut 2022-02-26 184 ret = of_property_read_u32(np, "renesas,slew-rate", &sr);
892e0ddea1aa6f Marek Vasut 2022-02-26 185 of_node_put(np);
892e0ddea1aa6f Marek Vasut 2022-02-26 186 if (!ret) {
892e0ddea1aa6f Marek Vasut 2022-02-26 187 if (sr == 2000000) { /* 2V/ns */
603df193ec5174 Alexander Stein 2023-03-10 188 rs9->clk_dif_sr &= ~dif;
892e0ddea1aa6f Marek Vasut 2022-02-26 189 } else if (sr == 3000000) { /* 3V/ns (default) */
603df193ec5174 Alexander Stein 2023-03-10 190 rs9->clk_dif_sr |= dif;
892e0ddea1aa6f Marek Vasut 2022-02-26 191 } else
892e0ddea1aa6f Marek Vasut 2022-02-26 192 ret = dev_err_probe(&client->dev, -EINVAL,
892e0ddea1aa6f Marek Vasut 2022-02-26 193 "Invalid renesas,slew-rate value\n");
892e0ddea1aa6f Marek Vasut 2022-02-26 194 }
892e0ddea1aa6f Marek Vasut 2022-02-26 195
892e0ddea1aa6f Marek Vasut 2022-02-26 196 return ret;
892e0ddea1aa6f Marek Vasut 2022-02-26 197 }
892e0ddea1aa6f Marek Vasut 2022-02-26 198
:::::: The code at line 178 was first introduced by commit
:::::: 892e0ddea1aa6f70b68cb2dd8e16bf271e20e72f clk: rs9: Add Renesas 9-series PCIe clock generator driver
:::::: TO: Marek Vasut <marex@denx.de>
:::::: CC: Stephen Boyd <sboyd@kernel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* 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
2025-01-19 23:45 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 kernel test robot
@ 2025-01-20 7:19 ` Marek Vasut
2025-01-20 8:41 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2025-01-20 7:19 UTC (permalink / raw)
To: kernel test robot, Marek Vasut; +Cc: oe-kbuild-all, linux-kernel, Stephen Boyd
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@intel.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]
> 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 ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* 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
2025-01-20 7:19 ` Marek Vasut
@ 2025-01-20 8:41 ` Geert Uytterhoeven
0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2025-01-20 8:41 UTC (permalink / raw)
To: Marek Vasut
Cc: kernel test robot, Marek Vasut, oe-kbuild-all, linux-kernel,
Stephen Boyd
On Mon, Jan 20, 2025 at 8:19 AM Marek Vasut <marek.vasut@mailbox.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@intel.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@linux-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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-20 8:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-19 23:45 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 kernel test robot
2025-01-20 7:19 ` Marek Vasut
2025-01-20 8:41 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox