Skip to contentSkip to conversation

can: kvaser_usb: silence a GCC 12 -Warray-bounds warning

PATCH Applied Jakub Kicinski 2 participants 3 messages May 20, 2022 – May 23, 2022

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 can: kvaser_usb: silence a GCC 12 -Warray-bounds warning

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

---
Hi Marc, are you planning another -next PR? Can we take this directly?

---
 drivers/net/can/usb/kvaser_usb/Makefile | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/can/usb/kvaser_usb/Makefile +5 -0
index cf260044f0b9..b20d951a0790 100644
@@ -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
Signature · 1 line
2.34.3
maintainer Applied
#1 lore raw
Quoted 8 lines · Jakub Kicinski

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);
      |                       ^~~~~~~~~~~
Quoted 6 lines

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

---
Hi Marc, are you planning another -next PR? Can we take this directly?

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

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#2 lore raw
Quoted 9 lines · Marc Kleine-Budde
Quoted 8 lines · Jakub Kicinski

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);
      |                       ^~~~~~~~~~~
Quoted 8 lines
Quoted 6 lines

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

---
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/[email protected]/

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |