llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* clang: net: qed_main.c:1227:3: error: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 18 [-Werror,-Wfortify-source]
@ 2023-08-28 12:27 Naresh Kamboju
  2023-08-28 14:48 ` Nathan Chancellor
  2023-08-28 14:52 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Naresh Kamboju @ 2023-08-28 12:27 UTC (permalink / raw)
  To: clang-built-linux, linux-stable, lkft-triage
  Cc: Netdev, David Miller, Eric Dumazet, Sasha Levin,
	Greg Kroah-Hartman, Nathan Chancellor, Nick Desaulniers

[My two cents]

stable-rc linux-6.1.y and linux-6.4.y x86 clang-nightly builds fail with
following warnings / errors.

Build errors:
--------------
drivers/net/ethernet/qlogic/qed/qed_main.c:1227:3: error: 'snprintf'
will always be truncated; specified size is 16, but format string
expands to at least 18 [-Werror,-Wfortify-source]
 1227 |                 snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
      |                 ^
1 error generated.

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

--
Linaro LKFT
https://lkft.linaro.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: clang: net: qed_main.c:1227:3: error: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 18 [-Werror,-Wfortify-source]
  2023-08-28 12:27 clang: net: qed_main.c:1227:3: error: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 18 [-Werror,-Wfortify-source] Naresh Kamboju
@ 2023-08-28 14:48 ` Nathan Chancellor
  2023-08-28 14:52 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-08-28 14:48 UTC (permalink / raw)
  To: Naresh Kamboju
  Cc: clang-built-linux, linux-stable, lkft-triage, Netdev,
	David Miller, Eric Dumazet, Sasha Levin, Greg Kroah-Hartman,
	Nick Desaulniers, Ariel Elior, Manish Chopra

Hi Naresh,

On Mon, Aug 28, 2023 at 05:57:38PM +0530, Naresh Kamboju wrote:
> [My two cents]
> 
> stable-rc linux-6.1.y and linux-6.4.y x86 clang-nightly builds fail with
> following warnings / errors.
> 
> Build errors:
> --------------
> drivers/net/ethernet/qlogic/qed/qed_main.c:1227:3: error: 'snprintf'
> will always be truncated; specified size is 16, but format string
> expands to at least 18 [-Werror,-Wfortify-source]
>  1227 |                 snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
>       |                 ^
> 1 error generated.
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

Thank you as always for the report. This is a result of a change in
clang to implement the equivalent of GCC's -Wformat-truncation, which is
currently disabled for the whole kernel in mainline and enabled in W=1
in -next. I have filed an issue to figure out what to do about this:
https://github.com/ClangBuiltLinux/linux/issues/1923

For the record, if you see an issue with clang-nightly that you do not
see with older versions of clang, it is generally an indication that
something has changed on the toolchain side, so it is probably not worth
bothering the stable or subsystem folks with the initial report.
Consider just messaging Nick, myself, and llvm@lists.linux.dev in those
cases so we can pre-triage and bring other folks in as necessary.

That said, this seems like a legitimate warning. As I mentioned above,
GCC shows the same warning with W=1 in -next, so this should be fixed.

  drivers/net/ethernet/qlogic/qed/qed_main.c: In function 'qed_slowpath_start':
  drivers/net/ethernet/qlogic/qed/qed_main.c:1218:63: error: '%02x' directive output truncated writing 2 bytes into a region of size 1 [-Werror=format-truncation=]
   1218 |                 snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
        |                                                               ^~~~
  In function 'qed_slowpath_wq_start',
      inlined from 'qed_slowpath_start' at drivers/net/ethernet/qlogic/qed/qed_main.c:1250:6:
  drivers/net/ethernet/qlogic/qed/qed_main.c:1218:43: note: directive argument in the range [0, 255]
   1218 |                 snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
        |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/net/ethernet/qlogic/qed/qed_main.c:1218:17: note: 'snprintf' output 18 bytes into a destination of size 16
   1218 |                 snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1219 |                          cdev->pdev->bus->number,
        |                          ~~~~~~~~~~~~~~~~~~~~~~~~
   1220 |                          PCI_SLOT(cdev->pdev->devfn), hwfn->abs_pf_id);
        |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: clang: net: qed_main.c:1227:3: error: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 18 [-Werror,-Wfortify-source]
  2023-08-28 12:27 clang: net: qed_main.c:1227:3: error: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 18 [-Werror,-Wfortify-source] Naresh Kamboju
  2023-08-28 14:48 ` Nathan Chancellor
@ 2023-08-28 14:52 ` Greg Kroah-Hartman
  2023-08-28 17:30   ` Naresh Kamboju
  1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-08-28 14:52 UTC (permalink / raw)
  To: Naresh Kamboju
  Cc: clang-built-linux, linux-stable, lkft-triage, Netdev,
	David Miller, Eric Dumazet, Sasha Levin, Nathan Chancellor,
	Nick Desaulniers

On Mon, Aug 28, 2023 at 05:57:38PM +0530, Naresh Kamboju wrote:
> [My two cents]
> 
> stable-rc linux-6.1.y and linux-6.4.y x86 clang-nightly builds fail with
> following warnings / errors.
> 
> Build errors:
> --------------
> drivers/net/ethernet/qlogic/qed/qed_main.c:1227:3: error: 'snprintf'
> will always be truncated; specified size is 16, but format string
> expands to at least 18 [-Werror,-Wfortify-source]
>  1227 |                 snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
>       |                 ^
> 1 error generated.
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

Is this also an issue in 6.5?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: clang: net: qed_main.c:1227:3: error: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 18 [-Werror,-Wfortify-source]
  2023-08-28 14:52 ` Greg Kroah-Hartman
@ 2023-08-28 17:30   ` Naresh Kamboju
  0 siblings, 0 replies; 4+ messages in thread
From: Naresh Kamboju @ 2023-08-28 17:30 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: clang-built-linux, linux-stable, lkft-triage, Netdev,
	David Miller, Eric Dumazet, Sasha Levin, Nathan Chancellor,
	Nick Desaulniers

On Mon, 28 Aug 2023 at 20:22, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Mon, Aug 28, 2023 at 05:57:38PM +0530, Naresh Kamboju wrote:
> > [My two cents]
> >
> > stable-rc linux-6.1.y and linux-6.4.y x86 clang-nightly builds fail with
> > following warnings / errors.
> >
> > Build errors:
> > --------------
> > drivers/net/ethernet/qlogic/qed/qed_main.c:1227:3: error: 'snprintf'
> > will always be truncated; specified size is 16, but format string
> > expands to at least 18 [-Werror,-Wfortify-source]
> >  1227 |                 snprintf(name, NAME_SIZE, "slowpath-%02x:%02x.%02x",
> >       |                 ^
> > 1 error generated.
> >
> > Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
>
> Is this also an issue in 6.5?

I see it on 6.5, Linux next-20230828 tag, stable 6.4 and 6.1.

- Naresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-28 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 12:27 clang: net: qed_main.c:1227:3: error: 'snprintf' will always be truncated; specified size is 16, but format string expands to at least 18 [-Werror,-Wfortify-source] Naresh Kamboju
2023-08-28 14:48 ` Nathan Chancellor
2023-08-28 14:52 ` Greg Kroah-Hartman
2023-08-28 17:30   ` Naresh Kamboju

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).