From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Fri, 29 Jan 2010 17:57:28 +0100 Subject: [U-Boot] [PATCH] mkimage: SEGFAULT with imximage on 64 bit systems In-Reply-To: <201001291104.59853.vapier@gentoo.org> References: <1264760533-17490-1-git-send-email-sbabic@denx.de> <201001291104.59853.vapier@gentoo.org> Message-ID: <4B631378.8070804@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 =====================================================================