diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-12-13 13:00:43 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-12-17 19:33:51 +0100 |
commit | 3c29e188415e81c32a9107ecb2616fc6b967abc5 (patch) | |
tree | fc0d143e9be3818af11c4d8a37cedce4c5c7637a /hw/isa | |
parent | 14a1bb48ea48d541ea6f373c12fb7e88d2c89d8f (diff) |
hw/isa/isa-bus: cleanup irq functions
The irq number is unsigned; we reject negative values. But -1
is used for the isairq array, which is declared unsigned! And
since we have a definition for the number of ISA IRQs, use it.
Based on a patch by Philippe Mathieu-Daudé.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/isa')
-rw-r--r-- | hw/isa/isa-bus.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 388800603b..798dd9194e 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -82,24 +82,27 @@ void isa_bus_irqs(ISABus *bus, qemu_irq *irqs) * This function is only for special cases such as the 'ferr', and * temporary use for normal devices until they are converted to qdev. */ -qemu_irq isa_get_irq(ISADevice *dev, int isairq) +qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq) { assert(!dev || ISA_BUS(qdev_get_parent_bus(DEVICE(dev))) == isabus); - if (isairq < 0 || isairq > 15) { + if (isairq >= ISA_NUM_IRQS) { hw_error("isa irq %d invalid", isairq); } return isabus->irqs[isairq]; } -void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq) +void isa_init_irq(ISADevice *dev, qemu_irq *p, unsigned isairq) { assert(dev->nirqs < ARRAY_SIZE(dev->isairq)); + if (isairq >= ISA_NUM_IRQS) { + hw_error("isa irq %d invalid", isairq); + } dev->isairq[dev->nirqs] = isairq; *p = isa_get_irq(dev, isairq); dev->nirqs++; } -void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, int isairq) +void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq) { qemu_irq irq; isa_init_irq(isadev, &irq, isairq); |