grub/grub-core/disk
Michael Chang bdf170d101 mdraid1x_linux: Fix gcc10 error -Werror=array-bounds
We bumped into the build error while testing gcc-10 pre-release.

../../grub-core/disk/mdraid1x_linux.c: In function 'grub_mdraid_detect':
../../grub-core/disk/mdraid1x_linux.c:181:15: error: array subscript <unknown> is outside array bounds of 'grub_uint16_t[0]' {aka 'short unsigned int[0]'} [-Werror=array-bounds]
  181 |      (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)]
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../grub-core/disk/mdraid1x_linux.c:98:17: note: while referencing 'dev_roles'
   98 |   grub_uint16_t dev_roles[0]; /* Role in array, or 0xffff for a spare, or 0xfffe for faulty.  */
      |                 ^~~~~~~~~
../../grub-core/disk/mdraid1x_linux.c:127:33: note: defined here 'sb'
  127 |       struct grub_raid_super_1x sb;
      |                                 ^~
cc1: all warnings being treated as errors

Apparently gcc issues the warning when trying to access sb.dev_roles
array's member, since it is a zero length array as the last element of
struct grub_raid_super_1x that is allocated sparsely without extra
chunks for the trailing bits, so the warning looks legitimate in this
regard.

As the whole thing here is doing offset computation, it is undue to use
syntax that would imply array member access then take address from it
later. Instead we could accomplish the same thing through basic array
pointer arithmetic to pacify the warning.

Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-31 12:17:02 +02:00
..
arc Rename grub_disk members 2019-03-25 15:14:52 +01:00
efi efidisk: NULL pointer dereference in grub_efidisk_get_device_name() 2019-04-02 13:09:08 +02:00
i386/pc Rename grub_disk members 2019-03-25 15:14:52 +01:00
ieee1275 Rename grub_disk members 2019-03-25 15:14:52 +01:00
uboot Rename grub_disk members 2019-03-25 15:14:52 +01:00
xen Rename grub_disk members 2019-03-25 15:14:52 +01:00
AFSplitter.c afsplitter: Move into its own module 2020-01-10 14:27:49 +01:00
ahci.c ahci: Increase time-out from 10 s to 32 s 2018-09-13 10:54:54 +02:00
ata.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
cryptodisk.c luks: Move configuration of ciphers into cryptodisk 2020-01-10 14:29:37 +01:00
diskfilter.c misc: Make grub_strtol() "end" pointers have safer const qualifiers 2020-02-28 12:41:29 +01:00
dmraid_nvidia.c dmraid_nvidia: Set a name to usable value to avoid null dereference. 2015-07-22 01:57:40 +02:00
geli.c disk/geli: Add missing free. 2015-01-24 21:47:51 +01:00
host.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
ldm.c disk: Update grub_gpt_partentry 2018-04-23 13:21:45 +02:00
loopback.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
luks.c luks: Move configuration of ciphers into cryptodisk 2020-01-10 14:29:37 +01:00
luks2.c luks2: Add missing newline to debug message 2020-02-28 12:27:55 +01:00
lvm.c lvm: Add LVM cache logical volume handling 2020-03-31 11:59:35 +02:00
mdraid1x_linux.c mdraid1x_linux: Fix gcc10 error -Werror=array-bounds 2020-03-31 12:17:02 +02:00
mdraid_linux.c cleanup: grub_cpu_to_XXX_compile_time for constants 2014-09-22 20:47:10 +04:00
mdraid_linux_be.c Handle big-endian mdraid. 2012-03-26 16:10:40 +02:00
memdisk.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
pata.c Add PCI command activation to all PCI drivers as required for coreboot 2013-11-26 14:21:11 +01:00
raid5_recover.c * include/grub/diskfilter.h (grub_raid5_recover_func_t): Use proper 2012-06-25 17:36:50 +02:00
raid6_recover.c btrfs: Make more generic the code for RAID 6 rebuilding 2018-10-31 12:07:29 +01:00
scsi.c Rename grub_disk members 2019-03-25 15:14:52 +01:00
usbms.c cleanup: grub_cpu_to_XXX_compile_time for constants 2014-09-22 20:47:10 +04:00