>Number: 48757
>Category: kern
>Synopsis: sys/arch/i386/pci/pci_intr_fixup.c var set but not used (+FIX?)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Apr 19 17:35:00 +0000 2014
>Originator: Robert Elz
>Release: NetBSD 6.99.40 (ie: -current ; as of 2014-04-18)
>Organization:
Prince of Songkla University
>Environment:
System: NetBSD perseus.noi.kre.to 6.99.17 NetBSD 6.99.17 (GENERIC) #1: Fri Feb
22 22:09:50 ICT 2013
kre%jade.coe.psu.ac.th@localhost:/usr/obj/current/i386/sys/arch/i386/compile/GENERIC
i386
Architecture: i386
Machine: i386
>Description:
When compiled with just the right combination of options, an i386
kernel compile fails as ...
/usr/obj/current/tools/bin/i486--netbsdelf-gcc -msoft-float -mno-mmx -mno-sse
-mno-avx -ffreestanding -fno-zero-initialized-in-bss -O2 -fstack-protector
-Wstack-protector --param ssp-buffer-size=1 -fno-strict-aliasing -fno-common
-std=gnu99 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Wswitch
-Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-pointer-sign
-Wno-attributes -Wextra -Wno-unused-parameter -Wold-style-definition
-Wno-sign-compare --sysroot=/release/current/i386 -Di386 -I.
-I/release/current/src/sys/../common/include -I/release/current/src/sys/arch
-I/release/current/src/sys -nostdinc -DI686_CPU -DMATH_EMULATE -DUCONSOLE
-DSYSTRACE -DLKM -DCOMPAT_30_PTHREAD -DSOFTDEP -DIPSEC_ESP -DPFIL_HOOKS
-DWSDISPLAY_CHARFUNCS -DMAXUSERS=32 -D_KERNEL -D_KERNEL_OPT -std=gnu99
-I/release/current/src/sys/lib/libkern/../../../common/lib/libc/quad
-I/release/current/src/sys/lib/libkern/..!
/../../common/lib/libc/string
-I/release/current/src/sys/lib/libkern/../../../common/lib/libc/arch/i386/string
-D_FORTIFY_SOURCE=2 -I/release/current/src/sys/external/bsd/ipf
-I/release/current/src/sys/external/bsd/acpica/dist/include -c
/release/current/src/sys/arch/i386/pci/pci_intr_fixup.c
/release/current/src/sys/arch/i386/pci/pci_intr_fixup.c: In function
'pciintr_do_header_fixup':
/release/current/src/sys/arch/i386/pci/pci_intr_fixup.c:669:17: error: variable
'id' set but not used [-Werror=unused-but-set-variable]
pcireg_t intr, id;
^
cc1: all warnings being treated as errors
*** Failed target: pci_intr_fixup.o
>How-To-Repeat:
Not sure what option combination gets us to this point (other than
that clearly PCIBIOSVERBOSE is not set) - in addition to the
standard set of kernels, I compile about 10 more for various
current, and past, local systems every time I do a build. Exactly
one of them failed this way, all the rest built successfully.
I guess if it were important, I could work out what the option
set is that causes this - and I can easily send anyone who asks the
kernel config file - but as the problem is obvious, and I think,
easy to fix, I am not sure it matters.
But with the right kernel config file, just build an i386 kernel..
(Or, once you are aimed at it [below] just read the source.)
Also, note that the source file in question has not been touched in
years, so this "error" has clearly been caused (or made visible) by a
compiler, or build options, change - and one that happened fairly
recently - a 6.99.37 build I did about 4 weeks ago (my last
successful i386 build - for other reasons, now all corrected)
did not have a problem with the file in question neither the kernel
config file, nor the src file, have been changed in the interim).
>Fix:
Appying the patch below allows the kernel to build successfully
(and doesn't break any of my other 386 kernel builds). However I can't
test that this kernel still works - the system it was for has been
gone for many years now (the kernel is still being built because
that's just computer time - working out which ones I no longer need
takes (would take) my time...)
That caveat is relevant, as the fix deletes a call to pci_conf_read().
The error comes because the result of that func call is
(when PCIBIOSVERBOSE is not set) assigned to a variable that is
never touched again ("id") - but I do not personally have enough
knowledge of the NetBSD PCI config code to be sure that omiting that
func call won't cause some other problem (non-obvious side effects
perhaps - nb: this is not a claim that there is an issue, just ...).
So, someone who does understand this stuff should give this a
look over before comitting it.
Also note, the variable "function" assigned in the call to
pci_decompose_tag() is also never used again with PCIBIOSDEBUG
undefined - the (current) compiler isn't picking up on that one
(it should be able to tell that the var must be output from the
func, as it is uninitialised before the call, but it is apparently
not quite that smart yet) - but some later compiler "enhancement"
might start to object to that one being set, but never used, as
well, so figuring out how to fix that one - as long as we are going
to keep using compilers, and compile options, that are this pedantic,
mght be a good idea.
Index: pci_intr_fixup.c
===================================================================
RCS file: /cvsroot/NetBSD/src/sys/arch/i386/pci/pci_intr_fixup.c,v
retrieving revision 1.49
diff -u -r1.49 pci_intr_fixup.c
--- pci_intr_fixup.c 1 Jul 2011 17:37:26 -0000 1.49
+++ pci_intr_fixup.c 19 Apr 2014 16:37:10 -0000
@@ -666,10 +666,15 @@
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;
+#endif
pci_decompose_tag(pc, tag, &bus, &device, &function);
+#ifdef PCIBIOSVERBOSE
id = pci_conf_read(pc, tag, PCI_ID_REG);
+#endif
intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
pin = PCI_INTERRUPT_PIN(intr);