Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/findbad
diff options
context:
space:
mode:
authoralbert <albert>2009-11-23 02:37:53 (GMT)
committer albert <albert>2009-11-23 02:37:53 (GMT)
commitb5abb03bef0f32e1890602ea4bdd3a52c78b523d (patch)
treebd47dcca2bb3d666f5ca14e8b9fdf4d69768cc66 /findbad
parent597e6cee217a651d5a3bed3622824f91df78f5bb (diff)
run this to find coding mistakes
Diffstat (limited to 'findbad')
-rwxr-xr-xfindbad50
1 files changed, 50 insertions, 0 deletions
diff --git a/findbad b/findbad
new file mode 100755
index 0000000..7dfa11b
--- /dev/null
+++ b/findbad
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+CFILES=`find . -name \*.c -o -name \*.cpp -o -name \*.m`
+HFILES=`find . -name \*.h`
+OFILES=`find . -name \*.o -o -name \*.obj | egrep -v dummy.o`
+SOFILES=`find . -name \*.so -o -name \*.lib -o -name \*.dll -o -name \*.a -o -name \*.bundle`
+
+echo
+echo ++++++++++++++++ function prototypes in a '*.c' file +++++++++++++++++++++
+egrep '^[a-zA-Z_].*[)].*;' $CFILES | egrep -v ':typedef|[)][(]'
+
+echo
+echo ++++++++++++++++ non-extern prototypes in a header file +++++++++++++++++++++
+egrep '^[a-zA-Z_].*;' $HFILES | egrep -v ':(extern|typedef)'
+
+echo
+echo -n ++++++++++++++++ stuff that should be static but is not +++++++++++++++++++++
+nm $OFILES | colrm 1 9 | egrep '^[A-TV-Z] ' | colrm 1 2 | sort | uniq > notU.check
+nm $OFILES | colrm 1 9 | egrep '^U ' | colrm 1 2 | sort | uniq > U.check
+cat U.check U.check U.check notU.check | sort | uniq -c | sort -n | egrep '1 ' | colrm 1 8 > badtux.check
+cat badtux.check | while read a ; do nm $OFILES | egrep ':| . '$a'$' | egrep -B1 ' . '$a'$' ; done | egrep -v -- -- > wh.check
+(cat wh.check | tr -d '\n' ; echo) | sed -r -e 's/[.][/]([-0-9a-zA-Z_]*[/])*/\n/g' | sed -r -e 's/:.* / /' | awk '{printf("%-18s %s\n",$1,$2)}' | sort > sorted.check
+egrep -v ' main$' sorted.check
+
+echo
+echo ++++++++++++++++ things leaking out of shared objects +++++++++++++++++++++
+nm $SOFILES | egrep ' [A-TV-Z] [^_]|:' | awk '/.*[/]([^/]+)[.][a-zA-Z]*:/{file=$1} / [A-Za-z] /{printf("%-33s %s\n",file,$3)}' > soD.check
+while read a ; do
+ for i in $SOFILES ; do
+ j=`echo $i | sed -r -e 's/.*[/]([^/]+)[.][a-z]+$/\1/'`
+ echo '[^a-zA-Z_0-9]'${j}_$a'$'
+ done
+done > patterns.check <<-DONE
+ get_tool_count
+ get_name
+ get_icon
+ get_description
+ requires_colors
+ modes
+ set_color
+ init
+ api_version
+ shutdown
+ click
+ drag
+ release
+ switchin
+ switchout
+DONE
+egrep -v -f patterns.check soD.check