[U-Boot] [PATCH] tools/kwbimage: Fix compilation warning

Wolfgang Denk wd at denx.de
Mon Oct 27 13:57:43 CET 2014


Dear Stefan,

In message <1414412953-25615-1-git-send-email-sr at 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


More information about the U-Boot mailing list