* [U-Boot] [PATCH v2] tools/kwbimage: Fix compilation warning
@ 2014-10-28 10:32 Stefan Roese
2014-10-28 10:38 ` Wolfgang Denk
2014-10-30 22:16 ` Anatolij Gustschin
0 siblings, 2 replies; 4+ messages in thread
From: Stefan Roese @ 2014-10-28 10:32 UTC (permalink / raw)
To: u-boot
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>
---
v2:
- Change error message so that it really makes sense (unsupported
version instead of no version)
- Change this also in the commit text
- Small change (s/is/if)
tools/kwbimage.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 1120e9b..0179c74 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -752,14 +752,25 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd,
}
version = image_get_version();
- /* Fallback to version 0 is no version is provided in the cfg file */
- if (version == -1)
- version = 0;
-
- if (version == 0)
+ switch (version) {
+ /*
+ * Fallback to version 0 if no version is provided in the
+ * cfg file
+ */
+ case -1:
+ case 0:
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);
+ break;
+
+ default:
+ fprintf(stderr, "Unsupported version %d\n", version);
+ free(image_cfg);
+ exit(EXIT_FAILURE);
+ }
if (!image) {
fprintf(stderr, "Could not create image\n");
--
2.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] tools/kwbimage: Fix compilation warning
2014-10-28 10:32 [U-Boot] [PATCH v2] tools/kwbimage: Fix compilation warning Stefan Roese
@ 2014-10-28 10:38 ` Wolfgang Denk
2014-11-13 22:51 ` York Sun
2014-10-30 22:16 ` Anatolij Gustschin
1 sibling, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2014-10-28 10:38 UTC (permalink / raw)
To: u-boot
Dear Stefan Roese,
In message <1414492344-19055-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 an unsupported version
> is configured in the cfg file.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> v2:
> - Change error message so that it really makes sense (unsupported
> version instead of no version)
> - Change this also in the commit text
> - Small change (s/is/if)
Acked-By: Wolfgang Denk <wd@denx.de>
Thanks!
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
Es ist offensichtlich, dass das menschliche Gehirn wie ein Computer
funktioniert. Da es keine dummen Computer gibt, gibt es also auch
keine dummen Menschen. Nur ein paar Leute, die unter DOS laufen.
-- <unbekannt>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] tools/kwbimage: Fix compilation warning
2014-10-28 10:32 [U-Boot] [PATCH v2] tools/kwbimage: Fix compilation warning Stefan Roese
2014-10-28 10:38 ` Wolfgang Denk
@ 2014-10-30 22:16 ` Anatolij Gustschin
1 sibling, 0 replies; 4+ messages in thread
From: Anatolij Gustschin @ 2014-10-30 22:16 UTC (permalink / raw)
To: u-boot
On Tue, 28 Oct 2014 11:32:24 +0100
Stefan Roese <sr@denx.de> 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 an unsupported version
> is configured in the cfg file.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> v2:
> - Change error message so that it really makes sense (unsupported
> version instead of no version)
> - Change this also in the commit text
> - Small change (s/is/if)
>
> tools/kwbimage.c | 23 +++++++++++++++++------
> 1 file changed, 17 insertions(+), 6 deletions(-)
Applied to u-boot-staging. Thanks!
Anatolij
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] tools/kwbimage: Fix compilation warning
2014-10-28 10:38 ` Wolfgang Denk
@ 2014-11-13 22:51 ` York Sun
0 siblings, 0 replies; 4+ messages in thread
From: York Sun @ 2014-11-13 22:51 UTC (permalink / raw)
To: u-boot
On 10/28/2014 03:38 AM, Wolfgang Denk wrote:
> Dear Stefan Roese,
>
> In message <1414492344-19055-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 an unsupported version
>> is configured in the cfg file.
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> ---
>> v2:
>> - Change error message so that it really makes sense (unsupported
>> version instead of no version)
>> - Change this also in the commit text
>> - Small change (s/is/if)
>
> Acked-By: Wolfgang Denk <wd@denx.de>
>
I failed to see how the warning message got fixed. I still see this warning when
compiling.
York
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-13 22:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-28 10:32 [U-Boot] [PATCH v2] tools/kwbimage: Fix compilation warning Stefan Roese
2014-10-28 10:38 ` Wolfgang Denk
2014-11-13 22:51 ` York Sun
2014-10-30 22:16 ` Anatolij Gustschin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox