aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-04-03 17:42:54 -0400
committerMichael Mann <mmann78@netscape.net>2014-04-14 00:10:20 +0000
commit0a5572ea77aff392c7925b8ce30c15327c8d28cc (patch)
tree006767092db788eb77357a619beb1bf3fab6814f /tools
parentf532fb94fc1478061e94c98423079b74269967f3 (diff)
Fix Bug 9951: 'git commit hook isn't calling checkAPIs.pl with arguments for the dissectors'
I recently made a change to packet-rtp.c and inappropriately included g_error() in it, which the builbots caught during their run of checkAPIs.pl. But checkAPIs.pl is supposed to catch such things for us before we submit, by being invoked in the git pre-commit hook. Apparently though, buildbots call checkAPIs.pl with extra arguments for different cases... and for packet dissectors it calls it with a '-g abort' argument, which is how it caught the g_error. So the "bug" is that the pre-commit hook should invoke checAPIs.pl with that argument too, for epan/dissectors/packet-*.c files. Change-Id: Ie8f9dcc55f2248918208dea85a04f67e6bf9829a Reviewed-on: https://code.wireshark.org/review/953 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/checkAPIs.pl14
-rwxr-xr-xtools/pre-commit2
2 files changed, 15 insertions, 1 deletions
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index 1335bdd69c..17750194d8 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -1860,6 +1860,7 @@ sub print_usage
print " [--nocheck-addtext] [--nocheck-hf] [--debug] file1 file2 ...\n";
print "\n";
print " -M: Generate output for -g in 'machine-readable' format\n";
+ print " -p: used by the git pre-commit hook\n";
print " -h: help, print usage message\n";
print " -g <group>: Check input files for use of APIs in <group>\n";
print " (in addition to the default groups)\n";
@@ -2000,6 +2001,7 @@ my $check_addtext = 1; # default: enabled
my $debug_flag = 0; # default: disabled
my $buildbot_flag = 0;
my $help_flag = 0;
+my $pre_commit = 0;
my $result = GetOptions(
'group=s' => \@apiGroups,
@@ -2010,6 +2012,7 @@ my $result = GetOptions(
'check-addtext!' => \$check_addtext,
'build' => \$buildbot_flag,
'debug' => \$debug_flag,
+ 'pre-commit' => \$pre_commit,
'help' => \$help_flag
);
if (!$result || $help_flag) {
@@ -2017,6 +2020,17 @@ if (!$result || $help_flag) {
exit(1);
}
+# the pre-commit hook only calls checkAPIs one file at a time, so this
+# is safe to do globally (and easier)
+if ($pre_commit) {
+ my $filename = $ARGV[0];
+ # if the filename is packet-*.c or packet-*.h, then we set the abort and termoutput groups.
+ if ($filename =~ /\bpacket-\w+\.[ch]$/) {
+ push @apiGroups, "abort";
+ push @apiGroups, "termoutput";
+ }
+}
+
# Add a 'function_count' anonymous hash to each of the 'apiGroup' entries in the %APIs hash.
for my $apiGroup (keys %APIs) {
my @functions = @{$APIs{$apiGroup}{functions}};
diff --git a/tools/pre-commit b/tools/pre-commit
index 89afabc3e9..55b9c9c96d 100755
--- a/tools/pre-commit
+++ b/tools/pre-commit
@@ -21,7 +21,7 @@ for FILE in `git diff-index --cached --name-only HEAD | grep "\.[ch]$"` ; do
./tools/checkhf.pl $FILE
#Check if checkAPIs is good
- ./tools/checkAPIs.pl $FILE
+ ./tools/checkAPIs.pl -p $FILE
#Check if fix-encoding-args is good
./tools/fix-encoding-args.pl $FILE