grub2/0282-util-mkimage-fix-gcc5-build-failure.patch
Peter Jones 8c6b1ac71e Reconcile with upstream once again.
Also include some minor fixes for gcc 5.1.1

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-07-22 09:46:32 -04:00

42 lines
1.4 KiB
Diff

From 32cd33bd19348afb77ab849846e0b6d6157ea308 Mon Sep 17 00:00:00 2001
From: Jiri Slaby <jslaby@suse.cz>
Date: Thu, 12 Feb 2015 11:02:09 +0100
Subject: [PATCH 282/506] 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>
---
util/mkimage.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/mkimage.c b/util/mkimage.c
index bccd703..7821dc5 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;
--
2.4.3