From: Michael Chang <mchang@suse.com>
To: grub-devel@gnu.org
Subject: [PATCH 3/3] reed_solomon: Fix array subscript 0 is outside array bounds
Date: Thu, 17 Mar 2022 14:43:42 +0800 [thread overview]
Message-ID: <20220317064342.25671-4-mchang@suse.com> (raw)
In-Reply-To: <20220317064342.25671-1-mchang@suse.com>
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 82779a296b..562bd2e3e3 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
next prev parent reply other threads:[~2022-03-17 6:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 6:43 [PATCH 0/3] Fix GCC 12 build error Michael Chang
2022-03-17 6:43 ` [PATCH 1/3] mkimage: Fix dangling pointer may be used error Michael Chang
2022-03-22 20:59 ` Daniel Kiper
2022-03-17 6:43 ` [PATCH 2/3] Fix -Werror=array-bounds array subscript 0 is outside array bounds Michael Chang
2022-03-22 21:19 ` Daniel Kiper
2022-03-23 4:51 ` Michael Chang
2022-03-17 6:43 ` Michael Chang [this message]
2022-03-17 7:41 ` [PATCH 3/3] reed_solomon: Fix " Paul Menzel
2022-03-17 8:59 ` Michael Chang
2022-03-22 21:21 ` Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220317064342.25671-4-mchang@suse.com \
--to=mchang@suse.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.