NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/49181: i386 Kernel compilation error (warning -> error) if no PCIBIOSVERBOSE



The following reply was made to PR kern/49181; it has been noted by GNATS.

From: Alan Barrett <apb%cequrux.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/49181: i386 Kernel compilation error (warning -> error) if
 no PCIBIOSVERBOSE
Date: Mon, 8 Sep 2014 15:06:05 +0200

 On Sun, 07 Sep 2014, kre%munnari.OZ.AU@localhost wrote:
 >      If PCIBIOSVERBOSE is not set in the kernel config, then ...
 >
 >.../src/sys/arch/i386/pci/pci_intr_fixup.c: In function 
 >'pciintr_do_header_fixup':
 >.../src/sys/arch/i386/pci/pci_intr_fixup.c:669:17: error: variable 'id'
 >set but not used [-Werror=unused-but-set-variable]
 >
 >+#else
 >+     if (id == (pcireg_t)7)
 >+             printf("Lucky 7!\n");
 > #endif
 
 Let's not do that!
 
 I offer one of the following two patches, depending on whether or not
 it's acceptable to suppress or move the pci_conf_read call.
 
 Patch 1: Mark the variable __unused in the ! PCIBIOSVERBOSE case,
 and retain the pci_conf_read call in exactly the same place.
 
 Index: sys/arch/i386/pci/pci_intr_fixup.c
 --- sys/arch/i386/pci/pci_intr_fixup.c 1 Jul 2011 17:37:26 -0000       1.49
 +++ sys/arch/i386/pci/pci_intr_fixup.c 8 Sep 2014 12:55:23 -0000
 @@ -666,7 +666,12 @@ pciintr_do_header_fixup(pci_chipset_tag_
        struct pciintr_link_map *l;
        int pin, irq, link;
        int bus, device, function;
 -      pcireg_t intr, id;
 +      pcireg_t intr;
 +#ifdef PCIBIOSVERBOSE
 +      pcireg_t id;
 +#else
 +      pcireg_t id __unused;
 +#endif
  
        pci_decompose_tag(pc, tag, &bus, &device, &function);
        id = pci_conf_read(pc, tag, PCI_ID_REG);
 
 Patch 2: Move the variable declaration and initialisation into
 a block that's evaluated only when pcibiosverbose is true.  The
 pci_conf_read may not be performed at all, or may be performed out of
 order relative to what the current code does.
 
 Index: sys/arch/i386/pci/pci_intr_fixup.c
 --- sys/arch/i386/pci/pci_intr_fixup.c 1 Jul 2011 17:37:26 -0000       1.49
 +++ sys/arch/i386/pci/pci_intr_fixup.c 8 Sep 2014 12:56:58 -0000
 @@ -666,10 +666,9 @@ pciintr_do_header_fixup(pci_chipset_tag_
        struct pciintr_link_map *l;
        int pin, irq, link;
        int bus, device, function;
 -      pcireg_t intr, id;
 +      pcireg_t intr;
  
        pci_decompose_tag(pc, tag, &bus, &device, &function);
 -      id = pci_conf_read(pc, tag, PCI_ID_REG);
  
        intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
        pin = PCI_INTERRUPT_PIN(intr);
 @@ -710,6 +709,8 @@ pciintr_do_header_fixup(pci_chipset_tag_
  
  #ifdef PCIBIOSVERBOSE
        if (pcibiosverbose) {
 +              pcireg_t id = pci_conf_read(pc, tag, PCI_ID_REG);
 +
                PCIBIOS_PRINTV(("%03d:%02d:%d 0x%04x 0x%04x   %c  0x%02x",
                    bus, device, function, PCI_VENDOR(id), PCI_PRODUCT(id),
                    '@' + pin, l->clink));
 
 --apb (Alan Barrett)
 


Home | Main Index | Thread Index | Old Index