summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorivo <ivo@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-14 22:05:49 +0000
committerivo <ivo@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-14 22:05:49 +0000
commit71b5d4f1ae5d3b9072147c0d1de4427251983487 (patch)
tree59c794875fe447abf1c5b6c2b34b2192c77cdfb1 /TOOLS
parent95c4abd4222c6c13ec4d52f621de1b51e8abfd99 (diff)
downloadmpv-71b5d4f1ae5d3b9072147c0d1de4427251983487.tar.bz2
mpv-71b5d4f1ae5d3b9072147c0d1de4427251983487.tar.xz
added checks for stupid code like casting return value of malloc and friends,
sizeof(char) and similar 1 byte types, &&1, ||0, +0, -0, *1, *0 typical usage: ./checktree.sh -none -stupid -showcont somefile.c git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19090 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS')
-rwxr-xr-xTOOLS/checktree.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/TOOLS/checktree.sh b/TOOLS/checktree.sh
index 05debaa11b..4d9b6f72ee 100755
--- a/TOOLS/checktree.sh
+++ b/TOOLS/checktree.sh
@@ -23,6 +23,7 @@ _trailws=no
_rcsid=no
_oll=no
_charset=no
+_stupid=no
_showcont=no
_color=yes
@@ -48,6 +49,7 @@ enable_all_tests() {
_rcsid=yes
_oll=yes
_charset=yes
+ _stupid=yes
}
disable_all_tests() {
@@ -58,6 +60,7 @@ disable_all_tests() {
_rcsid=no
_oll=no
_charset=no
+ _stupid=no
}
printoption() {
@@ -112,6 +115,7 @@ for i in "$@"; do
printoption "rcsid " "test for missing RCS Id's" "$_rcsid"
printoption "oll " "test for overly long lines" "$_oll"
printoption "charset " "test for wrong charset" "$_charset"
+ printoption "stupid " "test for stupid code" "$_stupid"
echo
printoption "all " "enable all tests" "no"
echo
@@ -126,6 +130,12 @@ for i in "$@"; do
echo -e "If there are, -(no)svn has no effect.\n"
exit
;;
+ -stupid)
+ _stupid=yes
+ ;;
+ -nostupid)
+ _stupid=no
+ ;;
-charset)
_charset=yes
;;
@@ -300,3 +310,47 @@ if [ "$_charset" == "yes" ]; then
fi
# -----------------------------------------------------------------------------
+
+if [ "$_stupid" == "yes" ]; then
+ printhead "checking for stupid code ..."
+
+ # avoid false-positives in xpm files, docs, etc, only check .c and .h files
+ chfilelist=`echo $filelist | tr ' ' '\n' | grep "[\.][ch]$"`
+
+ for i in calloc malloc realloc memalign av_malloc av_mallocz faad_malloc \
+ lzo_malloc safe_malloc mpeg2_malloc _ogg_malloc; do
+ printhead "--> casting of void* $i()"
+ grep $_grepopts "([ ]*[a-zA-Z_]\+[ ]*\*.*)[ ]*$i" $chfilelist
+ done
+
+ for i in "" signed unsigned; do
+ printhead "--> usage of sizeof($i char)"
+ grep $_grepopts "sizeof[ ]*([ ]*$i[ ]*char[ ]*)" $chfilelist
+ done
+
+ for i in int8_t uint8_t; do
+ printhead "--> usage of sizeof($i)"
+ grep $_grepopts "sizeof[ ]*([ ]*$i[ ]*)" $chfilelist
+ done
+
+ printhead "--> usage of &&1"
+ grep $_grepopts "&&[ ]*1" $chfilelist
+
+ printhead "--> usage of ||0"
+ grep $_grepopts "||[ ]*0" $chfilelist
+
+ # added a-fA-F_ to eliminate some false positives
+ printhead "--> usage of *0"
+ grep $_grepopts "[a-zA-Z0-9)]\+[ ]*\*[ ]*0[^.0-9xa-fA-F_]" $chfilelist
+
+ printhead "--> usage of *1"
+ grep $_grepopts "[a-zA-Z0-9)]\+[ ]*\*[ ]*1[^.0-9ea-fA-F_]" $chfilelist
+
+ printhead "--> usage of +0"
+ grep $_grepopts "[a-zA-Z0-9)]\+[ ]*+[ ]*0[^.0-9xa-fA-F_]" $chfilelist
+
+ printhead "--> usage of -0"
+ grep $_grepopts "[a-zA-Z0-9)]\+[ ]*-[ ]*0[^.0-9xa-fA-F_]" $chfilelist
+fi
+
+# -----------------------------------------------------------------------------