]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
common: cli_hush: avoid dead code
authorPeng Fan <Peng.Fan@freescale.com>
Tue, 24 Nov 2015 08:54:21 +0000 (16:54 +0800)
committerTom Rini <trini@konsulko.com>
Sat, 5 Dec 2015 23:22:14 +0000 (18:22 -0500)
Condition "(value == NULL && ++value == NULL)" actully will
always return false.

Instead, use condition "(value == NULL || *(value + 1) == 0)" to detect
such expression "c=". To "c=", *(value + 1) is 0, so directly return -1,
but not continue.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Cc: Rabin Vincent <rabin@rab.in>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/cli_hush.c

index a7cac4fcb9dfbb6ad568cd25f27b4be06c9477e3..f075459911e02f714d39d1f45020fabc52991962 100644 (file)
@@ -2162,7 +2162,7 @@ int set_local_var(const char *s, int flg_export)
         * NAME=VALUE format.  So the first order of business is to
         * split 's' on the '=' into 'name' and 'value' */
        value = strchr(name, '=');
-       if (value == NULL && ++value == NULL) {
+       if (value == NULL || *(value + 1) == 0) {
                free(name);
                return -1;
        }