All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] common: cli_hush: avoid dead code
Date: Tue, 24 Nov 2015 12:04:54 -0700	[thread overview]
Message-ID: <CAPnjgZ0CDP+-wtu+xFarN3OvXRMnmg2aKoJ6G2k9zJQ7_XfusA@mail.gmail.com> (raw)
In-Reply-To: <1448355263-545-2-git-send-email-Peng.Fan@freescale.com>

On 24 November 2015 at 01:54, Peng Fan <Peng.Fan@freescale.com> wrote:
> 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>
> ---
>  common/cli_hush.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

> 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) {

I suggest:

if (!value || !value[1])

but please feel free to ignore this. What you have will work.

>                 free(name);
>                 return -1;
>         }
> --
> 2.6.2
>
>

  reply	other threads:[~2015-11-24 19:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24  8:54 [U-Boot] [PATCH] common: bootm: check return value of strict_strtoul Peng Fan
2015-11-24  8:54 ` [U-Boot] [RFC] common: cli_hush: avoid dead code Peng Fan
2015-11-24 19:04   ` Simon Glass [this message]
2015-12-06 22:06   ` [U-Boot] [U-Boot,RFC] " Tom Rini
2015-11-24  8:54 ` [U-Boot] [PATCH] common: image-fdt: correct fdt_blob for IMAGE_FORMAT_LEGACY Peng Fan
2015-11-24 19:04   ` Simon Glass
2015-11-25  1:12     ` Peng Fan
2015-12-01 20:01       ` Simon Glass
2015-12-06 22:06   ` [U-Boot] " Tom Rini
2015-11-24  8:54 ` [U-Boot] [PATCH] video: ipu: simplify if else code Peng Fan
2015-11-24  9:55   ` Stefano Babic
2015-11-24 19:04 ` [U-Boot] [PATCH] common: bootm: check return value of strict_strtoul Simon Glass
2015-12-06 22:05 ` [U-Boot] " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPnjgZ0CDP+-wtu+xFarN3OvXRMnmg2aKoJ6G2k9zJQ7_XfusA@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.