]> xenbits.xensource.com Git - seabios.git/commitdiff
pciinit: Fix build warning in mch_pci_slot_get_irq()
authorKevin O'Connor <kevin@koconnor.net>
Wed, 12 Nov 2014 23:00:30 +0000 (18:00 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 12 Nov 2014 23:11:57 +0000 (18:11 -0500)
Some old versions of gcc warn that 'irq might be used uninitialized'.
Replace the switch statement with an if statement to suppress the
warning.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/fw/pciinit.c

index fd5dfb9a30989678f2d83b5e477acf9fefec8543..3e6308a5ba0c7973287f445d54fb73fbcac26156 100644 (file)
@@ -115,27 +115,18 @@ static int piix_pci_slot_get_irq(struct pci_device *pci, int pin)
 
 static int mch_pci_slot_get_irq(struct pci_device *pci, int pin)
 {
-    int irq, slot, pin_addend = 0;
-
+    int pin_addend = 0;
     while (pci->parent != NULL) {
         pin_addend += pci_bdf_to_dev(pci->bdf);
         pci = pci->parent;
     }
-    slot = pci_bdf_to_dev(pci->bdf);
-
-    switch (slot) {
-    /* Slots 0-24 rotate slot:pin mapping similar to piix above, but
-       with a different starting index - see q35-acpi-dsdt.dsl */
-    case 0 ... 24:
-        irq = pci_irqs[(pin - 1 + pin_addend + slot) & 3];
-        break;
+    u8 slot = pci_bdf_to_dev(pci->bdf);
+    if (slot <= 24)
+        /* Slots 0-24 rotate slot:pin mapping similar to piix above, but
+           with a different starting index - see q35-acpi-dsdt.dsl */
+        return pci_irqs[(pin - 1 + pin_addend + slot) & 3];
     /* Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H) */
-    case 25 ... 31:
-        irq = pci_irqs[(pin - 1 + pin_addend) & 3];
-        break;
-    }
-
-    return irq;
+    return pci_irqs[(pin - 1 + pin_addend) & 3];
 }
 
 /* PIIX3/PIIX4 PCI to ISA bridge */