[U-Boot] [PATCH] display_buffer: fix misaligned buffer

Detlev Zundel dzu at denx.de
Mon Aug 30 12:02:28 CEST 2010


Hi Reinhard,

> Reinhard Meyer schrieb:
>>> +	uint32_t linebuf[MAX_LINE_LENGTH_BYTES/4 + 1];
>>>>  	uint32_t *uip = (void*)linebuf;
>>>>  	uint16_t *usp = (void*)linebuf;
>>>>  	uint8_t *ucp = (void*)linebuf;
>> I personally prefer this above an attribute. Its disputeable but I prefer
>> to do things with "normal C constructs" where possible.
> Reading this, after it had been sent, a perfect patch

The quest for the "perfect patch", now that's the spirit ;)  

<completely off-topic>
Very likely it will be easier than the perfect pac-man game[1] and I
hope we don't have such a split screen waiting *lol*
</cot>

> should make the buffer an union:
>
> union {
> 	uint32_t ui[MAX.../4+1];
> 	uint16_t us[MAX.../2+1];
> 	uint8_t  uc[MAX...+1];
> } linebuf;

That also sounds good indeed - it even better documents the intention of
the code so by my own arguments I'd vote for it.  I presume you will
follow up with such a patch once you tested it?

Thanks!
  Detlev

[1] http://en.wikipedia.org/wiki/Pac-Man

-- 
``The number of UNIX installations has grown to 10,
with more expected.''     Unix Programmers Manual -- 1972
The number of UNIX variants has grown to dozens,
with more expected.                               -- 2001
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de


More information about the U-Boot mailing list