tech-kern archive

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

Uninitialized var in altq_subr.c



Hi,

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);


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?

        hauke

--
     The ASCII Ribbon Campaign                    Hauke Fath
()     No HTML/RTF in email             Institut für Nachrichtentechnik
/\     No Word docs in email                     TU Darmstadt
     Respect for open standards              Ruf +49-6151-16-3281


Home | Main Index | Thread Index | Old Index