[PATCH] net: wwan: t7xx: do not compile with -Werror by default

From: Jiri Slaby (SUSE)
Date: Wed Mar 29 2023 - 06:26:52 EST


When playing with various compilers or their versions, some choke on
the t7xx code. For example (with gcc 13):
In file included from ./arch/s390/include/generated/asm/rwonce.h:1,
from ../include/linux/compiler.h:247,
from ../include/linux/build_bug.h:5,
from ../include/linux/bits.h:22,
from ../drivers/net/wwan/t7xx/t7xx_state_monitor.c:17:
In function 'preempt_count',
inlined from 't7xx_fsm_append_event' at ../drivers/net/wwan/t7xx/t7xx_state_monitor.c:439:43:
../include/asm-generic/rwonce.h:44:26: error: array subscript 0 is outside array bounds of 'const volatile int[0]' [-Werror=array-bounds=]

There is no reason for any code in the kernel to be built with -Werror
by default. Note that we have generic CONFIG_WERROR. OTOH, some drivers
may want to do this only on per-driver basis. Some do
CONFIG_DRM_I915_WERROR or alike. But I reused the scsi's:
ifdef WARNINGS_BECOME_ERRORS
approach.

Now, if one wants to build t7xx with -Werror, they may say:
make WARNINGS_BECOME_ERRORS=1

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@xxxxxxxxxx>
Cc: Chandrashekar Devegowda <chandrashekar.devegowda@xxxxxxxxx>
Cc: Intel Corporation <linuxwwan@xxxxxxxxx>
Cc: Chiranjeevi Rapolu <chiranjeevi.rapolu@xxxxxxxxxxxxxxx>
Cc: Liu Haijun <haijun.liu@xxxxxxxxxxxx>
Cc: M Chetan Kumar <m.chetan.kumar@xxxxxxxxxxxxxxx>
Cc: Ricardo Martinez <ricardo.martinez@xxxxxxxxxxxxxxx>
Cc: Loic Poulain <loic.poulain@xxxxxxxxxx>
Cc: Sergey Ryazanov <ryazanov.s.a@xxxxxxxxx>
Cc: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
---
drivers/net/wwan/t7xx/Makefile | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/wwan/t7xx/Makefile b/drivers/net/wwan/t7xx/Makefile
index 268ff9e87e5b..29622c2c4533 100644
--- a/drivers/net/wwan/t7xx/Makefile
+++ b/drivers/net/wwan/t7xx/Makefile
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-only

+ifdef WARNINGS_BECOME_ERRORS
ccflags-y += -Werror
+endif

obj-${CONFIG_MTK_T7XX} := mtk_t7xx.o
mtk_t7xx-y:= t7xx_pci.o \
--
2.40.0