All of lore.kernel.org
 help / color / mirror / Atom feed
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
Subject: [Qemu-devel] [PATCH v2 3/4] checkpatch: check trace-events code style
Date: Sat, 29 Jul 2017 16:11:58 +0300	[thread overview]
Message-ID: <20170729131159.24949-4-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20170729131159.24949-1-vsementsov@virtuozzo.com>

Accordingly 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>
---
 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

  parent reply	other threads:[~2017-07-29 13:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-29 13:11 [Qemu-devel] [PATCH v2 0/4] trace-events: print 0x before hex numbers Vladimir Sementsov-Ogievskiy
2017-07-29 13:11 ` [Qemu-devel] [PATCH v2 1/4] coding_style: add point about 0x in trace-events Vladimir Sementsov-Ogievskiy
2017-07-31  9:19   ` Stefan Hajnoczi
2017-07-31 12:45     ` Eric Blake
2017-07-29 13:11 ` [Qemu-devel] [PATCH v2 2/4] trace-events: fix code style: %# -> 0x% Vladimir Sementsov-Ogievskiy
2017-07-31  9:24   ` Stefan Hajnoczi
2017-07-31 12:48   ` Eric Blake
2017-07-29 13:11 ` Vladimir Sementsov-Ogievskiy [this message]
2017-07-31  9:26   ` [Qemu-devel] [PATCH v2 3/4] checkpatch: check trace-events code style Stefan Hajnoczi
2017-07-31 12:48     ` Eric Blake
2017-07-29 13:11 ` [Qemu-devel] [PATCH v2 4/4] trace-events: fix code style: print 0x before hex numbers Vladimir Sementsov-Ogievskiy
2017-07-31  9:36   ` Stefan Hajnoczi
2017-07-31  9:49   ` Cornelia Huck
2017-07-31 15:05     ` Vladimir Sementsov-Ogievskiy
2017-07-31 15:38       ` Cornelia Huck
2017-07-29 13:32 ` [Qemu-devel] [PATCH v2 0/4] trace-events: " no-reply

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=20170729131159.24949-4-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=berrange@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.