diff options
author | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2015-06-01 19:48:17 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-07-23 15:53:38 +0000 |
commit | 1ddf1cfeb006aec4fe8d41d4f84fa052b30ec887 (patch) | |
tree | bf8f7b032de8e144983da26988713733031097d5 /tools/checkAPIs.pl | |
parent | 8575e41918c25eeaec42fc8f1510bd3f4f41d87a (diff) | |
download | wireshark-1ddf1cfeb006aec4fe8d41d4f84fa052b30ec887.tar.gz |
CheckAPI: Add a shadow variable check
Check if there is index, time or strlen variable
Change-Id: I530a35d6e1cf13f0795b35579ce76ee373ed4b1a
Reviewed-on: https://code.wireshark.org/review/8724
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'tools/checkAPIs.pl')
-rwxr-xr-x | tools/checkAPIs.pl | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl index 5738f9dc0b..16772fcf39 100755 --- a/tools/checkAPIs.pl +++ b/tools/checkAPIs.pl @@ -1440,6 +1440,30 @@ sub checkAPIsCalledWithTvbGetPtr($$$) } } +# List of possible shadow variable (Majority coming from Mac OS X..) +my @ShadowVariable = ( + 'index', + 'time', + 'strlen', +); + +sub checkShadowVariable($$$) +{ + my ($groupHashRef, $fileContentsRef, $foundAPIsRef) = @_; + + for my $api ( @{$groupHashRef} ) + { + my $cnt = 0; + while (${$fileContentsRef} =~ m/ \W $api \W* \( /gx) + { + $cnt += 1; + } + if ($cnt > 0) { + push @{$foundAPIsRef}, $api; + } + } +} + sub check_snprintf_plus_strlen($$) { my ($fileContentsRef, $filename) = @_; @@ -2154,6 +2178,12 @@ while ($_ = $ARGV[0]) # print STDERR "Found APIs with embedded tvb_get_ptr() calls in ".$filename." : ".join(',', @foundAPIs)."\n" #} + checkShadowVariable(\@ShadowVariable, \$fileContents, \@foundAPIs); + if (@foundAPIs) { + print STDERR "Warning: Found shadow variable(s) in ".$filename." : ".join(',', @foundAPIs)."\n" + } + + check_snprintf_plus_strlen(\$fileContents, $filename); if ($check_addtext && ! $buildbot_flag) { |