[chrony-dev] Logs from scan-build from Clang 3.4-1

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Dear chrony developers,


using the Clang static analyzer scan-build from Debian Clang version
3.4-1, the following warnings are printed.

        $ git describe origin/master
        1.29-3-g169eee6
        $ scan-build -analyze-headers -o scan-build make -j2
        scan-build: Using '/usr/bin/clang' for static analysis
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c util.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c sched.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c regress.c
        regress.c:197:22: warning: The left operand of '<' is a garbage value
            if (((resid[i-1] < 0.0) && (resid[i] < 0.0)) ||
                  ~~~~~~~~~~ ^
        regress.c:197:42: warning: The left operand of '<' is a garbage value
            if (((resid[i-1] < 0.0) && (resid[i] < 0.0)) ||
                                        ~~~~~~~~ ^
        regress.c:198:42: warning: The left operand of '>' is a garbage value
                ((resid[i-1] > 0.0) && (resid[i] > 0.0))) {
                                        ~~~~~~~~ ^
        regress.c:396:21: warning: The left operand of '>' is a garbage value
                while (x[r] > piv) r--;
                       ~~~~ ^
        4 warnings generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c local.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c sys.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c main.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c ntp_io.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c ntp_core.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c ntp_sources.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c sources.c
        ntp_core.c:1545:3: warning: Value stored to 'prev' is never read
          prev = inst->local_rx;
          ^      ~~~~~~~~~~~~~~
        1 warning generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c sourcestats.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c reference.c
        sourcestats.c:625:5: warning: Value stored to 'prev' is never read
            prev = *sample;
            ^      ~~~~~~~
        sourcestats.c:640:3: warning: Value stored to 'prev_offset' is never read
          prev_offset = inst->estimated_offset;
          ^             ~~~~~~~~~~~~~~~~~~~~~~
        2 warnings generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c logging.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c conf.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c cmdmon.c
        cmdmon.c:1940:5: warning: Value stored to 'allowed' is never read
            allowed = 0;
            ^         ~
        1 warning generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c keys.c
        keys.c:263:7: warning: Function call argument is an uninitialized value
              LOG(LOGS_WARN, LOGF_Keys, "Detected duplicate key %lu", key_id);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ./logging.h:101:61: note: expanded from macro 'LOG'
        #define LOG LOG_Position(__FILE__, __LINE__, __FUNCTION__); LOG_Line_Function
                                                                    ^
        1 warning generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c nameserv.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c acquire.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c manual.c
        manual.c:176:54: warning: The left operand of '*' is a garbage value
            samples[i].residual = offsets[i] - (b0 + agos[i] * b1);
                                                     ~~~~~~~ ^
        1 warning generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c addrfilt.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c cmdparse.c
        acquire.c:623:9: warning: Call to 'malloc' has an allocation size of 0 bytes
          eps = MallocArray(Endpoint, 2*n_sane_sources);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ./memory.h:32:34: note: expanded from macro 'MallocArray'
        #define MallocArray(T, n) ((T *) malloc((n) * sizeof(T)))
                                         ^~~~~~~~~~~~~~~~~~~~~~~
        acquire.c:689:54: warning: The left operand of '+' is a garbage value
              estimated_offset = 0.5 * (intervals[index1].lo + intervals[index2].hi);
                                        ~~~~~~~~~~~~~~~~~~~~ ^
        2 warnings generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c mkdirpp.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c rtc.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c pktlength.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c clientlog.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c broadcast.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c refclock.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c refclock_phc.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c refclock_pps.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c refclock_shm.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c refclock_sock.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c tempcomp.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g   -c hash_intmd5.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c sys_linux.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c wrap_adjtimex.c
        sys_linux.c:1164:14: warning: Access to field 'pw_gid' results in a dereference of a null pointer (loaded from variable 'pw')
          if (setgid(pw->pw_gid)) {
                     ^~~~~~~~~~
        1 warning generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c rtc_linux.c
        rtc_linux.c:675:7: warning: Branch condition evaluates to a garbage value
          if (valid) {
              ^~~~~
        rtc_linux.c:756:5: warning: Value stored to 'error' is never read
            error = 1;
            ^       ~
        2 warnings generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g   -c client.c
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g  -c getdate.c
        getdate.c:1265:5: warning: Value stored to 'yymsg' is never read
            yymsg = "Deleting";
            ^       ~~~~~~~~~~
        1 warning generated.
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g -o chronyd util.o sched.o regress.o local.o sys.o main.o ntp_io.o ntp_core.o ntp_sources.o sources.o sourcestats.o reference.o logging.o conf.o cmdmon.o keys.o nameserv.o acquire.o manual.o addrfilt.o cmdparse.o mkdirpp.o rtc.o pktlength.o clientlog.o broadcast.o refclock.o refclock_phc.o refclock_pps.o refclock_shm.o refclock_sock.o tempcomp.o hash_intmd5.o sys_linux.o wrap_adjtimex.o rtc_linux.o   -lm -lcap
        /usr/share/clang/scan-build/ccc-analyzer -O2 -g -o chronyc client.o nameserv.o getdate.o cmdparse.o pktlength.o util.o hash_intmd5.o   -ledit  -lm 
        scan-build: 16 bugs found.
        scan-build: Run 'scan-view /srv/filme/src/chrony/scan-build/2013-10-03-130043-31884-1' to examine bug reports.

I suggest to install it on your system yourself, as it also gives nice
Web pages where the steps are shown how to reach certain conditions.

Unfortunately, I do not know the code well enough to fix certain things,
so I just posted patches for the easy ones and hope somebody else finds
the time to address the other warnings.


Thanks,

Paul

Attachment: signature.asc
Description: This is a digitally signed message part



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/