diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-02-10 22:53:48 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-02-10 22:53:48 +0000 |
commit | 7be63e199ba9c599016a17e9b9e88c3ffc1c9640 (patch) | |
tree | 917b661233c88a00e709ae1025d6714fbb8edcf2 /tools | |
parent | b1d4ef88516f250106728d0b8deb713d6276db09 (diff) |
Add (commented-out for now) code to check certain function calls for embedded
(in the argument list) calls to tvb_get_ptr().
svn path=/trunk/; revision=35906
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/checkAPIs.pl | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl index fc594166e6..5d2f58a620 100755 --- a/tools/checkAPIs.pl +++ b/tools/checkAPIs.pl @@ -933,11 +933,11 @@ my %deprecatedGtkFunctions = ( 'GTK_WIDGET_VISIBLE', 'W', # gtk_widget_getvisible() (avail since 2.18) ## Deprecated as of GTK+ 2.22 but to be replaced only when Wireshark requires GTK+ 2.18 or later ## (or: use conditional code based upon the GTK version). - 'gtk_dialog_get_has_separator', 'E', # This function will be removed in GTK+ 3 + 'gtk_dialog_get_has_separator', 'E', # This function will be removed in GTK+ 3 'gtk_dialog_set_has_separator', 'E', # This function will be removed in GTK+ 3 'gtk_icon_view_get_orientation', 'E', # gtk_icon_view_get_item_orientation() 'gtk_icon_view_set_orientation', 'E', # gtk_icon_view_set_item_orientation() - 'gtk_item_deselect', 'E', # gtk_menu_item_deselect() + 'gtk_item_deselect', 'E', # gtk_menu_item_deselect() 'gtk_item_select', 'E', # gtk_menu_item_select() 'gtk_item_toggle', 'E', # 'gtk_recent_manager_get_limit', 'E', # Use GtkRecentChooser @@ -976,9 +976,44 @@ sub findAPIinFile($$$) } } +my @TvbPtrAPIs = ( + # Use NULL for the value_ptr instead of tvb_get_ptr() + # (Only if the given offset and length are equal) with these: + 'proto_tree_add_bytes_format', + 'proto_tree_add_bytes_format_value', + # Use the tvb_* version of these: + 'ether_to_str', + 'ip_to_str', + 'ip6_to_str', + 'fc_to_str', + 'fcwwn_to_str' +); + +sub checkAPIsCalledWithTvbGetPtr($$$) +{ + my ($APIs, $fileContentsRef, $foundAPIsRef) = @_; + + for my $api (@{$APIs}) { + my @items; + my $cnt = 0; + + @items = (${$fileContentsRef} =~ m/($api[^;]*;)/sg); + while (@items) { + my ($item) = @items; + shift @items; + if ($item =~ /tvb_get_ptr/xos) { + $cnt += 1; + } + } + + if ($cnt > 0) { + push @{$foundAPIsRef}, $api; + } + } +} + # Given the file contents and a file name, check all of the hf entries for # various problems (such as those checked for in proto.c). - sub check_hf_entries($$) { my ($fileContentsRef, $filename) = @_; @@ -1194,6 +1229,12 @@ while ($_ = $ARGV[0]) $errorCount++; } + #checkAPIsCalledWithTvbGetPtr(\@TvbPtrAPIs, \$fileContents, \@foundAPIs); + + #if (@foundAPIs) { + # print STDERR "Found APIs with embedded tvb_get_ptr() calls in ".$filename.": ".join(',', @foundAPIs)."\n" + #} + # 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): |