aboutsummaryrefslogtreecommitdiffstats
path: root/tools/checkAPIs.pl
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2012-07-03 21:55:55 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2012-07-03 21:55:55 +0000
commit3d1b5e3474c1befa2e0cbfe67da100b6a3e32124 (patch)
tree757753fc5eb9ca494ac2981e34de868a4b5ee1fe /tools/checkAPIs.pl
parentd889046e5f9b6309fbdd32b1ee0f6d149edb0cdd (diff)
As suggested by Jakub in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7429#c4 :
Add checks for calls to proto_tree_add_XXX (where XXX != item and a few other functions) with an encoding (ENC_*) argument. Also add a comment to checkAddTextCalls() about why 3 loops are used. svn path=/trunk/; revision=43563
Diffstat (limited to 'tools/checkAPIs.pl')
-rwxr-xr-xtools/checkAPIs.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index c7180c9316..95c53256ce 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -1318,6 +1318,9 @@ sub checkAddTextCalls($$)
my $okay_add_text_count = 0;
my $add_xxx_count = 0;
+ # The 3 loops here are slow, but trying a single loop with capturing
+ # parenthesis is even slower!
+
# First count how many proto_tree_add_text() calls there are in total
while (${$fileContentsRef} =~ m/ \W* proto_tree_add_text \W* \( /gox) {
$add_text_count++;
@@ -1407,6 +1410,40 @@ sub check_snprintf_plus_strlen($$)
}
}
+sub check_proto_tree_add_XXX_encoding($$)
+{
+ my ($fileContentsRef, $filename) = @_;
+ my @items;
+
+ @items = (${$fileContentsRef} =~ m/ (proto_tree_add_[_a-z0-9]+) \( ([^;]*) \) \s* ; /xsg);
+
+ while (@items) {
+ my ($func) = @items;
+ shift @items;
+ my ($args) = @items;
+ shift @items;
+
+ # Remove anything inside parenthesis in the arguments so we
+ # don't get false positives when someone calls
+ # proto_tree_add_XXX(..., tvb_YYY(..., ENC_ZZZ))
+ $args =~ s/\(.*\)//g;
+
+ if ($args =~ /,\s*ENC_/xos) {
+ if (!($func =~ /proto_tree_add_(item|bitmask|bits_item|bits_ret_val)/xos)
+ ) {
+ print STDERR "Warning: ".$filename." uses $func with ENC_*.\n";
+
+ # Print out the function args to make it easier
+ # to find the offending code. But first make
+ # it readable by eliminating extra white space.
+ $args =~ s/\s+/ /g;
+ print STDERR "\tArgs: " . $args . "\n";
+ }
+ }
+ }
+}
+
+
# Verify that all declared ett_ variables are registered.
# Don't bother trying to check usage (for now)...
sub check_ett_registration($$)
@@ -1765,6 +1802,8 @@ while ($_ = $ARGV[0])
checkAddTextCalls(\$fileContents, $filename);
}
+ check_proto_tree_add_XXX_encoding(\$fileContents, $filename);
+
# Brute force check for value_string arrays which are missing {0, NULL} as the final (terminating) array entry
if ($check_value_string_array_null_termination) {
# Assumption: definition is of form (pseudo-Regex):