From mboxrd@z Thu Jan 1 00:00:00 1970 From: emilio@elopez.com.ar (=?windows-1252?Q?Emilio_L=F3pez?=) Date: Sat, 27 Apr 2013 20:54:35 -0300 Subject: Array subscript above array bounds warning In-Reply-To: <517C5F56.7040106@prisktech.co.nz> References: <517C5F56.7040106@prisktech.co.nz> Message-ID: <517C653B.7050908@elopez.com.ar> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org El 27/04/13 20:29, Tony Prisk escribi?: > Could someone clarify for me what I am missing here? > > > in drivers/net/ethernet/via/velocity.h is the following definition: > > struct mac_regs { > volatile u8 PAR[6]; /* 0x00 */ > ... > } > > I am trying to add the following function but it keeps giving array > bounds warnings: > > static void velocity_set_power_state(struct velocity_info *vptr, char > state) > { > struct mac_regs __iomem *regs = vptr->mac_regs; > > if (vptr->bustype == BUS_PCI) { > pci_set_power_state(vptr->pdev, state); > } else { > writeb(state, (®s->PAR[0]) + 0x154); This would be equivalent to writeb(state, regs->PAR + 0x154); or writeb(state, ®s->PAR[340]); Which would be out of bounds, right? As it's an u8 array with just 6 elements, not 341+