Skip to contentSkip to conversation

image: Fix loop condition to avoid warning

PATCH In review Thierry Reding 3 participants 4 messages Aug 20, 2015 – Aug 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image: Fix loop condition to avoid warning

From: Thierry Reding <[email protected]>

GCC 5.1 starts warning for comparisons such as !a > 0, assuming that the negation was meant to apply to the whole expression rather than just the left operand.

Indeed the comparison in the FIT loadable code is confusingly written, though it does end up doing the right thing. Rewrite the condition to be more explicit, that is, iterate over strings until they're exhausted.

---
 common/image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +2 -2
index 998a4b6fcdfb..5e6f4af5d9cf 100644
@@ -1228,10 +1228,10 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
 		conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
 
 		for (loadables_index = 0;
-		     !fdt_get_string_index(buf, conf_noffset,
+		     fdt_get_string_index(buf, conf_noffset,
 				FIT_LOADABLE_PROP,
 				loadables_index,
-				(const char **)&uname) > 0;
+				(const char **)&uname) == 0;
 		     loadables_index++)
 		{
 			fit_img_result = fit_image_load(images,
Signature · 1 line
2.4.5
#1 lore raw

PATCH 1/1 image: Fix loop condition to avoid warning

Quoted 11 lines · Thierry Reding

From: Thierry Reding <[email protected]>

GCC 5.1 starts warning for comparisons such as !a > 0, assuming that the negation was meant to apply to the whole expression rather than just the left operand.

Indeed the comparison in the FIT loadable code is confusingly written, though it does end up doing the right thing. Rewrite the condition to be more explicit, that is, iterate over strings until they're exhausted.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150820/f99dec79/attachment.sig>
#2 lore raw

PATCH 1/1 image: Fix loop condition to avoid warning

In reply to Thierry Reding
Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

GCC 5.1 starts warning for comparisons such as !a > 0, assuming that the negation was meant to apply to the whole expression rather than just the left operand.

Quoted 8 lines

Indeed the comparison in the FIT loadable code is confusingly written, though it does end up doing the right thing. Rewrite the condition to be more explicit, that is, iterate over strings until they're exhausted.

---
 common/image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#3 lore raw
In reply to Thierry Reding
Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

GCC 5.1 starts warning for comparisons such as !a > 0, assuming that the negation was meant to apply to the whole expression rather than just the left operand.

Quoted 7 lines

Indeed the comparison in the FIT loadable code is confusingly written, though it does end up doing the right thing. Rewrite the condition to be more explicit, that is, iterate over strings until they're exhausted.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150828/0caa3039/attachment.sig>