Add (commented-out for now) code to check certain function calls for embedded
authormorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 10 Feb 2011 22:53:48 +0000 (22:53 +0000)
committermorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 10 Feb 2011 22:53:48 +0000 (22:53 +0000)
(in the argument list) calls to tvb_get_ptr().

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35906 f5534014-38df-0310-8fa8-9805f1628bb7

tools/checkAPIs.pl

index fc594166e6c5565420ee3b1a9d59e9fa5280f30f..5d2f58a6204ce280372b6091b00dede2143cbe1b 100755 (executable)
@@ -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):