From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 2 Apr 2008 16:50:12 +0200 Subject: [U-Boot-Users] [PATCH] cmd_nand: Fix warning: dereferencing type-punned pointer will break strict-aliasing rules In-Reply-To: <20080402143919.B479F2476E@gemini.denx.de> References: <1207136270-19315-1-git-send-email-plagnioj@jcrosoft.com> <20080402143919.B479F2476E@gemini.denx.de> Message-ID: <20080402145012.GA18098@game.jcrosoft.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 16:39 Wed 02 Apr , Wolfgang Denk wrote: > In message <1207136270-19315-1-git-send-email-plagnioj@jcrosoft.com> you wrote: > > cmd_nand.c:353: warning: dereferencing type-punned pointer will break strict-aliasing rules > > cmd_nand.c:356: warning: dereferencing type-punned pointer will break strict-aliasing rules > > > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD > > > > diff --git a/common/cmd_nand.c b/common/cmd_nand.c > > index 7b1f830..2906aed 100644 > > --- a/common/cmd_nand.c > > +++ b/common/cmd_nand.c > > @@ -84,7 +84,7 @@ static int nand_dump(nand_info_t *nand, ulong off) > > > > /* ------------------------------------------------------------------------- */ > > > > -static inline int str2long(char *p, ulong *num) > > +static inline int str2long(char *p, loff_t *num) > > I think this is plain wrong. It may silence the warning, but it is > wrong. > > The type is the result of calling simple_strtoul(), and this function > returns, um, and unsigned long. And not an offset type. I agree > > > -arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size) > > +arg_off_size(int argc, char *argv[], nand_info_t *nand, loff_t *off, size_t *size) > > No. That's all wrong. I disagree, the true type of the offest is loff_t and size is size_t in the linux/mtd. Maybe we need to do the cast to ulong in this function. Best Regards, J.