cmd_bdinfo: Fix printf() format warning
PATCH 1/1 cmd_bdinfo: Fix printf() format warning
Fix the following warning on avr32 and, from the looks of it, all other architectures except arm, blackfin and mips.
cmd_bdinfo.c: In function 'do_bdinfo':
cmd_bdinfo.c:367: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
In order to not introduce new warnings on the aforementioned three architectures as well as i386, I added a cast to unsigned long. This should be safe even if bi_baudrate is declared as 'int' (assuming there's no such thing as negative baud rates.)
--- common/cmd_bdinfo.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
common/cmd_bdinfo.c +1 -1
@@ -364,7 +364,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }puts ("\nip_addr = " );print_IPaddr (bd->bi_ip_addr); -printf ("\nbaudrate = %d bps\n" , bd->bi_baudrate); +printf ("\nbaudrate = %lu bps\n" , (unsigned long )bd->bi_baudrate);return 0 ; }
Signature · 1 line
1.5.6.2
PATCH 1/1 cmd_bdinfo: Fix printf() format warning
Quoted 11 lines · In message <[email protected]>…
Fix the following warning on avr32 and, from the looks of it, all other architectures except arm, blackfin and mips.
cmd_bdinfo.c: In function 'do_bdinfo':
cmd_bdinfo.c:367: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'In order to not introduce new warnings on the aforementioned three architectures as well as i386, I added a cast to unsigned long. This should be safe even if
bi_baudrateis declared as 'int' (assuming there's no such thing as negative baud rates.)
Instead of the cast, should we not rather fix ARM, BF and MIPS to use ulong like anybody else?
Best regards,
Wolfgang Denk
Signature · 6 lines
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 We Klingons believe as you do -- the sick should die. Only the strong should live. -- Kras, "Friday's Child", stardate 3497.2
PATCH 1/1 cmd_bdinfo: Fix printf() format warning
Quoted 7 lines · Wolfgang Denk
Quoted 4 lines
In order to not introduce new warnings on the aforementioned three architectures as well as i386, I added a cast to unsigned long. This should be safe even if
bi_baudrateis declared as 'int' (assuming there's no such thing as negative baud rates.)Instead of the cast, should we not rather fix ARM, BF and MIPS to use ulong like anybody else?
Yeah, that's probably better. But I don't know what sort of side effects that kind of change might cause. There could be code somewhere that needs bi_baudrate to be signed for some obscure reason.
But if you're ok with it and people are willing to test, I can certainly make that change.
Haavard
PATCH 1/1 cmd_bdinfo: Fix printf() format warning
Quoted 4 lines · In message <[email protected]> you wrote:
Yeah, that's probably better. But I don't know what sort of side effects that kind of change might cause. There could be code somewhere that needs
bi_baudrateto be signed for some obscure reason.
I am positively sure that no uch code exists (and it there were any such code it was worth of breaking it, really hard :-).
Quoted 2 lines
But if you're ok with it and people are willing to test, I can certainly make that change.
Please do.
Best regards,
Wolfgang Denk
Signature · 5 lines
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 It seems intuitively obvious to me, which means that it might be wrong. -- Chris Torek
PATCH v2 1/1 cmd_bdinfo: Fix printf() format warning
Fix the following warning on avr32 and, from the looks of it, all other architectures except arm, blackfin and mips.
cmd_bdinfo.c: In function 'do_bdinfo':
cmd_bdinfo.c:367: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
In order to not introduce new warnings on the aforementioned three architectures as well as i386, I changed the type of the bi_baudrate field to be unsigned long so that all architectures are consisten. This may break some really questionable code (highly unlikely) and/or introduce new format warnings elsewhere (somewhat more likely), but if so, it needs fixing anyway.
---
Cc'ed the maintainers of the affected architectures except i386.
Does anyone know who's in charge of the i386 port? The chances of breakage on i386 is lower than on the other three architectures since the field is unsigned to begin with, and is wedged between two other unsigned longs, so it shouldn't cause any changes to the struct layout even on x86_64.
common/cmd_bdinfo.c | 2 +- include/asm-arm/u-boot.h | 2 +- include/asm-blackfin/u-boot.h | 2 +- include/asm-i386/u-boot.h | 2 +- include/asm-mips/u-boot.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
common/cmd_bdinfo.c +1 -1
@@ -364,7 +364,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }puts ("\nip_addr = " );print_IPaddr (bd->bi_ip_addr); -printf ("\nbaudrate = %d bps\n" , bd->bi_baudrate); +printf ("\nbaudrate = %lu bps\n" , bd->bi_baudrate);return 0 ; }
include/asm-arm/u-boot.h +1 -1
@@ -37,7 +37,7 @@#define _U_BOOT_H_ 1 typedef struct bd_info { - int bi_baudrate; /* serial console baudrate */ + unsigned long bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ unsigned char bi_enetaddr[6]; /* Ethernet adress */ struct environment_s *bi_env;
include/asm-blackfin/u-boot.h +1 -1
@@ -29,7 +29,7 @@#define _U_BOOT_H_ 1 typedef struct bd_info { - int bi_baudrate; /* serial console baudrate */ + unsigned long bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ unsigned char bi_enetaddr[6]; /* Ethernet adress */ unsigned long bi_boot_params; /* where this board expects params */
include/asm-i386/u-boot.h +1 -1
@@ -50,7 +50,7 @@ typedef struct bd_info {unsigned short bi_ethspeed;/* Ethernet speed in Mbps */ unsigned long bi_intfreq;/* Internal Freq, in MHz */ unsigned long bi_busfreq;/* Bus Freq, in MHz */ -unsigned int bi_baudrate;/* Console Baudrate */ +unsigned long bi_baudrate;/* Console Baudrate */ unsigned long bi_boot_params;/* where this board expects params */ struct environment_s *bi_env; struct /* RAM configuration */
include/asm-mips/u-boot.h +1 -1
@@ -32,7 +32,7 @@#define _U_BOOT_H_ 1 typedef struct bd_info { - int bi_baudrate; /* serial console baudrate */ + unsigned long bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ unsigned char bi_enetaddr[6]; /* Ethernet adress */ unsigned long bi_arch_number; /* unique id for this board */
Signature · 1 line
1.5.6.3
PATCH v2 1/1 cmd_bdinfo: Fix printf() format warning
Quoted 6 lines · Haavard Skinnemoen
Fix the following warning on avr32 and, from the looks of it, all other architectures except arm, blackfin and mips.
cmd_bdinfo.c: In function 'do_bdinfo':
cmd_bdinfo.c:367: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
Ah, bugger. I completely misparsed that file -- do_bdinfo is supposed to be arch-specific, but avr32 uses the same implementation as MIPS for some arbitrary reason. So this patch just makes things worse.
Please ignore. I'll fix it some other way.
Btw, how about moving this stuff into an arch-specific file? lib_<arch>/bdinfo.c for example?
Haavard