[U-Boot] [PATCH] board/linkstation/ide.c: Fix compile warning

Wolfgang Denk wd at denx.de
Fri Sep 11 14:00:06 CEST 2009


Dear Guennadi Liakhovetski,

In message <Pine.LNX.4.64.0909111259280.6139 at axis700.grange> you wrote:
> Hi Wolfgang
> 
> On Fri, 11 Sep 2009, Wolfgang Denk wrote:
> 
> > Fix warning: ide.c:60: warning: dereferencing type-punned pointer will
> > break strict-aliasing rules
> > 
> > Signed-off-by: Wolfgang Denk <wd at denx.de>
> > Cc: Guennadi Liakhovetski <lg at denx.de>
> > ---
> >  board/linkstation/ide.c |    4 +++-
> >  1 files changed, 3 insertions(+), 1 deletions(-)
> > 
> > diff --git a/board/linkstation/ide.c b/board/linkstation/ide.c
> > index 2c89d62..5dd1d0e 100644
> > --- a/board/linkstation/ide.c
> > +++ b/board/linkstation/ide.c
> > @@ -54,10 +54,12 @@ int ide_preinit (void)
> >  	if (devbusfn == -1)
> >  		devbusfn = pci_find_device(PCI_VENDOR_ID_ITE,PCI_DEVICE_ID_ITE_8212,0);
> >  	if (devbusfn != -1) {
> > +		ulong *ide_bus_offset_ptr = &ide_bus_offset[0];
> > +
> >  		status = 0;
> >  
> >  		pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0,
> > -							   (u32 *) &ide_bus_offset[0]);
> > +							   (u32 *)ide_bus_offset_ptr);
> 
> Can we also use this occasion to get rid of this typecast?

No, as this would result in

ide.c:62: warning: passing argument 3 of 'pci_read_config_dword' from
incompatible pointer type

OK, we can declare ide_bus_offset_ptr as u32 8, but then we need the
cast there to avoid a "initialization from incompatible pointer type"
warning - so this isn't exactly an improvement.

I suggest we leave it as is, as this is the minimal-invasive change.

If you want to submit a more general cleanup patch (unifying data
types) you are welcome (but that would be a separate action in any
case).

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
If I had to live my life again,  I'd  make  the  same  mistakes, only
sooner.                                          -- Tallulah Bankhead


More information about the U-Boot mailing list