grub2/0003-reed_solomon-Fix-array-subscript-0-is-outside-array-.patch
Michael Chang 91bf25e435 Accepting request 962324 from home:michael-chang:gcc12:grub2
- Fix GCC 12 build failure (bsc#1196546)
  * 0001-mkimage-Fix-dangling-pointer-may-be-used-error.patch
  * 0002-Fix-Werror-array-bounds-array-subscript-0-is-outside.patch
  * 0003-reed_solomon-Fix-array-subscript-0-is-outside-array-.patch
- Revised
  * grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
  * 0002-ieee1275-powerpc-enables-device-mapper-discovery.patch

OBS-URL: https://build.opensuse.org/request/show/962324
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=408
2022-03-18 07:29:19 +00:00

52 lines
1.5 KiB
Diff

From 0b1b1666ecd98d577cb72b3f4acdbe3af2e86a84 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Wed, 16 Mar 2022 17:59:30 +0800
Subject: [PATCH 3/3] reed_solomon: Fix array subscript 0 is outside array
bounds
The grub_absolute_pointer() is a compound expression that can only work
within a function. We are out of luck here when the pointer variables
require global definition due to ATTRIBUTE_TEXT that have to use fully
initialized global definition because of the way linkers work.
static gf_single_t * const gf_powx ATTRIBUTE_TEXT = (void *) 0x100000;
For the reason given above, use gcc diagnostic pragmas to suppress the
array-bounds warning.
Signed-off-by: Michael Chang <mchang@suse.com>
---
grub-core/lib/reed_solomon.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c
index 467305b46a..817db6a234 100644
--- a/grub-core/lib/reed_solomon.c
+++ b/grub-core/lib/reed_solomon.c
@@ -102,6 +102,11 @@ static gf_single_t errvals[256];
static gf_single_t eqstat[65536 + 256];
#endif
+#if __GNUC__ == 12
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+
static gf_single_t
gf_mul (gf_single_t a, gf_single_t b)
{
@@ -319,6 +324,10 @@ decode_block (gf_single_t *ptr, grub_size_t s,
}
}
+#if __GNUC__ == 12
+#pragma GCC diagnostic pop
+#endif
+
#if !defined (STANDALONE)
static void
encode_block (gf_single_t *ptr, grub_size_t s,
--
2.34.1