qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Claudio Fontana <cfontana@suse.de>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org, "Claudio Fontana" <cfontana@suse.de>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: [RFC v2] checkpatch: detect missing changes to trace-events
Date: Fri,  7 Aug 2020 13:14:47 +0200	[thread overview]
Message-ID: <20200807111447.15599-1-cfontana@suse.de> (raw)

Signed-off-by: Claudio Fontana <cfontana@suse.de>
---
 scripts/checkpatch.pl | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

v1 -> v2 :

* track the "from" file in addition to the "to" file,
  and grep into both (if they exist), looking for trace.h, trace-root.h

  If files are reachable and readable, emit a warning if there is no
  update to trace-events.


diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bd3faa154c..37db212fc6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1300,6 +1300,7 @@ sub process {
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
 	my $reported_maintainer_file = 0;
+	my $reported_trace_events_file = 0;
 	my $non_utf8_charset = 0;
 
 	our @report = ();
@@ -1309,6 +1310,7 @@ sub process {
 	our $cnt_chk = 0;
 
 	# Trace the real file/line as we go.
+	my $fromfile = '';
 	my $realfile = '';
 	my $realline = 0;
 	my $realcnt = 0;
@@ -1454,10 +1456,15 @@ sub process {
 		$here = "#$realline: " if ($file);
 
 		# extract the filename as it passes
-		if ($line =~ /^diff --git.*?(\S+)$/) {
-			$realfile = $1;
-			$realfile =~ s@^([^/]*)/@@ if (!$file);
+		if ($line =~ /^diff --git.*?(\S+).*?(\S+)$/) {
+			$fromfile = $1;
+			$realfile = $2;
+			if (!$file) {
+				$fromfile =~ s@^([^/]*)/@@ ;
+				$realfile =~ s@^([^/]*)/@@ ;
+			}
 	                checkfilename($realfile, \$acpi_testexpected, \$acpi_nontestexpected);
+
 		} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
 			$realfile = $1;
 			$realfile =~ s@^([^/]*)/@@ if (!$file);
@@ -1470,6 +1477,11 @@ sub process {
 			}
 
 			next;
+
+		} elsif ($line =~ /^---\s+(\S+)/) {
+			$fromfile = $1;
+			$fromfile =~ s@^([^/]*)/@@ if (!$file);
+			next;
 		}
 
 		$here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
@@ -1524,15 +1536,26 @@ sub process {
 		if ($line =~ /^\s*MAINTAINERS\s*\|/) {
 			$reported_maintainer_file = 1;
 		}
-
+# similar check for trace-events
+		if ($line =~ /^\s*trace-events\s*\|/) {
+			$reported_trace_events_file = 1;
+		}
 # Check for added, moved or deleted files
-		if (!$reported_maintainer_file && !$in_commit_log &&
+		if (!$in_commit_log &&
 		    ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
 		     $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
 		     ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
 		      (defined($1) || defined($2))))) {
-			$reported_maintainer_file = 1;
-			WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
+			if (!$reported_maintainer_file) {
+				$reported_maintainer_file = 1;
+				WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
+			}
+			if (!$reported_trace_events_file) {
+				if (`grep -F -s -e trace.h -e trace-root.h ${fromfile} ${realfile}` ne '') {
+					$reported_trace_events_file = 1;
+					WARN("added, moved or deleted file(s), does trace-events need updating?\n" . $herecurr);
+				}
+			}
 		}
 
 # Check for wrappage within a valid hunk of the file
-- 
2.16.4



             reply	other threads:[~2020-08-07 11:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 11:14 Claudio Fontana [this message]
2020-08-07 11:22 ` [RFC v2] checkpatch: detect missing changes to trace-events no-reply
2020-08-12 15:51 ` Stefan Hajnoczi
2020-08-12 16:08   ` Claudio Fontana
2020-09-02 15:14 ` Markus Armbruster
2020-09-02 16:40   ` Claudio Fontana

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=20200807111447.15599-1-cfontana@suse.de \
    --to=cfontana@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).