Skip to content

Commit b5fc3ca

Browse files
committed
ARM: ixp4xx: Replace 0-length arrays with flexible arrays
Zero-length arrays are deprecated[1]. Replace npe_load_firmware's union of 0-length arrays with flexible arrays. Detected with GCC 13, using -fstrict-flex-arrays=3: drivers/soc/ixp4xx/ixp4xx-npe.c: In function 'npe_load_firmware': drivers/soc/ixp4xx/ixp4xx-npe.c:570:60: warning: array subscript i is outside array bounds of 'u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=] 570 | image->data[i] = swab32(image->data[i]); include/uapi/linux/swab.h:115:54: note: in definition of macro '__swab32' 115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) | ^ drivers/soc/ixp4xx/ixp4xx-npe.c:570:42: note: in expansion of macro 'swab32' 570 | image->data[i] = swab32(image->data[i]); | ^~~~~~ drivers/soc/ixp4xx/ixp4xx-npe.c:522:29: note: while referencing 'data' 522 | u32 data[0]; | ^~~~ [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Cc: Krzysztof Halasa <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 439a1bc commit b5fc3ca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/soc/ixp4xx/ixp4xx-npe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,15 @@ int npe_load_firmware(struct npe *npe, const char *name, struct device *dev)
519519
u32 id;
520520
u32 size;
521521
union {
522-
u32 data[0];
523-
struct dl_block blocks[0];
522+
DECLARE_FLEX_ARRAY(u32, data);
523+
DECLARE_FLEX_ARRAY(struct dl_block, blocks);
524524
};
525525
} *image;
526526

527527
struct dl_codeblock {
528528
u32 npe_addr;
529529
u32 size;
530-
u32 data[0];
530+
u32 data[];
531531
} *cb;
532532

533533
int i, j, err, data_size, instr_size, blocks, table_end;

0 commit comments

Comments
 (0)