From patchwork Fri Jul 20 07:48:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Gouders X-Patchwork-Id: 10536135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 75473604D3 for ; Fri, 20 Jul 2018 07:48:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 626F22903B for ; Fri, 20 Jul 2018 07:48:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 567712904C; Fri, 20 Jul 2018 07:48:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00, DKIM_ADSP_DISCARD, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 268E42903B for ; Fri, 20 Jul 2018 07:48:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728207AbeGTIfi (ORCPT ); Fri, 20 Jul 2018 04:35:38 -0400 Received: from services.gouders.net ([141.101.32.176]:54496 "EHLO services.gouders.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727141AbeGTIfi (ORCPT ); Fri, 20 Jul 2018 04:35:38 -0400 Received: from lena.gouders.net ([193.175.198.193]) (authenticated bits=0) by services.gouders.net (8.14.8/8.14.8) with ESMTP id w6K7mGpI031540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 20 Jul 2018 09:48:27 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gouders.net; s=gnet; t=1532072908; bh=RC4mWJZYhMl7JHiAjT75Qx//tBV/boReNxyhISHoMpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YKKPLOcY2E80z9PPM/4YD/X3m451h/l/A28KuPSVLT4Rz+l1blBeu823sE9C2P31k dDoWoNIHfC2TOqBLeXNpnSfehanM5blHOYbz37/SBg1Vacaiun9VXNpTawt2xi1UNu FSytM3hjhbd46oKP0tIPV1bJ5Hn5dRtlL47shfXw= From: Dirk Gouders To: Joe Perches Cc: Dirk Gouders , Andy Whitcroft , Masahiro Yamada , 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 Message-Id: <20180720074804.4160-1-dirk@gouders.net> X-Mailer: git-send-email 2.16.1 In-Reply-To: References: Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Suggested-by: Masahiro Yamada Signed-off-by: Dirk Gouders --- 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*\"/) ||