summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndreas Bießmann <andreas.devel@googlemail.com>2014-10-24 23:25:52 +0200
committerTom Rini <trini@ti.com>2015-01-11 09:05:03 -0500
commitf411b8f2270bc75113d60f2ad662f25de6242b7d (patch)
treeb514043733402d2e1201c73301aa0f22d0868284 /tools
parent41e82da12a7f5f12eeb5d598adcd73870ed72544 (diff)
tools/kwbimage.c: fix parser error handling
The two error checks for image_boot_mode_id and image_nand_ecc_mode_id where wrong and would never fail, fix that! This was detected by Apple's clang compiler: ---8<--- HOSTCC tools/kwbimage.o tools/kwbimage.c:553:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (el->bootfrom < 0) { ~~~~~~~~~~~~ ^ ~ tools/kwbimage.c:571:23: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (el->nandeccmode < 0) { ~~~~~~~~~~~~~~~ ^ ~ 2 warnings generated. --->8--- Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Acked-By: Jeroen Hofstee <jeroen@myspectrum.nl>
Diffstat (limited to 'tools')
-rw-r--r--tools/kwbimage.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 2c302e5d498..807d46668be 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -554,13 +554,14 @@ static int image_create_config_parse_oneline(char *line,
el->version = atoi(value);
} else if (!strcmp(keyword, "BOOT_FROM")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
- el->type = IMAGE_CFG_BOOT_FROM;
- el->bootfrom = image_boot_mode_id(value);
- if (el->bootfrom < 0) {
+ int ret = image_boot_mode_id(value);
+ if (ret < 0) {
fprintf(stderr,
"Invalid boot media '%s'\n", value);
return -1;
}
+ el->type = IMAGE_CFG_BOOT_FROM;
+ el->bootfrom = ret;
} else if (!strcmp(keyword, "NAND_BLKSZ")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
el->type = IMAGE_CFG_NAND_BLKSZ;
@@ -572,13 +573,14 @@ static int image_create_config_parse_oneline(char *line,
strtoul(value, NULL, 16);
} else if (!strcmp(keyword, "NAND_ECC_MODE")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
- el->type = IMAGE_CFG_NAND_ECC_MODE;
- el->nandeccmode = image_nand_ecc_mode_id(value);
- if (el->nandeccmode < 0) {
+ int ret = image_nand_ecc_mode_id(value);
+ if (ret < 0) {
fprintf(stderr,
"Invalid NAND ECC mode '%s'\n", value);
return -1;
}
+ el->type = IMAGE_CFG_NAND_ECC_MODE;
+ el->nandeccmode = ret;
} else if (!strcmp(keyword, "NAND_PAGE_SIZE")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
el->type = IMAGE_CFG_NAND_PAGESZ;