From patchwork Fri Jul 12 11:20:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1131298 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 (mailfrom) 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 45lVr74yRFz9sDQ for ; Fri, 12 Jul 2019 21:21:59 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4E158C21DCA; Fri, 12 Jul 2019 11:21:37 +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 C3608C21DDC; Fri, 12 Jul 2019 11:21:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D07C1C21E07; Fri, 12 Jul 2019 11:21:27 +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 1D27FC21DCA for ; Fri, 12 Jul 2019 11:21:24 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id F3DC83C04C1; Fri, 12 Jul 2019 13:21:23 +0200 (CEST) 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 NXv_XrFNu2ad; Fri, 12 Jul 2019 13:21:18 +0200 (CEST) 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 0EF2A3C00BA; Fri, 12 Jul 2019 13:21:18 +0200 (CEST) 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.439.0; Fri, 12 Jul 2019 13:21:17 +0200 From: Eugeniu Rosca To: , Sam Protsenko , Simon Glass , Igor Opaniuk , Tom Rini Date: Fri, 12 Jul 2019 13:20:55 +0200 Message-ID: <20190712112059.25558-2-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712112059.25558-1-erosca@de.adit-jv.com> References: <20190712112059.25558-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 1/5] doc: Move README.android-fastboot-protocol to doc/android/ 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" Commit 9bdf0e8fef86 ("doc: relocate/rename Android README and add BCB overview") missed relocating README.android-fastboot-protocol. Fix it. Fixes: 9bdf0e8fef86 ("doc: relocate/rename Android README and add BCB overview") Signed-off-by: Eugeniu Rosca Reviewed-by: Igor Opaniuk Reviewed-by: Sam Protsenko --- .../fastboot-protocol.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/{README.android-fastboot-protocol => android/fastboot-protocol.txt} (100%) diff --git a/doc/README.android-fastboot-protocol b/doc/android/fastboot-protocol.txt similarity index 100% rename from doc/README.android-fastboot-protocol rename to doc/android/fastboot-protocol.txt From patchwork Fri Jul 12 11:20:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1131305 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 (mailfrom) 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 45lVsS6XLtz9sBt for ; Fri, 12 Jul 2019 21:23:08 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4305CC21DFD; Fri, 12 Jul 2019 11:22:06 +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 020E4C21DF3; Fri, 12 Jul 2019 11:22:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 64D6DC21BE5; Fri, 12 Jul 2019 11:21:32 +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 2BC87C21DA6 for ; Fri, 12 Jul 2019 11:21:29 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 0780E3C04C1; Fri, 12 Jul 2019 13:21:29 +0200 (CEST) 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 jRm1qe61rNJJ; Fri, 12 Jul 2019 13:21:22 +0200 (CEST) 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 6CACA3C001F; Fri, 12 Jul 2019 13:21:22 +0200 (CEST) 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.439.0; Fri, 12 Jul 2019 13:21:21 +0200 From: Eugeniu Rosca To: , Sam Protsenko , Simon Glass , Igor Opaniuk , Tom Rini Date: Fri, 12 Jul 2019 13:20:56 +0200 Message-ID: <20190712112059.25558-3-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712112059.25558-1-erosca@de.adit-jv.com> References: <20190712112059.25558-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 2/5] treewide: Fix stale references of Android docs 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" Commit 9bdf0e8fef86 ("doc: relocate/rename Android README and add BCB overview") left some obsolete references of Android documents/paths. This has been pointed out by Sam (thanks!) in: https://patchwork.ozlabs.org/patch/1104245/#2208134 Fixes: 9bdf0e8fef86 ("doc: relocate/rename Android README and add BCB overview") Reported-by: Sam Protsenko Suggested-by: Sam Protsenko Signed-off-by: Eugeniu Rosca Reviewed-by: Igor Opaniuk Reviewed-by: Sam Protsenko --- cmd/Kconfig | 2 +- doc/android/fastboot.txt | 2 +- test/py/tests/test_avb.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 3afb760a816f..3cf8233df62e 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -707,7 +707,7 @@ config CMD_FASTBOOT Android devices. Fastboot requires either the network stack enabled or support for acting as a USB device. - See doc/README.android-fastboot for more information. + See doc/android/fastboot.txt for more information. config CMD_FDC bool "fdcboot - Boot from floppy device" diff --git a/doc/android/fastboot.txt b/doc/android/fastboot.txt index 431191c473f2..dcf824713f94 100644 --- a/doc/android/fastboot.txt +++ b/doc/android/fastboot.txt @@ -6,7 +6,7 @@ Overview ======== The protocol that is used over USB and UDP is described in the -``README.android-fastboot-protocol`` file in the same directory. +``fastboot-protocol.txt`` file in the same directory. The current implementation supports the following standard commands: diff --git a/test/py/tests/test_avb.py b/test/py/tests/test_avb.py index 2bb75ed6e2a2..813242343555 100644 --- a/test/py/tests/test_avb.py +++ b/test/py/tests/test_avb.py @@ -8,7 +8,7 @@ This tests Android Verified Boot 2.0 support in U-boot: For additional details about how to build proper vbmeta partition -check doc/README.avb2 +check doc/android/avb2.txt For configuration verification: - Corrupt boot partition and check for failure From patchwork Fri Jul 12 11:20:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1131301 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 (mailfrom) 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 45lVrV42dmz9sBt for ; Fri, 12 Jul 2019 21:22:18 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1CE58C21CB6; Fri, 12 Jul 2019 11:21:52 +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 548CEC21DFB; Fri, 12 Jul 2019 11:21:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 68EC4C21D72; Fri, 12 Jul 2019 11:21: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 60030C21DB3 for ; Fri, 12 Jul 2019 11:21:33 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 4440D3C04C1; Fri, 12 Jul 2019 13:21:33 +0200 (CEST) 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 WXUVUOr4EUrV; Fri, 12 Jul 2019 13:21:26 +0200 (CEST) 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 CA71B3C00BA; Fri, 12 Jul 2019 13:21:26 +0200 (CEST) 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.439.0; Fri, 12 Jul 2019 13:21:26 +0200 From: Eugeniu Rosca To: , Sam Protsenko , Simon Glass , Igor Opaniuk , Tom Rini Date: Fri, 12 Jul 2019 13:20:57 +0200 Message-ID: <20190712112059.25558-4-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712112059.25558-1-erosca@de.adit-jv.com> References: <20190712112059.25558-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 3/5] cmd: bcb: Fix duplicated handling in two case-branches 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" Fix warning V1037 reported by PVS-Studio Static Analyzer: Two or more case-branches perform the same actions. Check lines: 49, 53 Fixes: db7b7a05b267 ("cmd: Add 'bcb' command to read/modify/write BCB fields") Signed-off-by: Eugeniu Rosca Reviewed-by: Igor Opaniuk --- cmd/bcb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index 2bd5a744deb5..3b1c7434e287 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -46,9 +46,6 @@ static int bcb_is_misused(int argc, char *const argv[]) switch (cmd) { case BCB_CMD_LOAD: - if (argc != 3) - goto err; - break; case BCB_CMD_FIELD_SET: if (argc != 3) goto err; From patchwork Fri Jul 12 11:20:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1131306 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 (mailfrom) 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 45lVsT4TSmz9sDB for ; Fri, 12 Jul 2019 21:23:09 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5B502C21C6A; Fri, 12 Jul 2019 11:22:38 +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 C1794C21DA6; Fri, 12 Jul 2019 11:22:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4244AC21D9A; Fri, 12 Jul 2019 11:21:41 +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 BA5E3C21DAF for ; Fri, 12 Jul 2019 11:21:37 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 9F17F3C00BA; Fri, 12 Jul 2019 13:21:37 +0200 (CEST) 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 JxeP9gSBqcX2; Fri, 12 Jul 2019 13:21:31 +0200 (CEST) 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 842623C001F; Fri, 12 Jul 2019 13:21:31 +0200 (CEST) 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.439.0; Fri, 12 Jul 2019 13:21:30 +0200 From: Eugeniu Rosca To: , Sam Protsenko , Simon Glass , Igor Opaniuk , Tom Rini Date: Fri, 12 Jul 2019 13:20:58 +0200 Message-ID: <20190712112059.25558-5-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712112059.25558-1-erosca@de.adit-jv.com> References: <20190712112059.25558-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 4/5] cmd: bcb: Use strcmp() instead of strncmp() for string literals 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" Quote from https://patchwork.ozlabs.org/patch/1104244/#2210814: ----------8<----------- strncmp() is chosen for the sake of paranoid/defensive programming. Indeed, strncmp() is not really needed when comparing a variable with a string literal. We expect strcmp() to behave safely even if the string variable is not NUL-terminated. In the same scenario, Linux v5.2-rc7 uses both strcmp() and strncmp(), but the frequency of strcmp() is higher: $ git --version git version 2.22.0 $ (Linux 5.2-rc7) git grep -En 'strncmp\([^"]*"[[:alnum:]]+"' | wc -l 1066 $ (Linux 5.2-rc7) git grep -En 'strcmp\([^"]*"[[:alnum:]]+"' | wc -l 1968 A quick "strcmp vs strncmp" object size test shows that strcmp() generates smaller memory footprint (gcc-8, x86_64): $ (U-Boot) size cmd/bcb-strncmp.o cmd/bcb-strcmp.o text data bss dec hex filename 3373 400 2048 5821 16bd cmd/bcb-strncmp.o 3314 400 2048 5762 1682 cmd/bcb-strcmp.o So, overall, I agree to use strcmp() whenever variables are compared with string literals. ----------8<----------- Fixes: db7b7a05b267 ("cmd: Add 'bcb' command to read/modify/write BCB fields") Reported-by: Simon Glass Signed-off-by: Eugeniu Rosca Reviewed-by: Igor Opaniuk --- cmd/bcb.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index 3b1c7434e287..c7138a5179a9 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -24,17 +24,17 @@ static struct bootloader_message bcb = { { 0 } }; static int bcb_cmd_get(char *cmd) { - if (!strncmp(cmd, "load", sizeof("load"))) + if (!strcmp(cmd, "load")) return BCB_CMD_LOAD; - if (!strncmp(cmd, "set", sizeof("set"))) + if (!strcmp(cmd, "set")) return BCB_CMD_FIELD_SET; - if (!strncmp(cmd, "clear", sizeof("clear"))) + if (!strcmp(cmd, "clear")) return BCB_CMD_FIELD_CLEAR; - if (!strncmp(cmd, "test", sizeof("test"))) + if (!strcmp(cmd, "test")) return BCB_CMD_FIELD_TEST; - if (!strncmp(cmd, "store", sizeof("store"))) + if (!strcmp(cmd, "store")) return BCB_CMD_STORE; - if (!strncmp(cmd, "dump", sizeof("dump"))) + if (!strcmp(cmd, "dump")) return BCB_CMD_FIELD_DUMP; else return -1; @@ -85,21 +85,21 @@ err: static int bcb_field_get(char *name, char **field, int *size) { - if (!strncmp(name, "command", sizeof("command"))) { - *field = bcb.command; - *size = sizeof(bcb.command); - } else if (!strncmp(name, "status", sizeof("status"))) { - *field = bcb.status; - *size = sizeof(bcb.status); - } else if (!strncmp(name, "recovery", sizeof("recovery"))) { - *field = bcb.recovery; - *size = sizeof(bcb.recovery); - } else if (!strncmp(name, "stage", sizeof("stage"))) { - *field = bcb.stage; - *size = sizeof(bcb.stage); - } else if (!strncmp(name, "reserved", sizeof("reserved"))) { - *field = bcb.reserved; - *size = sizeof(bcb.reserved); + if (!strcmp(name, "command")) { + *fieldp = bcb.command; + *sizep = sizeof(bcb.command); + } else if (!strcmp(name, "status")) { + *fieldp = bcb.status; + *sizep = sizeof(bcb.status); + } else if (!strcmp(name, "recovery")) { + *fieldp = bcb.recovery; + *sizep = sizeof(bcb.recovery); + } else if (!strcmp(name, "stage")) { + *fieldp = bcb.stage; + *sizep = sizeof(bcb.stage); + } else if (!strcmp(name, "reserved")) { + *fieldp = bcb.reserved; + *sizep = sizeof(bcb.reserved); } else { printf("Error: Unknown bcb field '%s'\n", name); return -1; From patchwork Fri Jul 12 11:25:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1131321 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 (mailfrom) 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 45lVxl3VSYz9sBF for ; Fri, 12 Jul 2019 21:26:51 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3A4B4C21E12; Fri, 12 Jul 2019 11:26:16 +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 EED59C21CB1; Fri, 12 Jul 2019 11:26:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 061AEC21C6A; Fri, 12 Jul 2019 11:26:04 +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 38806C21DA1 for ; Fri, 12 Jul 2019 11:26:01 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 151AA3C00BA; Fri, 12 Jul 2019 13:26:01 +0200 (CEST) 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 PAlCZG053vyS; Fri, 12 Jul 2019 13:25:54 +0200 (CEST) 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 98A8D3C001F; Fri, 12 Jul 2019 13:25:54 +0200 (CEST) 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.439.0; Fri, 12 Jul 2019 13:25:53 +0200 From: Eugeniu Rosca To: , Sam Protsenko , Simon Glass , Igor Opaniuk , Tom Rini Date: Fri, 12 Jul 2019 13:25:34 +0200 Message-ID: <20190712112534.25684-1-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712112059.25558-1-erosca@de.adit-jv.com> References: <20190712112059.25558-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 5/5] cmd: bcb: Apply non-functional refinements 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" These have been reported by Simon in [1] and fixed in [2]. However, since [1] has already been pushed to u-boot/master, the improvements incorporated in [2] are now extracted and resubmitted. [1] https://patchwork.ozlabs.org/patch/1104244/#2200259 [2] https://patchwork.ozlabs.org/cover/1128661/ ("[v4,0/4] Add 'bcb' command to read/modify/write Android BCB") Fixes: db7b7a05b267 ("cmd: Add 'bcb' command to read/modify/write BCB fields") Reported-by: Simon Glass Signed-off-by: Eugeniu Rosca Reviewed-by: Igor Opaniuk --- cmd/bcb.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index c7138a5179a9..9626f2c69e34 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -83,7 +83,7 @@ err: return -1; } -static int bcb_field_get(char *name, char **field, int *size) +static int bcb_field_get(char *name, char **fieldp, int *sizep) { if (!strcmp(name, "command")) { *fieldp = bcb.command; @@ -108,8 +108,8 @@ static int bcb_field_get(char *name, char **field, int *size) return 0; } -static int -do_bcb_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_bcb_load(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) { struct blk_desc *desc; disk_partition_t info; @@ -119,28 +119,28 @@ do_bcb_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ret = blk_get_device_by_str("mmc", argv[1], &desc); if (ret < 0) - goto err_1; + goto err_read_fail; part = simple_strtoul(argv[2], &endp, 0); if (*endp == '\0') { ret = part_get_info(desc, part, &info); if (ret) - goto err_1; + goto err_read_fail; } else { part = part_get_info_by_name(desc, argv[2], &info); if (part < 0) { ret = part; - goto err_1; + goto err_read_fail; } } cnt = DIV_ROUND_UP(sizeof(struct bootloader_message), info.blksz); if (cnt > info.size) - goto err_2; + goto err_too_small; if (blk_dread(desc, info.start, cnt, &bcb) != cnt) { ret = -EIO; - goto err_1; + goto err_read_fail; } bcb_dev = desc->devnum; @@ -148,10 +148,10 @@ do_bcb_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) debug("%s: Loaded from mmc %d:%d\n", __func__, bcb_dev, bcb_part); return CMD_RET_SUCCESS; -err_1: +err_read_fail: printf("Error: mmc %s:%s read failed (%d)\n", argv[1], argv[2], ret); goto err; -err_2: +err_too_small: printf("Error: mmc %s:%s too small!", argv[1], argv[2]); goto err; err: @@ -304,7 +304,8 @@ static int do_bcb(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_USAGE; if (bcb_is_misused(argc, argv)) { - /* We try to improve the user experience by reporting the + /* + * We try to improve the user experience by reporting the * root-cause of misusage, so don't return CMD_RET_USAGE, * since the latter prints out the full-blown help text */