[U-Boot] [PATCH] mkimage: SEGFAULT with imximage on 64 bit systems

Stefano Babic sbabic at denx.de
Fri Jan 29 17:57:28 CET 2010


Mike Frysinger wrote:
> man this is terrible terrible code.  using 64bit casts may fix 64bit systems, 
> but doesnt seem right on 32bit systems as you'd introduce more pointer/size 
> mismatches.

You are right - it works on 32 bit systems for the only reason that I
compute a fix offset inside a structure, as you pointed out later.

> if the only thing you want is imx_hdr->ext_header, why not do it that way:
> 	ext_header = &imx_hdr->ext_header

I can't, this is wrong. The ext_header is not fixed, but depends on the
size of the DCD table, that is variable. This table is set via a
configuration file and is specific for each board.
The ext_header pointer must be set at the next 32bit location after this
table.

> then again, this looks like you're doing constant subtraction.  the distance 
> between two struct members is always going to be the same, so why dont you use 
> offsetof() to avoid the random pointer ugliness.

Sometimes I miss the easiest solution. Thanks to point this out !

Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================


More information about the U-Boot mailing list