board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
PATCH 1/1 board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
--- board/esd/cpci405/cpci405.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
board/esd/cpci405/cpci405.c +3 -5
@@ -656,7 +656,6 @@ int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int i;unsigned char ow_id[6 ];char str[32 ]; -unsigned char ow_crc;/* * Clear 1-wire bit (open drain with pull-up)
@@ -675,11 +674,10 @@ int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])OWReadByte ();/* skip family code ( == 0x01) */ for (i =0 ; i <6 ; i++) ow_id[i] =OWReadByte (); - ow_crc =OWReadByte ();/* read crc */ +OWReadByte ();/* read crc */ -sprintf (str,"%08X%04X" , - *(unsigned int *)&ow_id[0 ], - *(unsigned short *)&ow_id[4 ]); +sprintf (str,"%02X%02X%02X%02X%02X%02X" , + ow_id[0 ], ow_id[1 ], ow_id[2 ], ow_id[3 ], ow_id[4 ], ow_id[5 ]);printf ("Setting environment variable 'ow_id' to %s\n" , str);setenv ("ow_id" , str);
Signature · 1 line
1.6.1
PATCH 1/1 board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
Quoted 19 lines
Signed-off-by Matthias Fuchs <[email protected]>--- board/esd/cpci405/cpci405.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)board/esd/cpci405/cpci405.c +0
-1@@ -656,7 +656,6 @@ int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int i;unsigned char ow_id[6 ];char str[32 ]; -unsigned char ow_crc;/* * Clear 1-wire bit (open drain with pull-up) @@ -675,11 +674,10 @@ int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc,char * const argv[])
OWReadByte(); /* skip family code ( ==0x01) */
board/esd/cpci405/cpci405.c int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 677
Quoted 4 lines
board/esd/cpci405/cpci405.c +1
-1for (i =0 ; i <6 ; i++) ow_id[i] =OWReadByte (); - ow_crc =OWReadByte ();/* read crc */ +OWReadByte ();/* read crc */
Are you sure this doesn't get optimized out? Did you test this patch please?
board/esd/cpci405/cpci405.c int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 682
Quoted 8 lines
board/esd/cpci405/cpci405.c +2
-3-sprintf (str,"%08X%04X" , - *(unsigned int *)&ow_id[0 ], - *(unsigned short *)&ow_id[4 ]); +sprintf (str,"%02X%02X%02X%02X%02X%02X" , + ow_id[0 ], ow_id[1 ], ow_id[2 ], ow_id[3 ], ow_id[4 ], ow_id[5 ]);printf ("Setting environment variable 'ow_id' to %s\n" , str);setenv ("ow_id" , str);
This does indeed look eerie, the old code.
Ok, good, I'll assign this gcc4.6 thing to myself and start picking these.
PATCH 1/1 board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
In reply to Matthias Fuchsboard/esd/cpci405/cpci405.c int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 680
Quoted 5 lines · On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
board/esd/cpci405/cpci405.c +2
-3-sprintf (str,"%08X%04X" , - *(unsigned int *)&ow_id[0 ], - *(unsigned short *)&ow_id[4 ]); +sprintf (str,"%02X%02X%02X%02X%02X%02X" , + ow_id[0 ], ow_id[1 ], ow_id[2 ], ow_id[3 ], ow_id[4 ], ow_id[5 ]);
use __get_unaligned_le32 and __get_unaligned_le16 helpers to avoid having to decode each byte.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111124/3a66dd7e/attachment.pgp>
PATCH 1/1 board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
Quoted 10 lines · On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
board/esd/cpci405/cpci405.c int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 680
Quoted 5 lines
board/esd/cpci405/cpci405.c +2
-3-sprintf (str,"%08X%04X" , - *(unsigned int *)&ow_id[0 ], - *(unsigned short *)&ow_id[4 ]); +sprintf (str,"%02X%02X%02X%02X%02X%02X" , + ow_id[0 ], ow_id[1 ], ow_id[2 ], ow_id[3 ], ow_id[4 ], ow_id[5 ]);use
__get_unaligned_le32and__get_unaligned_le16helpers to avoid having to decode each byte.
-mike
Is there any overhead introduced ?
M
PATCH 1/1 board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
Quoted 11 lines · On Friday 25 November 2011 03:33:39 Marek Vasut wrote:
Quoted 9 lines · On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
board/esd/cpci405/cpci405.c int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 680
Quoted 5 lines
board/esd/cpci405/cpci405.c +2
-3-sprintf (str,"%08X%04X" , - *(unsigned int *)&ow_id[0 ], - *(unsigned short *)&ow_id[4 ]); +sprintf (str,"%02X%02X%02X%02X%02X%02X" , + ow_id[0 ], ow_id[1 ], ow_id[2 ], ow_id[3 ], ow_id[4 ], ow_id[5 ]);use
__get_unaligned_le32and__get_unaligned_le16helpers to avoid having to decode each byte.Is there any overhead introduced ?
i imagine get_unaligned will be as worse as indexing every byte (which is what Matthias is proposing we change to), or as good as the current code (just casting the data). depends on the arch.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111125/ff236d18/attachment.pgp>
PATCH 1/1 board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
In reply to Mike FrysingerQuoted 9 lines · Mike Frysinger
board/esd/cpci405/cpci405.c int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 680
Quoted 5 lines · On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
board/esd/cpci405/cpci405.c +2
-3-sprintf (str,"%08X%04X" , - *(unsigned int *)&ow_id[0 ], - *(unsigned short *)&ow_id[4 ]); +sprintf (str,"%02X%02X%02X%02X%02X%02X" , + ow_id[0 ], ow_id[1 ], ow_id[2 ], ow_id[3 ], ow_id[4 ], ow_id[5 ]);use
__get_unaligned_le32and__get_unaligned_le16helpers to avoid having to decode each byte.
I must admit that I like the new style much more. But thanks for the hint on the __get-unaligned macros :-)
Matthias
Wolfgang Denk
AppliedPATCH 1/1 board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
In reply to Matthias FuchsDear Matthias Fuchs,
Quoted 4 lines · In message <[email protected]> you wrote:
Signed-off-by Matthias Fuchs <[email protected]>--- board/esd/cpci405/cpci405.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
Applied, thanks.
Stefan, hope this is OK with you, but I want to get rid of these warnings.
Best regards,
Wolfgang Denk
Signature · 7 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 You said you didn't want to use CGI.pm, but methinks you are needlessly reinventing the wheel, one spoke at a time. Either you are masochistic, or you just haven't seen enough of what CGI.pm can do for you. -- Randal L. Schwartz in <[email protected]>