From patchwork Fri Oct 24 21:25:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 403237 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BBFF614007D for ; Mon, 27 Oct 2014 02:26:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AC2BFA7915; Sun, 26 Oct 2014 16:25:24 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VaEmoxoiKc8x; Sun, 26 Oct 2014 16:25:24 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 07858A7919; Sun, 26 Oct 2014 16:23:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 629334B629 for ; Fri, 24 Oct 2014 23:35:43 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AedLpD2nxTjN for ; Fri, 24 Oct 2014 23:35:43 +0200 (CEST) X-Greylist: delayed 568 seconds by postgrey-1.32 at theia; Fri, 24 Oct 2014 23:35:40 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from cyclops.biessmann.org (cyclops.biessmann.org [134.0.25.77]) by theia.denx.de (Postfix) with ESMTP id 463064B628 for ; Fri, 24 Oct 2014 23:35:40 +0200 (CEST) Received: from localhost (er.biessmann.org [80.81.14.92]) by cyclops.biessmann.org (Postfix) with ESMTPSA id 49086B6262; Fri, 24 Oct 2014 23:26:11 +0200 (CEST) From: andreas.devel@googlemail.com To: u-boot@lists.denx.de Date: Fri, 24 Oct 2014 23:25:52 +0200 Message-Id: <1414185952-2227-1-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.9.3 (Apple Git-50) MIME-Version: 1.0 Cc: Stefan Roese , Guilherme Maciel Ferreira Subject: [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Andreas Bießmann 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 Acked-By: Jeroen Hofstee --- tools/kwbimage.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 42870ed..8fd70ef 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -548,13 +548,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; @@ -566,13 +567,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;