Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pmc changes break kernels w/makeoptions "COPTS=-Os"
Kernel configs like "NET4501" routinely include:
makeoptions "COPTS=-Os"
This causes GCC to emit warnings (treated as errors) if it thinks a
variable might be used uninitialized. For example, the following:
# compile NET4501_JDB/pmc.o
/r1/build/current/tools/amd64/bin/i486--netbsdelf-gcc -msoft-float -mno-mmx -mno-sse -mno-avx -ffreestanding -fno-zero-initialized-in-bss -g -Os -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=/r1/build/current/DEST/i386 -Di386 -I. -I/x/current/src/sys/external/bsd/acpica/dist -I/x/current/src/sys/../common/lib/libx86emu -I/x/current/src/sys/../common/include -I/x/current/src/sys/arch -I/x/current/src/sys -nostdinc -DTIMER_FREQ=1189200 -D_KERNEL -D_KERNEL_OPT -std=gnu99 -I/x/current/src/sys/lib/libkern/../../../common/lib/libc/quad -I/x/current/src/sys/lib/libkern/../../../common/lib/libc/string -I/x/current/src/sys/lib/libkern/../../../common/lib/libc/arch/i386/string -D_FORTIFY_SOURCE=2 -I/x/current/src/sys/dist/pf -c /x/current/src/sys/arch/x86/x86/pmc.c -o pmc.o
/x/current/src/sys/arch/x86/x86/pmc.c: In function 'pmc_nmi':
/x/current/src/sys/arch/x86/x86/pmc.c:168:2: error: 'pmc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
wrmsr(pmc->ctrmsr, pmc->ctrinitval);
^
While I can follow the logic in "pmc.c", GCC with "-Os" cannot. Would
the following patch be appropriate for appeasing GCC?
+Index: sys/arch/x86/x86/pmc.c
+===================================================================
+RCS file: /cvsroot/src/sys/arch/x86/x86/pmc.c,v
+retrieving revision 1.10
+diff -u -p -r1.10 pmc.c
+--- sys/arch/x86/x86/pmc.c 12 Jul 2017 17:33:29 -0000 1.10
++++ sys/arch/x86/x86/pmc.c 13 Jul 2017 19:08:13 -0000
+@@ -138,7 +138,7 @@ static int
+ pmc_nmi(const struct trapframe *tf, void *dummy)
+ {
+ struct cpu_info *ci = curcpu();
+- pmc_state_t *pmc;
++ pmc_state_t *pmc = (pmc_state_t *)NULL;
+ pmc_cpu_t *cpu;
+ uint64_t ctr;
+ size_t i;
--
|/"\ John D. Baker, KN5UKS NetBSD Darwin/MacOS X
|\ / jdbaker[snail]mylinuxisp[flyspeck]com OpenBSD FreeBSD
| X No HTML/proprietary data in email. BSD just sits there and works!
|/ \ GPGkeyID: D703 4A7E 479F 63F8 D3F4 BD99 9572 8F23 E4AD 1645
Home |
Main Index |
Thread Index |
Old Index