diff mbox series

[net-next] can: kvaser_usb: silence a GCC 12 -Warray-bounds warning

Message ID 20220520194659.2356903-1-kuba@kernel.org (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net-next] can: kvaser_usb: silence a GCC 12 -Warray-bounds warning | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jakub Kicinski May 20, 2022, 7:46 p.m. UTC
This driver does a lot of casting of smaller buffers to
struct kvaser_cmd_ext, GCC 12 does not like that:

drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript ‘struct kvaser_cmd_ext[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro ‘le16_to_cpu’
  489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
      |                       ^~~~~~~~~~~

Temporarily silence this warning (move it to W=1 builds).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
Hi Marc, are you planning another -next PR? Can we take this
directly?

CC: wg@grandegger.com
CC: mkl@pengutronix.de
CC: linux-can@vger.kernel.org
---
 drivers/net/can/usb/kvaser_usb/Makefile | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Marc Kleine-Budde May 23, 2022, 12:14 p.m. UTC | #1
On 20.05.2022 12:46:59, Jakub Kicinski wrote:
> This driver does a lot of casting of smaller buffers to
> struct kvaser_cmd_ext, GCC 12 does not like that:
> 
> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript ‘struct kvaser_cmd_ext[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro ‘le16_to_cpu’
>   489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
>       |                       ^~~~~~~~~~~
> 
> Temporarily silence this warning (move it to W=1 builds).
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> Hi Marc, are you planning another -next PR? Can we take this
> directly?

Thanks, applied and I'll send a -next PR soonish.

Marc
Marc Kleine-Budde May 23, 2022, 8:12 p.m. UTC | #2
On 23.05.2022 14:14:25, Marc Kleine-Budde wrote:
> On 20.05.2022 12:46:59, Jakub Kicinski wrote:
> > This driver does a lot of casting of smaller buffers to
> > struct kvaser_cmd_ext, GCC 12 does not like that:
> > 
> > drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript ‘struct kvaser_cmd_ext[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
> > drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro ‘le16_to_cpu’
> >   489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
> >       |                       ^~~~~~~~~~~
> > 
> > Temporarily silence this warning (move it to W=1 builds).
> > 
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> > ---
> > Hi Marc, are you planning another -next PR? Can we take this
> > directly?
> 
> Thanks, applied and I'll send a -next PR soonish.

Available here:

https://lore.kernel.org/all/20220523201045.1708855-1-mkl@pengutronix.de/

Marc
diff mbox series

Patch

diff --git a/drivers/net/can/usb/kvaser_usb/Makefile b/drivers/net/can/usb/kvaser_usb/Makefile
index cf260044f0b9..b20d951a0790 100644
--- a/drivers/net/can/usb/kvaser_usb/Makefile
+++ b/drivers/net/can/usb/kvaser_usb/Makefile
@@ -1,3 +1,8 @@ 
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
 kvaser_usb-y = kvaser_usb_core.o kvaser_usb_leaf.o kvaser_usb_hydra.o
+
+# FIXME: temporarily silence -Warray-bounds on non W=1+ builds
+ifndef KBUILD_EXTRA_WARN
+CFLAGS_kvaser_usb_hydra.o += -Wno-array-bounds
+endif