[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/48757: sys/arch/i386/pci/pci_intr_fixup.c var set but not used (+FIX?)
>Synopsis: sys/arch/i386/pci/pci_intr_fixup.c var set but not used (+FIX?)
>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)
Prince of Songkla University
System: NetBSD perseus.noi.kre.to 6.99.17 NetBSD 6.99.17 (GENERIC) #1: Fri Feb
22 22:09:50 ICT 2013
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 -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
/release/current/src/sys/arch/i386/pci/pci_intr_fixup.c: In function
/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
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).
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.
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;
+ pcireg_t id;
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);
Main Index |
Thread Index |