[U-Boot] [PATCH 05/22] board/linkstation/ide.c: Fix GCC 4.6 build warnings
Guennadi Liakhovetski
g.liakhovetski at gmx.de
Sun Nov 6 18:46:11 CET 2011
Hi Wolfgang
On Sat, 5 Nov 2011, Wolfgang Denk wrote:
> Fix:
> ide.c: In function 'ide_preinit':
> ide.c:69:21: warning: array subscript is above array bounds
> [-Warray-bounds]
> ide.c:69:21: warning: array subscript is above array bounds
> [-Warray-bounds]
> ide.c:70:17: warning: array subscript is above array bounds
> [-Warray-bounds]
>
> Signed-off-by: Wolfgang Denk <wd at denx.de>
> Cc: Guennadi Liakhovetski <g.liakhovetski at gmx.de>
> ---
> board/linkstation/ide.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/board/linkstation/ide.c b/board/linkstation/ide.c
> index 568fdf5..14e3fd0 100644
> --- a/board/linkstation/ide.c
> +++ b/board/linkstation/ide.c
> @@ -64,12 +64,14 @@ int ide_preinit (void)
> ide_bus_offset[0] = pci_hose_bus_to_phys(&hose,
> ide_bus_offset[0] & 0xfffffffe,
> PCI_REGION_IO);
> +#if CONFIG_SYS_IDE_MAXBUS > 1
I don't have gcc 4.6 installed here unfortunately, but wondering, wouldn't
this
if (CONFIG_SYS_IDE_MAXBUS > 1) {
ide_bus_offset[1]...
}
also make the compiler happy? Maybe not, because, probably, the above "if"
would be optimised away after indicies are verifies. But if it does fix
the problem too - it would be preferable IMHO. Of course, one could also
use a perversion like
if (CONFIG_SYS_IDE_MAXBUS > 1) {
ide_bus_offset[CONFIG_SYS_IDE_MAXBUS > 1]...
}
But that'd be even uglier, than the preprocessor "#if":)
Thanks
Guennadi
> pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_2,
> (u32 *) &ide_bus_offset[1]);
> ide_bus_offset[1] &= 0xfffffffe;
> ide_bus_offset[1] = pci_hose_bus_to_phys(&hose,
> ide_bus_offset[1] & 0xfffffffe,
> PCI_REGION_IO);
> +#endif
> }
>
> if (pci_find_device (PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8212, 0) != -1) {
> --
> 1.7.6.4
>
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
More information about the U-Boot
mailing list