From patchwork Fri Nov 29 19:29:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1202577 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47Pl3b1hSqz9sPJ for ; Sat, 30 Nov 2019 06:30:51 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CD4B2C21FEF; Fri, 29 Nov 2019 19:30:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 497AEC2209C; Fri, 29 Nov 2019 19:30:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4A08DC220FA; Fri, 29 Nov 2019 19:30:35 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id BE08DC22117 for ; Fri, 29 Nov 2019 19:30:35 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id A31D03C0579; Fri, 29 Nov 2019 20:30:35 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QRO0y4pzSijL; Fri, 29 Nov 2019 20:30:30 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id BEA323C00BE; Fri, 29 Nov 2019 20:30:30 +0100 (CET) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.468.0; Fri, 29 Nov 2019 20:30:30 +0100 From: Eugeniu Rosca To: , Tom Rini , Simon Glass , Sam Protsenko , Igor Opaniuk Date: Fri, 29 Nov 2019 20:29:17 +0100 Message-ID: <20191129192919.27715-3-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191129192919.27715-1-erosca@de.adit-jv.com> References: <20191129192919.27715-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Roman Stratiienko , Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 2/4] cmd: dtimg: Merge duplicated prints X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Getting DTB/DTBO header address happens twice (in do_dtimg_dump and in dtimg_get_fdt) with duplicating below error messages: - Error: Wrong image address - Error: DT image header is incorrect Reduce the duplication and improve the error message by appending the faulty address value: - Error: Wrong image address '0x48000000z' Signed-off-by: Eugeniu Rosca Reviewed-by: Sam Protsenko --- cmd/dtimg.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/cmd/dtimg.c b/cmd/dtimg.c index 2317c859953d..5989081b0c14 100644 --- a/cmd/dtimg.c +++ b/cmd/dtimg.c @@ -13,18 +13,13 @@ enum cmd_dtimg_info { CMD_DTIMG_SIZE, }; -static int do_dtimg_dump(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) +static int dtimg_get_argv_addr(char * const str, ulong *hdr_addrp) { char *endp; - ulong hdr_addr; + ulong hdr_addr = simple_strtoul(str, &endp, 16); - if (argc != 2) - return CMD_RET_USAGE; - - hdr_addr = simple_strtoul(argv[1], &endp, 16); if (*endp != '\0') { - printf("Error: Wrong image address\n"); + printf("Error: Wrong image address '%s'\n", str); return CMD_RET_FAILURE; } @@ -32,6 +27,21 @@ static int do_dtimg_dump(cmd_tbl_t *cmdtp, int flag, int argc, printf("Error: DT image header is incorrect\n"); return CMD_RET_FAILURE; } + *hdr_addrp = hdr_addr; + + return CMD_RET_SUCCESS; +} + +static int do_dtimg_dump(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + ulong hdr_addr; + + if (argc != 2) + return CMD_RET_USAGE; + + if (dtimg_get_argv_addr(argv[1], &hdr_addr) != CMD_RET_SUCCESS) + return CMD_RET_FAILURE; android_dt_print_contents(hdr_addr); @@ -50,16 +60,8 @@ static int dtimg_get_fdt(int argc, char * const argv[], enum cmd_dtimg_info cmd) if (argc != 4) return CMD_RET_USAGE; - hdr_addr = simple_strtoul(argv[1], &endp, 16); - if (*endp != '\0') { - printf("Error: Wrong image address\n"); + if (dtimg_get_argv_addr(argv[1], &hdr_addr) != CMD_RET_SUCCESS) return CMD_RET_FAILURE; - } - - if (!android_dt_check_header(hdr_addr)) { - printf("Error: DT image header is incorrect\n"); - return CMD_RET_FAILURE; - } index = simple_strtoul(argv[2], &endp, 0); if (*endp != '\0') {