From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, eblake@redhat.com, mreitz@redhat.com,
jsnow@redhat.com, vsementsov@virtuozzo.com, den@openvz.org,
stefanha@gmail.com, peter.maydell@linaro.org,
berrange@redhat.com, cohuck@redhat.com
Subject: [Qemu-devel] [PATCH v3 3/4] checkpatch: check trace-events code style
Date: Mon, 31 Jul 2017 19:01:34 +0300 [thread overview]
Message-ID: <20170731160135.12101-4-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20170731160135.12101-1-vsementsov@virtuozzo.com>
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>
---
scripts/checkpatch.pl | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4e91122813..fa478074b8 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)$/);
--
2.11.1
next prev parent reply other threads:[~2017-07-31 16:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-31 16:01 [Qemu-devel] [PATCH v3 0/4] trace-events: print 0x before hex numbers Vladimir Sementsov-Ogievskiy
2017-07-31 16:01 ` [Qemu-devel] [PATCH v3 1/4] coding_style: add point about 0x in trace-events Vladimir Sementsov-Ogievskiy
2017-07-31 16:07 ` Eric Blake
2017-07-31 16:01 ` [Qemu-devel] [PATCH v3 2/4] trace-events: fix code style: %# -> 0x% Vladimir Sementsov-Ogievskiy
2017-07-31 16:15 ` Eric Blake
2017-07-31 16:40 ` Vladimir Sementsov-Ogievskiy
2017-07-31 16:01 ` Vladimir Sementsov-Ogievskiy [this message]
2017-07-31 16:01 ` [Qemu-devel] [PATCH v3 4/4] trace-events: fix code style: print 0x before hex numbers Vladimir Sementsov-Ogievskiy
2017-07-31 16:25 ` [Qemu-devel] [PATCH v3 0/4] trace-events: " no-reply
2017-08-01 9:47 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170731160135.12101-4-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=berrange@redhat.com \
--cc=cohuck@redhat.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).