util: mkimage, fix gcc5 build failure
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>
This commit is contained in:
parent
c0f529ea67
commit
32cd33bd19
1 changed files with 2 additions and 2 deletions
|
@ -937,8 +937,8 @@ grub_install_get_image_target (const char *arg)
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
||||||
for (j = 0; image_targets[i].names[j]
|
for (j = 0; j < ARRAY_SIZE (image_targets[i].names) &&
|
||||||
&& j < ARRAY_SIZE (image_targets[i].names); j++)
|
image_targets[i].names[j]; j++)
|
||||||
if (strcmp (arg, image_targets[i].names[j]) == 0)
|
if (strcmp (arg, image_targets[i].names[j]) == 0)
|
||||||
return &image_targets[i];
|
return &image_targets[i];
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue