All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: grub-devel@gnu.org, phcoder@gmail.com
Subject: Re: [PATCH] util: mkimage, fix gcc5 build failure
Date: Thu, 12 Feb 2015 22:22:00 +0300	[thread overview]
Message-ID: <20150212222200.5d24d1b5@opensuse.site> (raw)
In-Reply-To: <1423735329-24760-1-git-send-email-jslaby@suse.cz>


pushed

В Thu, 12 Feb 2015 11:02:09 +0100
Jiri Slaby <jslaby@suse.cz> пишет:

> gcc5 reports:
> ../util/mkimage.c: In function 'grub_install_get_image_target':
> ../util/mkimage.c:954:5: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations]
>      && j < ARRAY_SIZE (image_targets[i].names); j++)
>      ^
> ../util/mkimage.c:953:39: note: possible undefined statement is here
>       for (j = 0; image_targets[i].names[j]
>                                         ^
> 
> Well, let's move the index 'j' test before accesing the array to:
> 1) make the loop obvious
> 2) make gcc happy
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
>  util/mkimage.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/util/mkimage.c b/util/mkimage.c
> index bccd70388afa..7821dc5eaf11 100644
> --- a/util/mkimage.c
> +++ b/util/mkimage.c
> @@ -937,8 +937,8 @@ grub_install_get_image_target (const char *arg)
>  {
>    unsigned i, j;
>    for (i = 0; i < ARRAY_SIZE (image_targets); i++)
> -    for (j = 0; image_targets[i].names[j]
> -	   && j < ARRAY_SIZE (image_targets[i].names); j++)
> +    for (j = 0; j < ARRAY_SIZE (image_targets[i].names) &&
> +		    image_targets[i].names[j]; j++)
>        if (strcmp (arg, image_targets[i].names[j]) == 0)
>  	return &image_targets[i];
>    return NULL;



      reply	other threads:[~2015-02-12 19:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12 10:02 [PATCH] util: mkimage, fix gcc5 build failure Jiri Slaby
2015-02-12 19:22 ` Andrei Borzenkov [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=20150212222200.5d24d1b5@opensuse.site \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=jslaby@suse.cz \
    --cc=phcoder@gmail.com \
    /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.