Open llvmbot opened 11 years ago
That does look totally bogus, but there have been a number of improvements to the analyzer since Clang 3.1 and Apple clang 421, and I don't see this on my recent trunk build. Can you test with ToT or the release branch for Clang 3.2?
You could also try the prepackaged-for-OS-X checker-269, from http://clang-analyzer.llvm.org, but that's not /quite/ as new. It's still newer than both versions you tried, though.
Ok this is fixed in checker-269 (below).
What's the story with clang version numbers? I only want to conditionally compile the memset below which shuts up the analyser but as checker is at 3.2 and Apple is at 4.1 the usual sort of tricks don't work. e.g.
( __clang_major__ < 4 || (__clang_major__ == 4 && __clang_minor__ < 2))
/* false positive: http://llvm.org/bugs/show_bug.cgi?id=14461 */
else memset(&querytsig, 0, sizeof(querytsig));
ccc-analyzer -I/Users/marka/git/bind9 -I. -Iinclude -I/Users/marka/git/bind9/lib/dns/include -I../../lib/dns/include -I/Users/marka/git/bind9/lib/isc/include -I../../lib/isc -I../../lib/isc/include -I../../lib/isc/unix/include -I../../lib/isc/pthreads/include -I../../lib/isc/x86_32/include -I/usr/include -I/opt/local/include -D_REENTRANT -DUSE_MD5 -DOPENSSL -DGSSAPI -DUSE_ISC_SPNEGO -D__APPLE_USE_RFC_3542 -g -O2 -I/opt/local/include/libxml2 -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing -c tsig.c
tsig.c:1157:4: warning: Function call argument is an uninitialized value
isc_buffer_putuint16(&databuf, querytsig.siglen);
^ ~~~~
/Users/marka/git/bind9/lib/isc/include/isc/buffer.h:894:31: note: expanded from macro 'isc_buffer_putuint16'
^
tsig.c:837:20: warning: Assigned value is garbage or undefined
tsig.timesigned = querytsig.timesigned;
^ ~~~~
tsig.c:888:26: warning: The right operand of '<' is a garbage value
if (response && bytes < querytsig.siglen)
^ ~~~~
3 warnings generated.
[drugs:bind9/lib/dns] marka% rm tsig.o
[drugs:bind9/lib/dns] marka% csh
[drugs:bind9/lib/dns] marka% set path = ( ~/Downloads/checker-269/bin $path )
[drugs:bind9/lib/dns] marka% clang -v
clang version 3.2 (tags/checker/checker-269)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
[drugs:bind9/lib/dns] marka% !ma
ma: Event not found.
[drugs:bind9/lib/dns] marka% make tsig.o
ccc-analyzer -I/Users/marka/git/bind9 -I. -Iinclude -I/Users/marka/git/bind9/lib/dns/include -I../../lib/dns/include -I/Users/marka/git/bind9/lib/isc/include -I../../lib/isc -I../../lib/isc/include -I../../lib/isc/unix/include -I../../lib/isc/pthreads/include -I../../lib/isc/x86_32/include -I/usr/include -I/opt/local/include -D_REENTRANT -DUSE_MD5 -DOPENSSL -DGSSAPI -DUSE_ISC_SPNEGO -D__APPLE_USE_RFC_3542 -g -O2 -I/opt/local/include/libxml2 -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing -c tsig.c
[drugs:bind9/lib/dns] marka%
That does look totally bogus, but there have been a number of improvements to the analyzer since Clang 3.1 and Apple clang 421, and I don't see this on my recent trunk build. Can you test with ToT or the release branch for Clang 3.2?
You could also try the prepackaged-for-OS-X checker-269, from http://clang-analyzer.llvm.org, but that's not /quite/ as new. It's still newer than both versions you tried, though.
assigned to @tkremenek
Extended Description
Multiple versions of clang.
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) Target: x86_64-apple-darwin12.2.0 Thread model: posix
clang version 3.1 (branches/release_31) Target: i386-portbld-freebsd8.3 Thread model: posix
The static analyser fails to remember that it set response to 0 for the analysis then proceeds to complain about code that will not be reached when response is 0.
clang --analyze tsig.preprocessed.c In file included from tsig.c:1: tsig.c:1337:4: warning: Function call argument is an uninitialized value isc__buffer_putuint16(&databuf, querytsig.siglen); ^
~~~~ tsig.c:1075:26: warning: The right operand of '<' is a garbage value if (response && bytes < querytsig.siglen) ^~~~~ tsig.c:1024:20: warning: Assigned value is garbage or undefined tsig.timesigned = querytsig.timesigned; ^~~~~