From 0b8bc21a123d73a3c4b72d5e876588892492a035 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Mon, 7 Dec 2015 18:01:54 +0100 Subject: [PATCH] mkimage: Fix warning from fix for generating multi and script images again Seems 6ae6e160 broke creating images in certain cases, there are two problems with that patch. First is that the expression "!x == 4 || !x == 6" is ambiguous. The intention here was "!(x == 4) || !(x == 6)" based on reading further in the file, where this was borrowed from. This however is interpreted by gcc as "(!x) == 4 || (!x) == 6" and always false. gcc-5.x will warn about this case. The second problem is that we do not want to test for the case of "(NOT x is 4) OR (NOT x is 6)" but instead "(x is not equal to 4) AND (x is not equal to 6)". This is because in those two cases we already execute the code question in another part of the file. Rewrite the expression and add parenthesis for clarity. Signed-off-by: Marek Vasut Cc: Tom Rini Cc: Philippe De Swert Cc: Simon Glass [trini: Re-word Marek's explanation] Gbp-Pq: Topic upstream/mkimage-fix-multi-script Gbp-Pq: Name 0002-mkimage-Fix-warning-from-fix-for-generating-multi-an.patch --- tools/mkimage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/mkimage.c b/tools/mkimage.c index ae01cb1e8..8f8b6df37 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -311,8 +311,7 @@ NXTARG: ; exit (retval); } - if (!params.type == IH_TYPE_MULTI || - !params.type == IH_TYPE_SCRIPT) { + if ((params.type != IH_TYPE_MULTI) && (params.type != IH_TYPE_SCRIPT)) { dfd = open(params.datafile, O_RDONLY | O_BINARY); if (dfd < 0) { fprintf(stderr, "%s: Can't open %s: %s\n", -- 2.30.2