
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