public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] tools/kwbimage: Fix compilation warning
Date: Mon, 27 Oct 2014 13:57:43 +0100	[thread overview]
Message-ID: <20141027125743.122C9380909@gemini.denx.de> (raw)
In-Reply-To: <1414412953-25615-1-git-send-email-sr@denx.de>

Dear Stefan,

In message <1414412953-25615-1-git-send-email-sr@denx.de> you wrote:
> This patch fixes a compilation warning of kwbimage.c:
> 
> tools/kwbimage.c: In function ?kwbimage_set_header?:
> tools/kwbimage.c:784:8: warning: ?headersz? may be used uninitialized in this function [-Wmaybe-uninitialized]
>   memcpy(ptr, image, headersz);
>         ^
> Instead of using multiple if statements, use a switch statement with
> a default entry. And return with error if the VERSION field is
> missing in the cfg file.

Thanks, but...

> +	switch (version) {
> +		/*
> +		 * Fallback to version 0 is no version is provided in the
> +		 * cfg file
> +		 */
> +	case -1:
> +	case 0:
>  		image = image_create_v0(&headersz, params, sbuf->st_size);
> +		break;
> +
> +	case 1:
>  		image = image_create_v1(&headersz, params, sbuf->st_size);
> +		break;
> +
> +	default:
> +		fprintf(stderr, "File %s does not have the VERSION field\n",
> +			params->imagename);
> +		free(image_cfg);
> +		exit(EXIT_FAILURE);
> +	}

What exactly is the difference between return code -1 (no version is
provided and you fall back to using version 0), and the default case?

To me these look the same?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Wenn Du ein' weise Antwort verlangst, Mu?t Du vern?nftig fragen.
                                                -- Goethe, Invektiven

  reply	other threads:[~2014-10-27 12:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27 12:29 [U-Boot] [PATCH] tools/kwbimage: Fix compilation warning Stefan Roese
2014-10-27 12:57 ` Wolfgang Denk [this message]
2014-10-27 13:09   ` Stefan Roese
2014-10-27 13:34     ` Wolfgang Denk
2014-10-27 16:47       ` Stefan Roese

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=20141027125743.122C9380909@gemini.denx.de \
    --to=wd@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox