From patchwork Mon Jul 16 12:39:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Gouders X-Patchwork-Id: 10526659 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 05DB3601D2 for ; Mon, 16 Jul 2018 12:39:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E847828418 for ; Mon, 16 Jul 2018 12:39:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC9F628A49; Mon, 16 Jul 2018 12:39:50 +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 235CF28418 for ; Mon, 16 Jul 2018 12:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728758AbeGPNHF (ORCPT ); Mon, 16 Jul 2018 09:07:05 -0400 Received: from services.gouders.net ([141.101.32.176]:36140 "EHLO services.gouders.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728437AbeGPNHF (ORCPT ); Mon, 16 Jul 2018 09:07:05 -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 w6GCdRnG011181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 16 Jul 2018 14:39:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gouders.net; s=gnet; t=1531744778; bh=Pp7yxRotF0kC0fYRR8X3GkFpaswQe84KPuVwD7sYPxw=; h=From:To:Cc:Subject:Date; b=UiGZcpN/Q9vBniot+WReOrW52b8JdHvMXog+aa/k5yAL+Jc2vw7E4E9mwlkBY6428 lFViJt/Eagu+4xRO9O0Jr9erJldlRGBwoqMXTlUslGt9OQDp5lzq4xaXfTvJGH6/S4 h5OtMH7pJn1YFiWcu7JBIrh7m7bXHF3TXPHppioE= From: Dirk Gouders To: Andy Whitcroft , Joe Perches Cc: Dirk Gouders , Masahiro Yamada , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: if_changed: check for multiple calls in targets Date: Mon, 16 Jul 2018 14:39:02 +0200 Message-Id: <20180716123902.5337-1-dirk@gouders.net> X-Mailer: git-send-email 2.16.1 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 Because the kbuild function if_changed writes the command line to a .cmd file for later tests, multiple calls of that function within a target would result in overwrites of previous values and effectively render the command line test meaningless, resulting in flip-flop behaviour. Produce an error for targets with multiple calls to if_changed. Three examples that would now 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) Suggested-by: Masahiro Yamada Signed-off-by: Dirk Gouders --- scripts/checkpatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 447857ffaf6b..b0aadf23148e 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\$\(call if_changed,/) && + ($line =~ /^[ +]\t\$\(call 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*\"/) ||