pci: fix compilation warnings
PATCH 1/1 pci: fix compilation warnings
Fix 'error: shift exponent -1 is negative' warning by adding a corresponding assert.
--- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/pci/pci.c +4 -0
@@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)static inline int pci_irq_state (PCIDevice *d,int irq_num) { +assert (irq_num >=0 ); +return (d->irq_state >> irq_num) &0x1 ; }static inline void pci_set_irq_state (PCIDevice *d,int irq_num,int level) { +assert (irq_num >=0 ); + d->irq_state &= ~(0x1 << irq_num); d->irq_state |= level << irq_num; }
Signature · 1 line
2.4.3
Am 28.03.2016 um 09:23 schrieb Marcel Apfelbaum:
Quoted 20 lines
Fix 'error: shift exponent -1 is negative' warning by adding a corresponding assert.
Reported-by Peter Maydell <[email protected]>Signed-off-by Markus Armbruster <[email protected]>Signed-off-by Marcel Apfelbaum <[email protected]>--- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+)hw/pci/pci.c +2
-0@@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)static inline int pci_irq_state (PCIDevice *d,int irq_num) { +assert (irq_num >=0 ); +
hw/pci/pci.c int pci_bar(PCIDevice *d, int reg) · line 177
Quoted 10 lines
hw/pci/pci.c +2
-0return (d->irq_state >> irq_num) &0x1 ; }static inline void pci_set_irq_state (PCIDevice *d,int irq_num,int level) { +assert (irq_num >=0 ); + d->irq_state &= ~(0x1 << irq_num); d->irq_state |= level << irq_num; }
Do we use negative values for irq_num anywhere?
If not, using an unsigned irq_num might be a better solution.
Stefan
Quoted 24 lines · Stefan Weil
Am 28.03.2016 um 09:23 schrieb Marcel Apfelbaum:
Quoted 23 lines
Fix 'error: shift exponent -1 is negative' warning by adding a corresponding assert.
Reported-by Peter Maydell <[email protected]>Signed-off-by Markus Armbruster <[email protected]>Signed-off-by Marcel Apfelbaum <[email protected]>--- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+)hw/pci/pci.c +2
-0@@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)static inline int pci_irq_state (PCIDevice *d,int irq_num) { +assert (irq_num >=0 ); +return (d->irq_state >> irq_num) &0x1 ; }
Quoted 9 lines
hw/pci/pci.c int pci_bar(PCIDevice *d, int reg) · line 177
Quoted 7 lines
hw/pci/pci.c +2
-0static inline void pci_set_irq_state (PCIDevice *d,int irq_num,int level) { +assert (irq_num >=0 ); + d->irq_state &= ~(0x1 << irq_num); d->irq_state |= level << irq_num; }Do we use negative values for
irq_numanywhere?
Hi Stefan,
I didn't see any irq_nu assignments to a negative value but there are some cases where it can be negative due to arithmetical operations like:
hw/pci-host/bonito.c:651: int internal_irq = irq_num - BONITO_IRQ_BASE;
On other cases we look for negative value:
hw/ppc/ppc4xx_devs.c:171: if (irq_num < 0 || irq_num > 3)
or
hw/ppc/ppc4xx_pci.c:263: if (irq_num < 0)
Quoted 1 line
If not, using an unsigned
irq_nummight be a better solution.
All of the above are manageable, of course, but we are close to
hard freeze (tomorrow) and the scope of this patch is much smaller (fix a compilation warning)
I think is definitely worth looking into it, but maybe as part of QEMU 2.7.
Thanks,
Marcel
Quoted 3 lines
Stefan
Quoted 3 lines · Marcel Apfelbaum
Fix 'error: shift exponent -1 is negative' warning by adding a corresponding assert.
Ping.
Thanks,
Marcel
Quoted 28 lines
Reported-by Peter Maydell <[email protected]>Signed-off-by Markus Armbruster <[email protected]>Signed-off-by Marcel Apfelbaum <[email protected]>--- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+)hw/pci/pci.c +4
-0@@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)static inline int pci_irq_state (PCIDevice *d,int irq_num) { +assert (irq_num >=0 ); +return (d->irq_state >> irq_num) &0x1 ; }static inline void pci_set_irq_state (PCIDevice *d,int irq_num,int level) { +assert (irq_num >=0 ); + d->irq_state &= ~(0x1 << irq_num); d->irq_state |= level << irq_num; }