sparc: openpromio: Address -Warray-bounds warning
authorGustavo A. R. Silva <gustavoars@kernel.org>
Thu, 22 Jun 2023 23:14:51 +0000 (17:14 -0600)
committerGustavo A. R. Silva <gustavoars@kernel.org>
Wed, 12 Jul 2023 19:24:20 +0000 (13:24 -0600)
commit221a4b56ec70c1a9f09ce78751613d16c508a4ce
tree57d1913ca0a6fa7ea90f96a08908f616d09137cd
parent76d2ceda723c90ad7ee93224b8ebaeeb4ea13203
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: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/322
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
arch/sparc/include/uapi/asm/openpromio.h