diff --git a/utilities/check_compensations b/utilities/check_compensations new file mode 100755 index 0000000..0019807 --- /dev/null +++ b/utilities/check_compensations @@ -0,0 +1,80 @@ +#! /usr/bin/perl -w + +use strict; +my @header = `find . -name '*.h'`; +my @source = `find . -name '*.c'`; + +my %h; +my $nest = 0; + +foreach my $i (@header) { + my @lines = `grep compensated_function $i`; + + foreach my $j (@lines) { + if($j =~ /compensated_function[^\(]+ ([^\s\(]+)\s*\(/) { + $h{$1}++; + } + } +} + +open EXTRAS, "additional_checked_functions"; + +while (defined(my $line = )) { + chomp $line; + $line =~ s/\#.*$//g; + $line =~ s/\s//g; + if($line =~ /\S/) { + $h{$line}++; + } +} + +print "Found the following checked functions:\n"; +print "------------------------------------- \n"; +foreach my $i (sort keys %h) { + print("$i\n"); +} +print "\n"; + + +my $pwd = `pwd`; +chomp $pwd; +foreach my $i (@source) { + chomp $i; + open IN, $i; + print "$i\n"; +# More accurate, but messes up line numbers. :( +# open IN, "utilities/cpp_no_inc <$i |"; + $nest = 0; + my $num = 0; + while(my $line = ) { + $num++; + my $in = 0; + if ($line =~ /\bbegin_action(_ret)?\b/) { + $nest++; + $in = 1; + } + if ($line =~ /\bend_action(_ret)?\b/ || $line =~ /\bcompensate(_ret)?\b/) { + $nest--; + if($in) { + warn "$pwd/$i:$num Cannot handle single line compensation checks\n"; + } + } + if($line !~ /\bcompensated_function\b/) { + foreach my $j (keys %h) { + if(($line =~ /$j\s*\(/) && !$nest) { + warn "$pwd/$i:$num Unchecked invocation of $j\n"; + } + } + if ($nest < 0) { + warn "$pwd/$i:$num Closed compensation check without open.\n"; + $nest = 0; + } + } + } + + if ($nest > 0) { + warn "$pwd/$i:$num Unclosed compensation check.\n"; + } + close IN; + +} diff --git a/utilities/cpp_no_inc b/utilities/cpp_no_inc new file mode 100755 index 0000000..ff6660c --- /dev/null +++ b/utilities/cpp_no_inc @@ -0,0 +1,4 @@ +#!/bin/bash +grep -v \#include |cpp|grep -v '^\# [0-9]' + +