* [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
@ 2011-11-24 15:39 Matthias Fuchs
2011-11-24 17:05 ` Marek Vasut
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Matthias Fuchs @ 2011-11-24 15:39 UTC (permalink / raw)
To: u-boot
Signed-off-by: Matthias Fuchs <matthias.fuchs@esd.eu>
---
board/esd/cpci405/cpci405.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/board/esd/cpci405/cpci405.c b/board/esd/cpci405/cpci405.c
index 98a8584..41b5ba0 100644
--- a/board/esd/cpci405/cpci405.c
+++ b/board/esd/cpci405/cpci405.c
@@ -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);
--
1.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
2011-11-24 15:39 [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning Matthias Fuchs
@ 2011-11-24 17:05 ` Marek Vasut
2011-11-24 17:40 ` Mike Frysinger
2011-12-07 20:22 ` Wolfgang Denk
2 siblings, 0 replies; 7+ messages in thread
From: Marek Vasut @ 2011-11-24 17:05 UTC (permalink / raw)
To: u-boot
> Signed-off-by: Matthias Fuchs <matthias.fuchs@esd.eu>
> ---
> board/esd/cpci405/cpci405.c | 8 +++-----
> 1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/board/esd/cpci405/cpci405.c b/board/esd/cpci405/cpci405.c
> index 98a8584..41b5ba0 100644
> --- a/board/esd/cpci405/cpci405.c
> +++ b/board/esd/cpci405/cpci405.c
> @@ -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 */
Are you sure this doesn't get optimized out? Did you test this patch please?
>
> - 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
2011-11-24 15:39 [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning Matthias Fuchs
2011-11-24 17:05 ` Marek Vasut
@ 2011-11-24 17:40 ` Mike Frysinger
2011-11-25 8:33 ` Marek Vasut
2011-11-25 12:50 ` Matthias Fuchs
2011-12-07 20:22 ` Wolfgang Denk
2 siblings, 2 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-11-24 17:40 UTC (permalink / raw)
To: u-boot
On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
> - 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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
2011-11-24 17:40 ` Mike Frysinger
@ 2011-11-25 8:33 ` Marek Vasut
2011-11-25 19:56 ` Mike Frysinger
2011-11-25 12:50 ` Matthias Fuchs
1 sibling, 1 reply; 7+ messages in thread
From: Marek Vasut @ 2011-11-25 8:33 UTC (permalink / raw)
To: u-boot
> On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
> > - 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
Is there any overhead introduced ?
M
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
2011-11-24 17:40 ` Mike Frysinger
2011-11-25 8:33 ` Marek Vasut
@ 2011-11-25 12:50 ` Matthias Fuchs
1 sibling, 0 replies; 7+ messages in thread
From: Matthias Fuchs @ 2011-11-25 12:50 UTC (permalink / raw)
To: u-boot
On 11/24/2011 06:40 PM, Mike Frysinger wrote:
> On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
>> - 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.
I must admit that I like the new style much more. But thanks for the hint on the
__get-unaligned macros :-)
Matthias
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
2011-11-25 8:33 ` Marek Vasut
@ 2011-11-25 19:56 ` Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-11-25 19:56 UTC (permalink / raw)
To: u-boot
On Friday 25 November 2011 03:33:39 Marek Vasut wrote:
> > On Thursday 24 November 2011 10:39:21 Matthias Fuchs wrote:
> > > - 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.
>
> 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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning
2011-11-24 15:39 [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning Matthias Fuchs
2011-11-24 17:05 ` Marek Vasut
2011-11-24 17:40 ` Mike Frysinger
@ 2011-12-07 20:22 ` Wolfgang Denk
2 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2011-12-07 20:22 UTC (permalink / raw)
To: u-boot
Dear Matthias Fuchs,
In message <4ECE6529.8050307@esd.eu> you wrote:
> Signed-off-by: Matthias Fuchs <matthias.fuchs@esd.eu>
> ---
> 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
--
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 <8cyb81rg81.fsf@gadget.cscaper.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-12-07 20:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24 15:39 [U-Boot] [PATCH] board/esd/cpci405/cpci405.c: Fix GCC 4.6 warning Matthias Fuchs
2011-11-24 17:05 ` Marek Vasut
2011-11-24 17:40 ` Mike Frysinger
2011-11-25 8:33 ` Marek Vasut
2011-11-25 19:56 ` Mike Frysinger
2011-11-25 12:50 ` Matthias Fuchs
2011-12-07 20:22 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox