Skip to content

Commit 221a4b5

Browse files
sparc: openpromio: Address -Warray-bounds warning
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct openpromio. Address the following warning found after building (with GCC-13) sparc with sparc64_defconfig: In function 'opromgetprop', inlined from 'openprom_sunos_ioctl.isra' at drivers/sbus/char/openprom.c:312:11: drivers/sbus/char/openprom.c:141:24: warning: array subscript 1 is above array bounds of 'char[1]' [-Warray-bounds=] 141 | op->oprom_array[len] = '\0'; | ~~~~~~~~~~~~~~~^~~~~ In file included from drivers/sbus/char/openprom.c:31: arch/sparc/include/uapi/asm/openpromio.h: In function 'openprom_sunos_ioctl.isra': arch/sparc/include/uapi/asm/openpromio.h:16:17: note: while referencing 'oprom_array' 16 | char oprom_array[1]; /* Holds property names and values. */ | ^~~~~~~~~~~ This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -Warray-bounds. This results in no differences in binary output. Link: KSPP#79 Link: KSPP#322 Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
1 parent 76d2ced commit 221a4b5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/sparc/include/uapi/asm/openpromio.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
* were chosen to be exactly equal to the SunOS equivalents.
1111
*/
1212

13-
struct openpromio
14-
{
13+
struct openpromio {
1514
unsigned int oprom_size; /* Actual size of the oprom_array. */
16-
char oprom_array[1]; /* Holds property names and values. */
15+
char oprom_array[]; /* Holds property names and values. */
1716
};
1817

1918
#define OPROMMAXPARAM 4096 /* Maximum size of oprom_array. */

0 commit comments

Comments
 (0)