NetBSD-Bugs archive

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

kern/39835: 'Uninitialized var in altq_subr.c' build failure



>Number:         39835
>Category:       kern
>Synopsis:       'Uninitialized var in altq_subr.c' build failure
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 30 13:30:01 +0000 2008
>Originator:     Hauke Fath <hf%spg.tu-darmstadt.de@localhost>
>Release:        NetBSD 4.99.73
>Organization:
        
>Environment:
        
        
System: NetBSD 4.99.73 sparc cross-build
Architecture: sparc
Machine: sparc
>Description:

        Compiling an altq enabled -current kernel gives me

#   compile  PIZZA_PF/altq_wfq.o
/u/netbsd-builds/developer/sparc/tools/bin/sparc--netbsdelf-gcc -mno-fpu 
-ffreestanding -fno-zero-initialized-in-bss -mcpu
--- altq_subr.o ---
cc1: warnings being treated as errors
/public/netbsd-developer/sys/altq/altq_subr.c: In function 'read_machclk':
/public/netbsd-developer/sys/altq/altq_subr.c:826: warning: 'val' may be used 
uninitialized in this function


        Looking at the source, gcc is right:


1.16         (peter    12-Oct-06): u_int64_t
1.16         (peter    12-Oct-06): read_machclk(void)
1.1          (thorpej  14-Dec-00): {
1.16         (peter    12-Oct-06):      u_int64_t val;
1.16         (peter    12-Oct-06):
1.16         (peter    12-Oct-06):      if (machclk_usepcc) {
1.25         (ad       10-May-08): #ifdef __HAVE_CPU_COUNTER
1.25         (ad       10-May-08):              return cpu_counter();
1.16         (peter    12-Oct-06): #endif
1.1          (thorpej  14-Dec-00):      } else {
1.16         (peter    12-Oct-06):              struct timeval tv;
1.16         (peter    12-Oct-06):
1.16         (peter    12-Oct-06):              microtime(&tv);
1.16         (peter    12-Oct-06):              val = (((u_int64_t)(tv.tv_sec - 
boottime.tv_sec) * 1000000
1.16         (peter    12-Oct-06):                  + tv.tv_usec) << 
MACHCLK_SHIFT);
1.1          (thorpej  14-Dec-00):      }
1.16         (peter    12-Oct-06):      return (val);


>How-To-Repeat:
        
        (Cross-)build.sh a sparc kernel from -current sources.

>Fix:

        I am tempted to slip in a 'val = 0', but am not sure that this
        is the intended return value for 'if (machclk_usepcc)' and
        undefined __HAVE_CPU_COUNTER? Someone who actually knows the
        code should look into this.

        See also
        <http://mail-index.netbsd.org/tech-kern/2008/10/27/msg003274.html> ff.

>Unformatted:
        
        


Home | Main Index | Thread Index | Old Index