From: "Grégoire Sutre" <gregoire.sutre@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: GRUB warning level increase
Date: Sun, 12 Feb 2012 15:25:02 +0100 [thread overview]
Message-ID: <4F37CBBE.8010104@gmail.com> (raw)
In-Reply-To: <4F353F08.5000808@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]
On 02/10/2012 05:00 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> Hello, all. I have increased the warning level in GRUB. This is done for
> quicker discovery and correction of the bugs which would be otherwise
> hard to track. Mostly it enabled warnings regarding guidelines which are
> already followed by GRUB.
On Debian GNU/Linux amd64 with GCC 4.6.2, I get a number of warnings
triggered by -Wunsafe-loop-optimizations. The first one is:
commands/lsacpi.c: In function 'grub_cmd_lsacpi':
commands/lsacpi.c:135:3: error: cannot optimize loop, the loop counter
may overflow [-Werror=unsafe-loop-optimizations]
commands/lsacpi.c:166:3: error: cannot optimize loop, the loop counter
may overflow [-Werror=unsafe-loop-optimizations]
cc1: all warnings being treated as errors
The attached patch fixes it. The remaining ones are, afaics, either
false positives or potential overflows in loops of the form:
for (i = 1; i <= foo; i++) { ... }
where i and foo have the same type (e.g., int). I'm not sure how to
properly fix those (declare i with a wider type? replace i by i+1 in
the whole loop to make the condition become i < foo?).
Grégoire
[-- Attachment #2: check-len.diff --]
[-- Type: text/x-patch, Size: 854 bytes --]
=== modified file 'grub-core/commands/lsacpi.c'
--- grub-core/commands/lsacpi.c 2012-02-10 15:48:48 +0000
+++ grub-core/commands/lsacpi.c 2012-02-12 14:03:07 +0000
@@ -132,7 +132,7 @@ disp_acpi_xsdt_table (struct grub_acpi_t
disp_acpi_table (t);
len = t->length - sizeof (*t);
desc = (grub_uint64_t *) (t + 1);
- for (; len > 0; desc++, len -= sizeof (*desc))
+ for (; len >= sizeof (*desc); desc++, len -= sizeof (*desc))
{
#if GRUB_CPU_SIZEOF_VOID_P == 4
if (*desc >= (1ULL << 32))
@@ -163,7 +163,7 @@ disp_acpi_rsdt_table (struct grub_acpi_t
disp_acpi_table (t);
len = t->length - sizeof (*t);
desc = (grub_uint32_t *) (t + 1);
- for (; len > 0; desc++, len -= sizeof (*desc))
+ for (; len >= sizeof (*desc); desc++, len -= sizeof (*desc))
{
t = (struct grub_acpi_table_header *) (grub_addr_t) *desc;
prev parent reply other threads:[~2012-02-12 14:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 16:00 GRUB warning level increase Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-12 14:25 ` Grégoire Sutre [this message]
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=4F37CBBE.8010104@gmail.com \
--to=gregoire.sutre@gmail.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.