Thread (17 messages) 17 messages, 4 authors, 2023-10-26

Re: [PATCH 3/4] mdadm: Avoid array bounds check of gcc

From: Paul Menzel <hidden>
Date: 2023-09-27 05:01:44

Dear Xiao,


Thank you for your patch.

Am 27.09.23 um 04:52 schrieb Xiao Ni:
With gcc version 13.2.1 20230918 (Red Hat 13.2.1-3) (GCC), it reports error:
super-ddf.c:1988:58: error: array subscript -1 is below array bounds of
‘struct phys_disk_entry[0]’ [-Werror=array-bounds=]
I wouldn’t wrap pasted lines.
The subscrit is defined as int type. And it can be smaller than 0.
subscript?
To avoid this error, add -Wno-array-bounds flag in Makefile.
Wouldn’t it be better to fix the error and not work around it by 
disabling the warning?


Kind regards,

Paul

quoted hunk ↗ jump to hunk
Signed-off-by: Xiao Ni <redacted>
---
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 5eac1a4e9690..47da883a9fb9 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ ifeq ($(origin CC),default)
  CC := $(CROSS_COMPILE)gcc
  endif
  CXFLAGS ?= -ggdb
-CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter
+CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -Wno-array-bounds
  ifdef WARN_UNUSED
  CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O3
  endif
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help