aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2017-07-31 19:01:34 +0300
committerStefan Hajnoczi <stefanha@redhat.com>2017-08-01 12:13:07 +0100
commitc3e5875afc0f93315470dfa5f31251fb9546c267 (patch)
tree311cf98ce7fd7dc249cfa1b7e198b1e98119eef4 /scripts
parentdb73ee4bc8861f9f6772e0d24f978d79e50e8dee (diff)
downloadqemu-c3e5875afc0f93315470dfa5f31251fb9546c267.zip
qemu-c3e5875afc0f93315470dfa5f31251fb9546c267.tar.gz
qemu-c3e5875afc0f93315470dfa5f31251fb9546c267.tar.bz2
checkpatch: check trace-events code style
According to CODING_STYLE, check that in trace-events: 1. hex numbers are prefixed with '0x' 2. '#' flag of printf is not used 3. The exclusion from 1. are period-separated groups of numbers Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20170731160135.12101-4-vsementsov@virtuozzo.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4e91122..fa47807 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1337,6 +1337,25 @@ sub process {
$rpt_cleaners = 1;
}
+# checks for trace-events files
+ if ($realfile =~ /trace-events$/ && $line =~ /^\+/) {
+ if ($rawline =~ /%[-+ 0]*#/) {
+ ERROR("Don't use '#' flag of printf format ('%#') in " .
+ "trace-events, use '0x' prefix instead\n" . $herecurr);
+ } else {
+ my $hex =
+ qr/%[-+ *.0-9]*([hljztL]|ll|hh)?(x|X|"\s*PRI[xX][^"]*"?)/;
+
+ # don't consider groups splitted by [.:/ ], like 2A.20:12ab
+ my $tmpline = $rawline =~ s/($hex[.:\/ ])+$hex//gr;
+
+ if ($tmpline =~ /(?<!0x)$hex/) {
+ ERROR("Hex numbers must be prefixed with '0x'\n" .
+ $herecurr);
+ }
+ }
+ }
+
# check we are in a valid source file if not then ignore this hunk
next if ($realfile !~ /\.(h|c|cpp|s|S|pl|py|sh)$/);