From patchwork Thu Nov 9 01:10:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 118356 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5975586qgn; Wed, 8 Nov 2017 17:10:53 -0800 (PST) X-Google-Smtp-Source: ABhQp+Rhubv5PFV5ak5/N9Tou4UpOOqkxz999qt5urqzMvDhhMEaUCU+Tj6l5D9T+xvEQlRCGr8W X-Received: by 10.99.96.129 with SMTP id u123mr2187553pgb.406.1510189852968; Wed, 08 Nov 2017 17:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510189852; cv=none; d=google.com; s=arc-20160816; b=F9ipaGx5uLoC8EGQn9g76Ch+GjNexSk+k3Zl+KRLC/fXG6HWlZOZdpZPtlWAobEx31 guHBSbwJgi02JJvpsWzGNYOJleEfj3t3piYeIhI99nljdTju6jRKl0Nj/HdJtco387TW sOgMY6n4zwDfpLxMf2HsT2wlYwe5byuMEl0ok06LLfc7nphUz233NxUaqxwUOIbQdilL hqgKJbltB/tjjiBMciAgtoJy56Cu7IOUToNrzg6vwk/bLEWY6FGvAOP2+nd8/Yx8ZdNC qUWnYm7n2xXWXotRVmUfEWkKLnMK0GLhd23fgFYaQnIV8cXGI5xNDXR3a5qXQciBsyc0 DUOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GQouYXgIUa9MJRY+Q4hDlUR1xV+MBISlT3eeCeZ/xVk=; b=hjfOjDe9ZfWvSYxAbu1sNjRIirG+tjip2dAZeCEpUiVILiFnIP9XJBvoVYfKkil2V8 r9dbBGDxrhLfc+7uFU3VPw05uQfSqcAJow73A9BiZqogbQ/c/DqOALme2QKYlvU3Xfer Ixit/7ThSGEYPtLXJ9VYVk2F1Zot2UZL7YzLjpFfL66Ahr0cnj+7B8yjGMMaLJp903S0 s0IUQenmWpDw2u2qBG3edCOKTZDMgUs4FInH6RFupHGJ1oefKODlzduVCcYTzFiC1nJT 2ke5DreDilkjEzpNj94WycXyvJQHHdcmobAtQrXMTtQVgy/J3P+wvApHiTOECtSIswOA mzuQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34si4922287pln.732.2017.11.08.17.10.52; Wed, 08 Nov 2017 17:10:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752892AbdKIBKu (ORCPT + 27 others); Wed, 8 Nov 2017 20:10:50 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:46983 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751566AbdKIBKt (ORCPT ); Wed, 8 Nov 2017 20:10:49 -0500 Received: by mail-ot0-f196.google.com with SMTP id o9so3992837ota.3 for ; Wed, 08 Nov 2017 17:10:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GQouYXgIUa9MJRY+Q4hDlUR1xV+MBISlT3eeCeZ/xVk=; b=kNfB8VsajKd7cMS358JEFXDFb3l2wXnZ9rxPUfl/JBbxB9gEMzsIdMi4PA1tLWzNLf K2zhdAFdcXJTuPnf9XjlBVXvBNHbR7YHuNv4zWTD4ItKoMnVcn09h7AoNqfsrrj0zKXY dwQoVGzZgI5dbcpyJLkVu5jStDMsLuBE1D4l+xXBCbFjQRdIUunpaQSo+sQooDptQFXz 4Hw/z2nVlZjsaT089jhTuJ6kCKpfO6L4GvYMCgoI45S30Wy05kBHrPo+79cuNYoiD3e6 D2/FIn0Vav7fr+XTy+eMf2x7cmCPqhzjTDLtM+3d6KtAY5LVfQtf1V5TdNGh0RhLjxQJ 3oNQ== X-Gm-Message-State: AJaThX78TBZg5XbcyyHCsUSFuRtlmEJlbqGHlykzoMg7YjTpJ0QkgUBh /XTjLMkXtlVoGqfs48DiK3vCbkY= X-Received: by 10.157.48.158 with SMTP id s30mr1509366otc.497.1510189848513; Wed, 08 Nov 2017 17:10:48 -0800 (PST) Received: from xps15.herring.priv (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id d42sm2637197ote.45.2017.11.08.17.10.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 17:10:48 -0800 (PST) From: Rob Herring To: linux-kernel@vger.kernel.org Cc: Andy Whitcroft , Joe Perches , Greg Kroah-Hartman Subject: [PATCH] checkpatch.pl: Add SPDX license tag check Date: Wed, 8 Nov 2017 19:10:47 -0600 Message-Id: <20171109011047.20040-1-robh@kernel.org> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a check warning if SPDX-License-Identifier tags are not used in newly added files. Cc: Andy Whitcroft Cc: Joe Perches Cc: Greg Kroah-Hartman Signed-off-by: Rob Herring --- I rewrote my previous version to check more than just dts files. It also now looks for a tag in added files rather than trying a fuzzy match on freeform license text. scripts/checkpatch.pl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.14.1 diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8b80bac055e4..6665735123e5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2185,6 +2185,8 @@ sub process { my $commit_log_has_diff = 0; my $reported_maintainer_file = 0; my $non_utf8_charset = 0; + my $added_file = 0; + my $missing_spdx_license = 0; my $last_blank_line = 0; my $last_coalesced_string_linenr = -1; @@ -2368,6 +2370,16 @@ sub process { $here = "#$linenr: " if (!$file); $here = "#$realline: " if ($file); + # determine if this is a new file + if ($line =~ m@^\-\-\-\s/@) { + if ($line =~ m@/dev/null@) { + $added_file = 1; + $missing_spdx_license++; + } else { + $added_file = 0; + } + } + my $found_file = 0; # extract the filename as it passes if ($line =~ /^diff --git.*?(\S+)$/) { @@ -2865,6 +2877,14 @@ sub process { } } +# check for using SPDX tag instead of free form license text + if ($added_file && + ($rawline =~ /\bSPDX-License-Identifier/ || + $realfile =~ /Documentation/)) { + $missing_spdx_license--; + $added_file = 0; + } + # check we are in a valid source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/); @@ -6399,6 +6419,11 @@ sub process { "Missing Signed-off-by: line(s)\n"); } + if ($missing_spdx_license) { + WARN("SPDX_LICENSE_TAG", + "Missing SPDX-License-Identifier tags in added files. Use tags instead of full license text.\n"); + } + print report_dump(); if ($summary && !($clean == 1 && $quiet == 1)) { print "$filename " if ($summary_file);