Subject: Re: Error in ip_nat.c when building -current
To: Raymond Meyer <raymond.meyer@rambler.ru>
From: Tobias Nygren <tnn@NetBSD.org>
List: current-users
Date: 05/22/2007 11:11:31
On Tue, 22 May 2007 09:59:49 +0100
Raymond Meyer <raymond.meyer@rambler.ru> wrote:

> Below are the errors when I try to build kernel. What would be a proper fix for 
> this? Explicitly setting variables nat, ipn, and hm to NULL?2
> 
> /opt/tools.sparc64/bin/sparc64--netbsd-gcc -mcmodel=medlow -mno-fpu -ffreestanding -fno-zero-initialized-in-bss -mcpu=ultrasparc -mvis -O3 -pipe -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-compare -Wno-pointer-sign -Wno-attributes -Wextra -Wno-unused-parameter -fno-strict-aliasing -Dsparc64 -D__sparc64__ -D_LP64 -Wa,-Av9a -I. -I/opt/src/sys/contrib/dev/ath/netbsd -I/opt/src/sys/../common/include -I/opt/src/sys/arch -I/opt/src/sys -nostdinc -DLKM -DMAXUSERS=64 -D_KERNEL -D_KERNEL_OPT -I/opt/src/sys/lib/libkern/../../../common/lib/libc/quad -I/opt/src/sys/lib/libkern/../../../common/lib/libc/string -I/opt/src/sys/lib/libkern/../../../common/lib/libc/arch/sparc64/string -I/opt/src/sys/dist/ipf -c /opt/src/sys/dist/ipf/netinet/ip_nat.c
> cc1: warnings being treated as errors
> /opt/src/sys/dist/ipf/netinet/ip_nat.c: In function 'fr_nat_ioctl':
> /opt/src/sys/dist/ipf/netinet/ip_nat.c:4923: warning: 'nat' may be used uninitialized in this function
> /opt/src/sys/dist/ipf/netinet/ip_nat.c:4922: warning: 'ipn' may be used uninitialized in this function
> /opt/src/sys/dist/ipf/netinet/ip_nat.c:4921: warning: 'hm' may be used uninitialized in this function
> *** [ip_nat.o] Error code 1
> 1 error
> 
> nbmake: stopped in /opt/obj.sparc64/sys/arch/sparc64/compile/GENERIC

Beware of building kernel code with -O3.
GCC's frivolous inlining has been known to cause problems in the past.
But if you're determined to try, explicitly initialising the variables
is a valid fix. This is just GCC guessing wrong due to it's loop
unswitching.

-T