aboutsummaryrefslogtreecommitdiff
path: root/hw/slavio_intctl.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2011-01-31 10:42:26 +0000
committerBlue Swirl <blauwirbel@gmail.com>2011-02-01 17:02:15 +0000
commitc84a88d8cb298b6757ad01a12a8bbba66cb6eaa2 (patch)
tree86a87370d9d96ddf17ce862fb3d633b018caffae /hw/slavio_intctl.c
parent60f356e86d66a4a22530ec7570f7582af602d200 (diff)
hw/slavio_intctl.c: fix gcc warning about array bounds overrun
The Ubuntu 10.10 gcc for ARM complains that we might be overrunning the cpu_irqs[][] array: silence this by correcting the bounds on the loop. (In fact we would not have overrun the array because bit MAX_PILS in pil_pending and irl_out will always be 0.) Also add a comment about why the loop's lower bound is OK. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/slavio_intctl.c')
-rw-r--r--hw/slavio_intctl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c
index fd69354bb3..a83e5b8272 100644
--- a/hw/slavio_intctl.c
+++ b/hw/slavio_intctl.c
@@ -289,7 +289,12 @@ static void slavio_check_interrupts(SLAVIO_INTCTLState *s, int set_irqs)
pil_pending |= (s->slaves[i].intreg_pending & CPU_SOFTIRQ_MASK) >> 16;
if (set_irqs) {
- for (j = MAX_PILS; j > 0; j--) {
+ /* Since there is not really an interrupt 0 (and pil_pending
+ * and irl_out bit zero are thus always zero) there is no need
+ * to do anything with cpu_irqs[i][0] and it is OK not to do
+ * the j=0 iteration of this loop.
+ */
+ for (j = MAX_PILS-1; j > 0; j--) {
if (pil_pending & (1 << j)) {
if (!(s->slaves[i].irl_out & (1 << j))) {
qemu_irq_raise(s->cpu_irqs[i][j]);