[U-Boot] [PATCH] Disaligned buffer in print_buffer

Reinhard Meyer u-boot at emk-elektronik.de
Fri Aug 27 11:41:08 CEST 2010


Stefano Babic schrieb:
> As linebuf is accessed with 32-bit pointers, its address
> must be 32 bit aligned to avoid misaligned access.
> 
> Signed-off-by: Stefano Babic <sbabic at denx.de>
> ---
>  lib/display_options.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/display_options.c b/lib/display_options.c
> index 20319e6..30374f9 100644
> --- a/lib/display_options.c
> +++ b/lib/display_options.c
> @@ -101,7 +101,7 @@ void print_size(unsigned long long size, const char *s)
>  #define DEFAULT_LINE_LENGTH_BYTES (16)
>  int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
>  {
> -	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
> +	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1] __attribute__((__aligned__(4)));
>  	uint32_t *uip = (void*)linebuf;
>  	uint16_t *usp = (void*)linebuf;
>  	uint8_t *ucp = (void*)linebuf;

Why not just declare it as
	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];
?

Best Regards,
Reinhard



More information about the U-Boot mailing list