2014-02-07 07:08:53 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
scriptsDir="${HOME}/alliance/dev/scripts"
|
|
|
|
cppCheckDir="${scriptsDir}/cppcheck"
|
|
|
|
|
Code cleanup with cppcheck & gcc 4.4.6 (RHEL6).
This commit is way too big. Next time split it tool by tool.
All tool sources have been checked with cppcheck & gcc. All correctables
errors/warning have been removed:
* Now uses correct conversion specifiers in printf(), mostly 'u' instead
of 'd' for unsigneds.
* In scanf(), uses systematically a maximum field width, 11 for int,
22 for long int and the appropriate length for char*.
* In strcpy(), no longer uses same array for source & dest, but uses
an intermediate array.
* Remove (or comment) unused variables.
* In C++ files, correct constructors attribute initialisation and
disable copy constructors.
* When possible, correct memory leaks. Some corrections would need a
more intimate knowledge of the source than I do.
* Removed some "gets()" calls.
* In parsers, undeclare yyunput & yyinput when necessary.
* NOT correct variable scope as it may clutter the code (my opinion).
Specific tools remark:
* In <asimut>, comment beginning with "FRAGILE" signals a very ugly
trick: structs passed as losig_list but with only the two first
fields identical.
* In <graal> & <dreal> for char used as table index, uses a cast toward
int, but in <xfsm>, <xgra>, <xsch> & <xvpn> simply declares the
variables int.
* In <cells>, dp_nmux_x1.ap, shrink the ALU2 part of the ALU3 terminals
so they do not collide with neighboring track. Has do to it manually
as Graal refuse to shrink them. The same correction must be done on
other cells for nero/kite dual compliance.
2014-02-18 07:53:05 -06:00
|
|
|
tools="`cat ${scriptsDir}/tools.lst`"
|
|
|
|
|
|
|
|
# Find all include directories
|
|
|
|
toolDirs=""
|
|
|
|
for tool in ${tools}; do
|
|
|
|
toolDirs="${toolDirs} ${HOME}/alliance/alliance/src/${tool}"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Building the include directories list..."
|
|
|
|
find ${toolDirs} -name '*.h' -exec dirname {} \; | sort | uniq > ${cppCheckDir}/alliance.incs
|
|
|
|
|
|
|
|
toolsMax="`wc -l ${scriptsDir}/tools.lst | cut -d ' ' -f1`"
|
|
|
|
toolsNb="0"
|
|
|
|
echo "$toolsMax tools to process."
|
|
|
|
for tool in ${tools}; do
|
|
|
|
toolsNb=`expr ${toolsNb} + 1`
|
|
|
|
if [ ${toolsNb} -gt ${toolsMax} ]; then exit 0; fi
|
|
|
|
|
|
|
|
toolDir="${HOME}/alliance/alliance/src/${tool}"
|
|
|
|
sources=`find ${toolDir} -name \*.h -o -name \*.c -o -name \*.hpp -o -name \*.cpp`
|
|
|
|
|
|
|
|
echo "Checking tool <${tool}>..."
|
|
|
|
cppcheck -j3 $action --enable=all \
|
|
|
|
--includes-file=${cppCheckDir}/alliance.incs \
|
|
|
|
${sources} 2>&1 \
|
|
|
|
| grep -v 'The scope of the variable .* can be reduced' \
|
|
|
|
> ${cppCheckDir}/${tool}.log
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|
2014-02-07 07:08:53 -06:00
|
|
|
# Look for missing includes.
|
|
|
|
#action="--check-config"
|
|
|
|
|
|
|
|
# Perform the actual check.
|
|
|
|
action=""
|
|
|
|
|
|
|
|
cppcheck -j3 $action --enable=all --verbose \
|
|
|
|
--includes-file=${cppCheckDir}/alliance.incs \
|
|
|
|
--file-list=${cppCheckDir}/alliance.srcs > ${cppCheckDir}/cppcheck.log 2>&1 &
|