Makistos
10/28/2013 - 7:49 AM

Prettifies the code into the Linux kernel style and runs Splint and Sparse static code analysis tools for every .c and .h file in the direct

Prettifies the code into the Linux kernel style and runs Splint and Sparse static code analysis tools for every .c and .h file in the directory. Also, change to use astyle. NOTE: Should add file existence checking insde for loop. #sparse #splint #static-analysis #bash #todo

# q.sh
# 
# Indents each code module to Linux kernel style and runs splint
# and sparse analysis on them. Reports are saved to the qreports
# directory.

REPFILE=quality.log

if [ -e $REPFILE ] ; then
  rm $REPFILE
fi

for i in *.c *.h ; do
  # Intend source file
  indent --linux-style --no-tabs $i

  echo $i: >> $REPFILE
  echo >> $REPFILE

  # Run splint
  echo "Splint...." >> $REPFILE 
  echo "----------" >> $REPFILE
  splint -weak $i >> $REPFILE +trytorecover 2>&1 # trytorecover required by ALSA inc files

  # Run sparse
  echo " " >> $REPFILE
  echo "----------" >> $REPFILE
  echo "Sparse...." >> $REPFILE 
  echo "----------" >> $REPFILE 

  sparse $i >> $REPFILE 2>&1
  echo >> $REPFILE
  echo "==========================================================================" >> $REPFILE
  echo >> $REPFILE 
done