* [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling
@ 2014-10-24 21:25 andreas.devel at googlemail.com
2014-10-27 12:06 ` Jeroen Hofstee
2015-01-11 14:05 ` [U-Boot] " Tom Rini
0 siblings, 2 replies; 5+ messages in thread
From: andreas.devel at googlemail.com @ 2014-10-24 21:25 UTC (permalink / raw)
To: u-boot
From: Andreas Bie?mann <andreas.devel@googlemail.com>
The two error checks for image_boot_mode_id and image_nand_ecc_mode_id where
wrong and would never fail, fix that!
This was detected by Apple's clang compiler:
---8<---
HOSTCC tools/kwbimage.o
tools/kwbimage.c:553:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (el->bootfrom < 0) {
~~~~~~~~~~~~ ^ ~
tools/kwbimage.c:571:23: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (el->nandeccmode < 0) {
~~~~~~~~~~~~~~~ ^ ~
2 warnings generated.
--->8---
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
tools/kwbimage.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 42870ed..8fd70ef 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -548,13 +548,14 @@ static int image_create_config_parse_oneline(char *line,
el->version = atoi(value);
} else if (!strcmp(keyword, "BOOT_FROM")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
- el->type = IMAGE_CFG_BOOT_FROM;
- el->bootfrom = image_boot_mode_id(value);
- if (el->bootfrom < 0) {
+ int ret = image_boot_mode_id(value);
+ if (ret < 0) {
fprintf(stderr,
"Invalid boot media '%s'\n", value);
return -1;
}
+ el->type = IMAGE_CFG_BOOT_FROM;
+ el->bootfrom = ret;
} else if (!strcmp(keyword, "NAND_BLKSZ")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
el->type = IMAGE_CFG_NAND_BLKSZ;
@@ -566,13 +567,14 @@ static int image_create_config_parse_oneline(char *line,
strtoul(value, NULL, 16);
} else if (!strcmp(keyword, "NAND_ECC_MODE")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
- el->type = IMAGE_CFG_NAND_ECC_MODE;
- el->nandeccmode = image_nand_ecc_mode_id(value);
- if (el->nandeccmode < 0) {
+ int ret = image_nand_ecc_mode_id(value);
+ if (ret < 0) {
fprintf(stderr,
"Invalid NAND ECC mode '%s'\n", value);
return -1;
}
+ el->type = IMAGE_CFG_NAND_ECC_MODE;
+ el->nandeccmode = ret;
} else if (!strcmp(keyword, "NAND_PAGE_SIZE")) {
char *value = strtok_r(NULL, deliminiters, &saveptr);
el->type = IMAGE_CFG_NAND_PAGESZ;
--
1.9.3 (Apple Git-50)
^ permalink raw reply related [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling
2014-10-24 21:25 [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling andreas.devel at googlemail.com
@ 2014-10-27 12:06 ` Jeroen Hofstee
2014-11-13 21:42 ` Jeroen Hofstee
2015-01-11 14:05 ` [U-Boot] " Tom Rini
1 sibling, 1 reply; 5+ messages in thread
From: Jeroen Hofstee @ 2014-10-27 12:06 UTC (permalink / raw)
To: u-boot
Hello Andreas,
On 24-10-14 23:25, andreas.devel at googlemail.com wrote:
> From: Andreas Bie?mann <andreas.devel@googlemail.com>
>
> The two error checks for image_boot_mode_id and image_nand_ecc_mode_id where
> wrong and would never fail, fix that!
>
> This was detected by Apple's clang compiler:
> ---8<---
> HOSTCC tools/kwbimage.o
> tools/kwbimage.c:553:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
> if (el->bootfrom < 0) {
> ~~~~~~~~~~~~ ^ ~
> tools/kwbimage.c:571:23: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
> if (el->nandeccmode < 0) {
> ~~~~~~~~~~~~~~~ ^ ~
> 2 warnings generated.
> --->8---
>
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> ---
>
> tools/kwbimage.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 42870ed..8fd70ef 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -548,13 +548,14 @@ static int image_create_config_parse_oneline(char *line,
> el->version = atoi(value);
> } else if (!strcmp(keyword, "BOOT_FROM")) {
> char *value = strtok_r(NULL, deliminiters, &saveptr);
> - el->type = IMAGE_CFG_BOOT_FROM;
> - el->bootfrom = image_boot_mode_id(value);
> - if (el->bootfrom < 0) {
> + int ret = image_boot_mode_id(value);
> + if (ret < 0) {
> fprintf(stderr,
> "Invalid boot media '%s'\n", value);
> return -1;
> }
> + el->type = IMAGE_CFG_BOOT_FROM;
> + el->bootfrom = ret;
> } else if (!strcmp(keyword, "NAND_BLKSZ")) {
> char *value = strtok_r(NULL, deliminiters, &saveptr);
> el->type = IMAGE_CFG_NAND_BLKSZ;
> @@ -566,13 +567,14 @@ static int image_create_config_parse_oneline(char *line,
> strtoul(value, NULL, 16);
> } else if (!strcmp(keyword, "NAND_ECC_MODE")) {
> char *value = strtok_r(NULL, deliminiters, &saveptr);
> - el->type = IMAGE_CFG_NAND_ECC_MODE;
> - el->nandeccmode = image_nand_ecc_mode_id(value);
> - if (el->nandeccmode < 0) {
> + int ret = image_nand_ecc_mode_id(value);
Thanks for fixing this. Could you move the int ret declaration before
actual code though?
Regards,
Jeroen
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling
2014-10-27 12:06 ` Jeroen Hofstee
@ 2014-11-13 21:42 ` Jeroen Hofstee
2015-01-11 13:48 ` Andreas Bießmann
0 siblings, 1 reply; 5+ messages in thread
From: Jeroen Hofstee @ 2014-11-13 21:42 UTC (permalink / raw)
To: u-boot
Hello Andreas,
On 27-10-14 13:06, Jeroen Hofstee wrote:
> Hello Andreas,
>
> On 24-10-14 23:25, andreas.devel at googlemail.com wrote:
>> From: Andreas Bie?mann <andreas.devel@googlemail.com>
>>
>> The two error checks for image_boot_mode_id and
>> image_nand_ecc_mode_id where
>> wrong and would never fail, fix that!
>>
>> This was detected by Apple's clang compiler:
>> ---8<---
>> HOSTCC tools/kwbimage.o
>> tools/kwbimage.c:553:20: warning: comparison of unsigned expression <
>> 0 is always false [-Wtautological-compare]
>> if (el->bootfrom < 0) {
>> ~~~~~~~~~~~~ ^ ~
>> tools/kwbimage.c:571:23: warning: comparison of unsigned expression <
>> 0 is always false [-Wtautological-compare]
>> if (el->nandeccmode < 0) {
>> ~~~~~~~~~~~~~~~ ^ ~
>> 2 warnings generated.
>> --->8---
>>
>> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>> ---
>>
>> tools/kwbimage.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
>> index 42870ed..8fd70ef 100644
>> --- a/tools/kwbimage.c
>> +++ b/tools/kwbimage.c
>> @@ -548,13 +548,14 @@ static int
>> image_create_config_parse_oneline(char *line,
>> el->version = atoi(value);
>> } else if (!strcmp(keyword, "BOOT_FROM")) {
>> char *value = strtok_r(NULL, deliminiters, &saveptr);
>> - el->type = IMAGE_CFG_BOOT_FROM;
>> - el->bootfrom = image_boot_mode_id(value);
>> - if (el->bootfrom < 0) {
>> + int ret = image_boot_mode_id(value);
>> + if (ret < 0) {
>> fprintf(stderr,
>> "Invalid boot media '%s'\n", value);
>> return -1;
>> }
>> + el->type = IMAGE_CFG_BOOT_FROM;
>> + el->bootfrom = ret;
>> } else if (!strcmp(keyword, "NAND_BLKSZ")) {
>> char *value = strtok_r(NULL, deliminiters, &saveptr);
>> el->type = IMAGE_CFG_NAND_BLKSZ;
>> @@ -566,13 +567,14 @@ static int
>> image_create_config_parse_oneline(char *line,
>> strtoul(value, NULL, 16);
>> } else if (!strcmp(keyword, "NAND_ECC_MODE")) {
>> char *value = strtok_r(NULL, deliminiters, &saveptr);
>> - el->type = IMAGE_CFG_NAND_ECC_MODE;
>> - el->nandeccmode = image_nand_ecc_mode_id(value);
>> - if (el->nandeccmode < 0) {
>> + int ret = image_nand_ecc_mode_id(value);
>
> Thanks for fixing this. Could you move the int ret declaration before
> actual code though?
Ah, I see now, you were not adding the declaration in the middle of
the code. There is just a newline missing after the declaration,
which make the patch look like it does. This was already the
case in the original code, so
Acked-By: Jeroen Hofstee <jeroen@myspectrum.nl>
Regards,
Jeroen
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling
2014-11-13 21:42 ` Jeroen Hofstee
@ 2015-01-11 13:48 ` Andreas Bießmann
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Bießmann @ 2015-01-11 13:48 UTC (permalink / raw)
To: u-boot
ping?
It is http://patchwork.ozlabs.org/patch/403237/
On 13.11.14 22:42, Jeroen Hofstee wrote:
> Hello Andreas,
>
> On 27-10-14 13:06, Jeroen Hofstee wrote:
>> Hello Andreas,
>>
>> On 24-10-14 23:25, andreas.devel at googlemail.com wrote:
>>> From: Andreas Bie?mann <andreas.devel@googlemail.com>
>>>
>>> The two error checks for image_boot_mode_id and
>>> image_nand_ecc_mode_id where
>>> wrong and would never fail, fix that!
>>>
>>> This was detected by Apple's clang compiler:
>>> ---8<---
>>> HOSTCC tools/kwbimage.o
>>> tools/kwbimage.c:553:20: warning: comparison of unsigned expression <
>>> 0 is always false [-Wtautological-compare]
>>> if (el->bootfrom < 0) {
>>> ~~~~~~~~~~~~ ^ ~
>>> tools/kwbimage.c:571:23: warning: comparison of unsigned expression <
>>> 0 is always false [-Wtautological-compare]
>>> if (el->nandeccmode < 0) {
>>> ~~~~~~~~~~~~~~~ ^ ~
>>> 2 warnings generated.
>>> --->8---
>>>
>>> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>>> ---
>>>
>>> tools/kwbimage.c | 14 ++++++++------
>>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
>>> index 42870ed..8fd70ef 100644
>>> --- a/tools/kwbimage.c
>>> +++ b/tools/kwbimage.c
>>> @@ -548,13 +548,14 @@ static int
>>> image_create_config_parse_oneline(char *line,
>>> el->version = atoi(value);
>>> } else if (!strcmp(keyword, "BOOT_FROM")) {
>>> char *value = strtok_r(NULL, deliminiters, &saveptr);
>>> - el->type = IMAGE_CFG_BOOT_FROM;
>>> - el->bootfrom = image_boot_mode_id(value);
>>> - if (el->bootfrom < 0) {
>>> + int ret = image_boot_mode_id(value);
>>> + if (ret < 0) {
>>> fprintf(stderr,
>>> "Invalid boot media '%s'\n", value);
>>> return -1;
>>> }
>>> + el->type = IMAGE_CFG_BOOT_FROM;
>>> + el->bootfrom = ret;
>>> } else if (!strcmp(keyword, "NAND_BLKSZ")) {
>>> char *value = strtok_r(NULL, deliminiters, &saveptr);
>>> el->type = IMAGE_CFG_NAND_BLKSZ;
>>> @@ -566,13 +567,14 @@ static int
>>> image_create_config_parse_oneline(char *line,
>>> strtoul(value, NULL, 16);
>>> } else if (!strcmp(keyword, "NAND_ECC_MODE")) {
>>> char *value = strtok_r(NULL, deliminiters, &saveptr);
>>> - el->type = IMAGE_CFG_NAND_ECC_MODE;
>>> - el->nandeccmode = image_nand_ecc_mode_id(value);
>>> - if (el->nandeccmode < 0) {
>>> + int ret = image_nand_ecc_mode_id(value);
>>
>> Thanks for fixing this. Could you move the int ret declaration before
>> actual code though?
>
> Ah, I see now, you were not adding the declaration in the middle of
> the code. There is just a newline missing after the declaration,
> which make the patch look like it does. This was already the
> case in the original code, so
>
> Acked-By: Jeroen Hofstee <jeroen@myspectrum.nl>
>
> Regards,
> Jeroen
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] tools/kwbimage.c: fix parser error handling
2014-10-24 21:25 [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling andreas.devel at googlemail.com
2014-10-27 12:06 ` Jeroen Hofstee
@ 2015-01-11 14:05 ` Tom Rini
1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2015-01-11 14:05 UTC (permalink / raw)
To: u-boot
On Fri, Oct 24, 2014 at 11:25:52PM +0200, Andreas Bie?mann wrote:
> From: Andreas Bie?mann <andreas.devel@googlemail.com>
>
> The two error checks for image_boot_mode_id and image_nand_ecc_mode_id where
> wrong and would never fail, fix that!
>
> This was detected by Apple's clang compiler:
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150111/3d865218/attachment.pgp>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-11 14:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-24 21:25 [U-Boot] [PATCH] tools/kwbimage.c: fix parser error handling andreas.devel at googlemail.com
2014-10-27 12:06 ` Jeroen Hofstee
2014-11-13 21:42 ` Jeroen Hofstee
2015-01-11 13:48 ` Andreas Bießmann
2015-01-11 14:05 ` [U-Boot] " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox