[U-Boot] [PATCH] fat: fix unaligned errors

Wolfgang Denk wd at denx.de
Fri Jan 2 23:20:47 CET 2009


Dear Mike Frysinger,

In message <1230857672-11798-1-git-send-email-vapier at gentoo.org> you wrote:
> From: Bryan Wu <bryan.wu at analog.com>
> 
> A couple of buffers in the fat code are declared as an array of bytes.  But
> it is then cast up to a structure with 16bit and 32bit members.  Since GCC
> assumes structure alignment here, we have to force the buffers to be
> aligned according to the structure usage.
...
> +__u8 get_vfatname_block[MAX_CLUSTSIZE] __attribute__ ((aligned(sizeof(__u16))));
...
> +__u8 get_dentfromdir_block[MAX_CLUSTSIZE] __attribute__ ((aligned(sizeof(__u32))));
...
> +__u8 do_fat_read_block[MAX_CLUSTSIZE] __attribute__ ((aligned(sizeof(__u32))));

What makes you sure that a 16 resp. 32 bit alignment is sufficient,
and that gcc does not decide to align such structures even stricter?

Wouldn't it make more sense to use "__alignof__ ()" here to be on the
safe side?

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
One friend in a lifetime is much; two  are  many;  three  are  hardly
possible. Friendship needs a certain parallelism of life, a community
of thought, a rivalry of aim.                     - Henry Brook Adams


More information about the U-Boot mailing list