mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dirk Gouders <dirk@gouders.net>
To: Joe Perches <joe@perches.com>
Cc: Dirk Gouders <dirk@gouders.net>,
	Andy Whitcroft <apw@canonical.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] checkpatch: kbuild: if_changed: check for multiple calls in targets
Date: Fri, 20 Jul 2018 09:48:04 +0200	[thread overview]
Message-ID: <20180720074804.4160-1-dirk@gouders.net> (raw)
In-Reply-To: <ghy3eafbrf.fsf@lena.gouders.net>

The kbuild function if_changed should not be called more than once for
a target.

Because that function writes the command line to a .cmd file for later
tests, multiple calls of it within a target would result in overwrites
of previous values and effectively render the command line test
meaningless, resulting in flip-flop behaviour.

Add a check for makefiles and kbuild files and produce an error for
targets with multiple calls to if_changed.

Three examples that now could be detected:

98f78525371b55ccd (x86/boot: Refuse to build with data relocations)
6a8dfe1cac5c591ae (microblaze: support U-BOOT image format)
684151a75bf25f5ae (sparc32: added U-Boot build target: uImage)

Reviewed-by: Joe Perches <joe@perches.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Dirk Gouders <dirk@gouders.net>
---
v2: rework commit message and regular expression
---
 scripts/checkpatch.pl | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 447857ffaf6b..437e98414f74 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2911,6 +2911,14 @@ sub process {
 			     "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
 		}
 
+		# Check for multiple calls of if_changed within a target in Makefiles
+		if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
+		    ($prevline =~ /^[ +]\t\s*\$\(call\s+if_changed,/) &&
+		    ($line =~ /^[ +]\t\s*\$\(call\s+if_changed,/)) {
+				ERROR("MULTIPLE_IF_CHANGED",
+				      "Multiple calls of if_changed within a target.\n" . $herecurr);
+		}
+
 # check for DT compatible documentation
 		if (defined $root &&
 			(($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||
-- 
2.16.1


  reply	other threads:[~2018-07-20  7:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 12:39 [PATCH] checkpatch: " Dirk Gouders
2018-07-16 15:23 ` Joe Perches
2018-07-17  9:32   ` Dirk Gouders
2018-07-20  7:48     ` Dirk Gouders [this message]
2018-07-20 10:06       ` [PATCH v2] checkpatch: kbuild: " Joe Perches
2018-07-20 15:21         ` Segher Boessenkool
2018-07-20 15:33           ` Joe Perches
2018-07-20 15:44             ` Segher Boessenkool

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=20180720074804.4160-1-dirk@gouders.net \
    --to=dirk@gouders.net \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yamada.masahiro@socionext.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

all inboxes | Powered by JetHome®