Menu

#30 uninitialized use of ret variable in Output.c

None
closed
nobody
None
5
2014-12-22
2014-09-24
Peter
No

Compiling MrFast 2.6.0.2 on Mac OS X 10.9.4 with XCode 5.1.1 which uses clang rather than the GNU C compiler gives several compiler warnings about uninitialized use of ret variable in Output.c which could be real bugs (and in any case are worth fixing):

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
$ tar -zxvf mrfast-2.6.0.2.tar.gz 
x mrfast-2.6.0.2/Reads.c
x mrfast-2.6.0.2/header
x mrfast-2.6.0.2/HashTable.h
x mrfast-2.6.0.2/CommandLineParser.h
x mrfast-2.6.0.2/MrFAST.h
x mrfast-2.6.0.2/Reads.h
x mrfast-2.6.0.2/LICENSE
x mrfast-2.6.0.2/Makefile
x mrfast-2.6.0.2/HashTable.c
x mrfast-2.6.0.2/CommandLineParser.c
x mrfast-2.6.0.2/MrFAST.c
x mrfast-2.6.0.2/Common.c
x mrfast-2.6.0.2/RefGenome.h
x mrfast-2.6.0.2/RefGenome.c
x mrfast-2.6.0.2/
x mrfast-2.6.0.2/Output.h
x mrfast-2.6.0.2/baseFAST.c
x mrfast-2.6.0.2/Common.h
x mrfast-2.6.0.2/Output.c
$ cd mrfast-2.6.0.2
$ make
gcc -c -O3 -Wall -msse -msse2  baseFAST.c -o baseFAST.o 
gcc -c -O3 -Wall -msse -msse2  CommandLineParser.c -o CommandLineParser.o 
gcc -c -O3 -Wall -msse -msse2  Common.c -o Common.o 
gcc -c -O3 -Wall -msse -msse2  HashTable.c -o HashTable.o 
gcc -c -O3 -Wall -msse -msse2  MrFAST.c -o MrFAST.o 
gcc -c -O3 -Wall -msse -msse2  Output.c -o Output.o 
Output.c:257:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  if (fp != NULL){
      ^~~~~~~~~~
Output.c:276:3: note: uninitialized use occurs here
  ret++;
  ^~~
Output.c:257:3: note: remove the 'if' if its condition is always true
  if (fp != NULL){
  ^~~~~~~~~~~~~~~
Output.c:252:12: note: initialize the variable 'ret' to silence this warning
  char *ret;
           ^
            = NULL
Output.c:291:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  if (fp != NULL){
      ^~~~~~~~~~
Output.c:310:3: note: uninitialized use occurs here
  ret++;
  ^~~
Output.c:291:3: note: remove the 'if' if its condition is always true
  if (fp != NULL){
  ^~~~~~~~~~~~~~~
Output.c:286:12: note: initialize the variable 'ret' to silence this warning
  char *ret;
           ^
            = NULL
2 warnings generated.
gcc -c -O3 -Wall -msse -msse2  Reads.c -o Reads.o 
gcc -c -O3 -Wall -msse -msse2  RefGenome.c -o RefGenome.o 
gcc baseFAST.o CommandLineParser.o Common.o HashTable.o MrFAST.o Output.o Reads.o RefGenome.o -o mrfast -lz -lm  
rm -rf *.o

Discussion

  • Can Alkan

    Can Alkan - 2014-10-02

    Thanks Peter. These are not real bugs though. We'll fix them in the upcoming 3.0 release, but since we do not support/use MacOSX, we might miss some of these

     
  • Can Alkan

    Can Alkan - 2014-10-27
    • status: open --> closed
    • Group: -->
     
  • Can Alkan

    Can Alkan - 2014-10-27

    fixed in 2.6.1.0

     

Log in to post a comment.

MongoDB Logo MongoDB