aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2013-02-07 19:36:29 +0000
committerBill Meier <wmeier@newsguy.com>2013-02-07 19:36:29 +0000
commit669e68dfded50f813464eeb3dc4e334578f85de5 (patch)
tree673deb7a166b20c6f33fd3fbcfb7ac43c7a49190 /tools
parent8bb6b5fe05014b7a4057571cfe3bf76594991e8b (diff)
Add a hack to fix false positive 'unused ...' related to use of ..._add_oui().
svn path=/trunk/; revision=47536
Diffstat (limited to 'tools')
-rwxr-xr-xtools/checkhf.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/checkhf.pl b/tools/checkhf.pl
index 238db33c6c..8618f51597 100755
--- a/tools/checkhf.pl
+++ b/tools/checkhf.pl
@@ -125,6 +125,8 @@ while (my $fileName = $ARGV[0]) {
@hfStaticDefs{grep {$hfDefs{$_} == 0} keys %hfDefs} = (); # All values in the new hash will be undef
$unUsedHRef = diff_hash(\%hfStaticDefs, \%hfUsage);
+ remove_hf_pid_from_unused_if_add_oui_call(\$fileContents, $fileName, $unUsedHRef);
+
print_list("Unused entry: $fileName, ", $unUsedHRef);
# 2. Are all the hfDefs entries (static and global) in hfArrayEntries ?
@@ -477,6 +479,36 @@ sub find_hf_usage {
}
# ---------------------------------------------------------------------
+# action: Remove from 'unused' hash an instance of a variable named hf_..._pid
+# if the source has a call to llc_add_oui() or ieee802a_add_oui().
+# (This is rather a bit of a hack).
+# arga: codeRef, fileName, unUsedHRef
+
+sub remove_hf_pid_from_unused_if_add_oui_call {
+ my ($codeRef, $fileName, $unUsedHRef) = @_;
+
+ if ((keys %$unUsedHRef) == 0) {
+ return;
+ }
+
+ my @hfvars = grep { / ^ hf_ [a-zA-Z0-9_]+ _pid $ /xo} keys $unUsedHRef;
+
+ if ((@hfvars == 0) || (@hfvars > 1)) {
+ return; # if multiple unused hf_..._pid
+ }
+
+ if ($$codeRef !~ / llc_add_oui | ieee802a_add_oui /xo) {
+ return;
+ }
+
+ # hf_...pid unused var && a call to ..._add_oui(); delete entry from unused
+ # XXX: maybe hf_..._pid should really be added to hfUsed ?
+ delete @$unUsedHRef{@hfvars};
+
+ return;
+}
+
+# ---------------------------------------------------------------------
sub debug_print_hash {
my ($title, $HRef) = @_;