Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YLqye-0005mk-7n for mharc-grub-devel@gnu.org; Thu, 12 Feb 2015 05:26:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLqyb-0005lp-UJ for grub-devel@gnu.org; Thu, 12 Feb 2015 05:26:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLqyY-0006GY-OZ for grub-devel@gnu.org; Thu, 12 Feb 2015 05:26:29 -0500 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:50679 helo=ip4-83-240-18-248.cust.nbox.cz) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLqyY-0006GK-Ib for grub-devel@gnu.org; Thu, 12 Feb 2015 05:26:26 -0500 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.85) (envelope-from ) id 1YLqb3-0006Rx-9e; Thu, 12 Feb 2015 11:02:09 +0100 From: Jiri Slaby To: grub-devel@gnu.org Subject: [PATCH] util: mkimage, fix gcc5 build failure Date: Thu, 12 Feb 2015 11:02:09 +0100 Message-Id: <1423735329-24760-1-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.2.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 83.240.67.251 Cc: arvidjaar@gmail.com, phcoder@gmail.com, Jiri Slaby X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2015 10:26:31 -0000 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 --- 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; -- 2.2.2