* [Qemu-devel] [PATCH] hw/slavio_intctl.c: fix gcc warning about array bounds overrun
@ 2011-01-31 10:42 Peter Maydell
2011-02-01 17:58 ` [Qemu-devel] " Blue Swirl
0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2011-01-31 10:42 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, patches
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>
---
I've tested that with this change we still boot the sparc
Debian image from http://people.debian.org/~aurel32/qemu/sparc/
and the change makes sense according to my understanding of
http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
hw/slavio_intctl.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c
index fd69354..a83e5b8 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]);
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [PATCH] hw/slavio_intctl.c: fix gcc warning about array bounds overrun
2011-01-31 10:42 [Qemu-devel] [PATCH] hw/slavio_intctl.c: fix gcc warning about array bounds overrun Peter Maydell
@ 2011-02-01 17:58 ` Blue Swirl
0 siblings, 0 replies; 2+ messages in thread
From: Blue Swirl @ 2011-02-01 17:58 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, patches
Thanks, applied.
On Mon, Jan 31, 2011 at 10:42 AM, Peter Maydell
<peter.maydell@linaro.org> wrote:
> 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>
> ---
> I've tested that with this change we still boot the sparc
> Debian image from http://people.debian.org/~aurel32/qemu/sparc/
> and the change makes sense according to my understanding of
> http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
>
> hw/slavio_intctl.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c
> index fd69354..a83e5b8 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]);
> --
> 1.7.1
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-01 18:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-31 10:42 [Qemu-devel] [PATCH] hw/slavio_intctl.c: fix gcc warning about array bounds overrun Peter Maydell
2011-02-01 17:58 ` [Qemu-devel] " Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).