mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-25 13:14:19 +08:00
tools/kwbimage: Fix compilation warning
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 an unsupported version is configured in the cfg file. Signed-off-by: Stefan Roese <sr@denx.de> Acked-By: Wolfgang Denk <wd@denx.de>
This commit is contained in:
parent
e5f1a586a7
commit
934a529f94
@ -760,14 +760,25 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
version = image_get_version();
|
version = image_get_version();
|
||||||
/* Fallback to version 0 is no version is provided in the cfg file */
|
switch (version) {
|
||||||
if (version == -1)
|
/*
|
||||||
version = 0;
|
* Fallback to version 0 if no version is provided in the
|
||||||
|
* cfg file
|
||||||
if (version == 0)
|
*/
|
||||||
|
case -1:
|
||||||
|
case 0:
|
||||||
image = image_create_v0(&headersz, params, sbuf->st_size);
|
image = image_create_v0(&headersz, params, sbuf->st_size);
|
||||||
else if (version == 1)
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
image = image_create_v1(&headersz, params, sbuf->st_size);
|
image = image_create_v1(&headersz, params, sbuf->st_size);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unsupported version %d\n", version);
|
||||||
|
free(image_cfg);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
fprintf(stderr, "Could not create image\n");
|
fprintf(stderr, "Could not create image\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user