[U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet()
Michael Trimarchi
michael at amarulasolutions.com
Tue May 28 06:05:40 CEST 2013
Hi
On May 28, 2013 6:02 AM, "Stephen Warren" <swarren at wwwdotorg.org> wrote:
>
> Some ARM compilers may emit code that makes unaligned accesses when
> faced with constructs such as:
>
> char mac[16] = "ethaddr";
>
Recently I have seen some of this emails. I understand the problem but is
it a compiler problem? Is it reported somewhere?
Michael
> Replace this with a strcpy() call instead to avoid this. strcpy() is
> used here, rather than replacing all usage of the mac variable with the
> string itself, since the loop itself sprintf()s to the variable each
> iteration, so strcpy() is doing basically the same thing.
>
> Reported-by: Florian Meier
> Signed-off-by: Stephen Warren <swarren at wwwdotorg.org>
> ---
> common/fdt_support.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 812acb4..89e7883 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -454,7 +454,7 @@ void fdt_fixup_ethernet(void *fdt)
> {
> int node, i, j;
> char enet[16], *tmp, *end;
> - char mac[16] = "ethaddr";
> + char mac[16];
> const char *path;
> unsigned char mac_addr[6];
>
> @@ -463,6 +463,7 @@ void fdt_fixup_ethernet(void *fdt)
> return;
>
> i = 0;
> + strcpy(mac, "ethaddr");
> while ((tmp = getenv(mac)) != NULL) {
> sprintf(enet, "ethernet%d", i);
> path = fdt_getprop(fdt, node, enet, NULL);
> --
> 1.7.10.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
More information about the U-Boot
mailing list