diff mbox series

[net-next,8/8] wifi: carl9170: silence a GCC 12 -Warray-bounds warning

Message ID 20220520194320.2356236-9-kuba@kernel.org
State New
Headers show
Series Fix/silence GCC 12 warnings in drivers/net/wireless/ | expand

Commit Message

Jakub Kicinski May 20, 2022, 7:43 p.m. UTC
carl9170 has a big union (struct carl9170_cmd) with all the command
types in it. But it allocates buffers only large enough for a given
command. This upsets GCC 12:

drivers/net/wireless/ath/carl9170/cmd.c:125:30: warning: array subscript ‘struct carl9170_cmd[0]’ is partly outside array bounds of ‘unsigned char[8]’ [-Warray-bounds]
  125 |                 tmp->hdr.cmd = cmd;
      |                 ~~~~~~~~~~~~~^~~~~

Punt the warning to W=1 for now. Hopefully GCC will learn to
recognize which fields are in-bounds.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: chunkeey@googlemail.com
CC: kvalo@kernel.org
CC: linux-wireless@vger.kernel.org
---
 drivers/net/wireless/ath/carl9170/Makefile | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Christian Lamparter May 20, 2022, 7:58 p.m. UTC | #1
On 20/05/2022 21:43, Jakub Kicinski wrote:
> carl9170 has a big union (struct carl9170_cmd) with all the command
> types in it. But it allocates buffers only large enough for a given
> command. This upsets GCC 12:
> 
> drivers/net/wireless/ath/carl9170/cmd.c:125:30: warning: array subscript ‘struct carl9170_cmd[0]’ is partly outside array bounds of ‘unsigned char[8]’ [-Warray-bounds]
>    125 |                 tmp->hdr.cmd = cmd;
>        |                 ~~~~~~~~~~~~~^~~~~
> 
> Punt the warning to W=1 for now. Hopefully GCC will learn to
> recognize which fields are in-bounds.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/carl9170/Makefile b/drivers/net/wireless/ath/carl9170/Makefile
index 1a81868ce26d..7463baa62fa8 100644
--- a/drivers/net/wireless/ath/carl9170/Makefile
+++ b/drivers/net/wireless/ath/carl9170/Makefile
@@ -3,3 +3,8 @@  carl9170-objs := main.o usb.o cmd.o mac.o phy.o led.o fw.o tx.o rx.o
 carl9170-$(CONFIG_CARL9170_DEBUGFS) += debug.o
 
 obj-$(CONFIG_CARL9170) += carl9170.o
+
+# FIXME: temporarily silence -Warray-bounds on non W=1+ builds
+ifndef KBUILD_EXTRA_WARN
+CFLAGS_cmd.o += -Wno-array-bounds
+endif