[U-Boot] [RFC] common: cli_hush: avoid dead code

Peng Fan Peng.Fan at freescale.com
Tue Nov 24 09:54:21 CET 2015


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 at freescale.com>
Cc: Rabin Vincent <rabin at rab.in>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
---
 common/cli_hush.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/cli_hush.c b/common/cli_hush.c
index a7cac4f..f075459 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -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;
 	}
-- 
2.6.2




More information about the U-Boot mailing list