Received: by 10.223.164.202 with SMTP id h10csp2336475wrb; Thu, 16 Nov 2017 13:26:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMYYuYFJOC+4PAAefnTo01IDnfes3D1kloiZlokIbB+76HpMHBK6k7EAhc50aiQakIQ13OoK X-Received: by 10.84.224.131 with SMTP id s3mr2982266plj.39.1510867616097; Thu, 16 Nov 2017 13:26:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510867616; cv=none; d=google.com; s=arc-20160816; b=QrwSAkJ+CrQGdkyQlnwBb9/GGh8Bx+35w+E9xbe7/tS9/A5DwHyhfN841NuG8qWoIr GNOYrHcdLJ/Uv98o7kon8bc+/U4hsRUkLGDkB1eMA2o2Fi9lpmKqYuyHGBUHIqSnD2zv wkQE3DIEuE+qbt7S+13KZhqLCHFqb2/kGUsSs3oq35lc55BmkinLGCVKE7065IcEH+PP 1jArM0ETV/YhvQivNGEmA952J8m44ZdJ+9ETJ389KUw17KmmyFXwuxP8BUXV9XdVfwuz lNZxAl4MwDdVSzgZw9KA1h/pMdY9TMV52B8IardpOvOvmLrkMw4V68i4dLOYNec0JT9D gJGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:references :in-reply-to:mime-version:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Ymo0m5CvL/VQk/70S037pzCsN7qdfWVeCDM9kWjTXTU=; b=jBX+2GTliLqFu4AhinTWLBuXadOUU5XBCBolhP/9rpbRbphPKHAZTkSskloFNBJIpZ 3+XyZ9z+c6rsoT3LDLCFKVR1Wx3AAQszCw71+FWwYb9DXLZoPqFJomzWmo6gdzEYu0m2 Xu7Nu8w5DL4V2ajXqoIaiu70QsAGLsqaRzQvhSNgk8QKlSOC5iUwTpLT7zK5a4yor01C lEqQ0dqqTLfAl8NJ7JOmbBYJKbEDmbKOcmZRFTOEQyvM0BcWjdySbHl4D6VyQf5RkoWR K/jS3uMx5o+hJ+MUayb+AjHAMYZsDzUHjRwQnoCJhTcNy4d9SPA7rxEL+qJ+eHjfK+eE n4yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si1578049pls.500.2017.11.16.13.26.41; Thu, 16 Nov 2017 13:26:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965463AbdKPREA (ORCPT + 92 others); Thu, 16 Nov 2017 12:04:00 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:50863 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936142AbdKPRCb (ORCPT ); Thu, 16 Nov 2017 12:02:31 -0500 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vAGH2OUt000593 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Nov 2017 17:02:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vAGH2OcL019107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Nov 2017 17:02:24 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vAGH2N4M017896; Thu, 16 Nov 2017 17:02:24 GMT Received: from abi.no.oracle.com (/10.172.144.123) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 16 Nov 2017 09:02:23 -0800 From: Knut Omang To: linux-kernel@vger.kernel.org Cc: Knut Omang , Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org Subject: [PATCH 2/7] kbuild: Add P= command line flag to run checkpatch Date: Thu, 16 Nov 2017 18:01:42 +0100 Message-Id: <716fa938a4ab0ad66490b72e2ed750cd6583728f.1510840787.git-series.knut.omang@oracle.com> X-Mailer: git-send-email 2.13.6 MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add interpretation of a new environment variable P={1,2} in spirit of the C= option, but executing checkpatch instead of sparse. Signed-off-by: Knut Omang Reviewed-by: Håkon Bugge Acked-by: Åsmund Østvold --- Makefile | 20 +++++++++++++++++++- scripts/Makefile.build | 13 +++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ccd9818..eb4bca9 100644 --- a/Makefile +++ b/Makefile @@ -176,6 +176,20 @@ ifndef KBUILD_CHECKSRC KBUILD_CHECKSRC = 0 endif +# Run scripts/checkpatch.pl with --ignore-cfg checkpatch.cfg +# +# Use 'make P=1' to enable checking of only re-compiled files. +# Use 'make P=2' to enable checking of *all* source files, regardless +# +# See the file "Documentation/dev-tools/run-checkpatch.rst" for more details, +# +ifeq ("$(origin P)", "command line") + KBUILD_CHECKPATCH = $(P) +endif +ifndef KBUILD_CHECKPATCH + KBUILD_CHECKPATCH = 0 +endif + # Use make M=dir to specify directory of external module to build # Old syntax make ... SUBDIRS=$PWD is still supported # Setting the environment variable KBUILD_EXTMOD take precedence @@ -340,7 +354,7 @@ ifeq ($(MAKECMDGOALS),) endif export KBUILD_MODULES KBUILD_BUILTIN -export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD +export KBUILD_CHECKSRC KBUILD_CHECKPATCH KBUILD_SRC KBUILD_EXTMOD # We need some generic definitions (do not try to remake the file). scripts/Kbuild.include: ; @@ -363,9 +377,12 @@ DEPMOD = /sbin/depmod PERL = perl PYTHON = python CHECK = sparse +CHECKP = scripts/checkpatch.pl CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void $(CF) +CHECKPFLAGS := --quiet --show-types --emacs \ + --ignore-cfg checkpatch.cfg --file $(PF) NOSTDINC_FLAGS = CFLAGS_MODULE = AFLAGS_MODULE = @@ -419,6 +436,7 @@ export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS +export CHECKP CHECKPFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV CFLAGS_KCOV CFLAGS_KASAN CFLAGS_UBSAN diff --git a/scripts/Makefile.build b/scripts/Makefile.build index bb831d4..cfc540a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -109,6 +109,17 @@ ifneq ($(KBUILD_CHECKSRC),0) endif endif +# Run per-directory/per-file specific checkpatch testing: +ifneq ($(KBUILD_CHECKPATCH),0) + ifeq ($(KBUILD_CHECKPATCH),2) + quiet_cmd_force_checkpatch = CHECKP $< + cmd_force_checkpatch = $(srctree)/$(CHECKP) $(POPTS) $< $(CHECKPFLAGS) ; + else + quiet_cmd_checkpatch = CHECKP $< + cmd_checkpatch = $(srctree)/$(CHECKP) $(POPTS) $< $(CHECKPFLAGS) ; + endif +endif + # Do section mismatch analysis for each module/built-in.o ifdef CONFIG_DEBUG_SECTION_MISMATCH cmd_secanalysis = ; scripts/mod/modpost $@ @@ -290,6 +301,7 @@ objtool_dep = $(objtool_obj) \ define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ + $(call echo-cmd,checkpatch) $(cmd_checkpatch) \ $(call cmd_and_fixdep,cc_o_c) \ $(cmd_modversions_c) \ $(call echo-cmd,objtool) $(cmd_objtool) \ @@ -312,6 +324,7 @@ endif # Built-in and composite module parts $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE $(call cmd,force_checksrc) + $(call cmd,force_checkpatch) $(call if_changed_rule,cc_o_c) # Single-part modules are special since we need to mark them in $(MODVERDIR) -- git-series 0.9.1 From 1585216797093825186@xxx Mon Nov 27 11:02:25 +0000 2017 X-GM-THRID: 1585216797093825186 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread