Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753494AbbDGTh0 (ORCPT ); Tue, 7 Apr 2015 15:37:26 -0400 Received: from seldrel01.sonyericsson.com ([212.209.106.2]:9410 "EHLO seldrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbbDGThY (ORCPT ); Tue, 7 Apr 2015 15:37:24 -0400 From: Bjorn Andersson To: Andy Whitcroft , Joe Perches CC: Subject: [PATCH v2] checkpatch: validate MODULE_LICENSE content Date: Tue, 7 Apr 2015 12:37:20 -0700 Message-ID: <1428435440-17092-1-git-send-email-bjorn.andersson@sonymobile.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1428365822.20888.11.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1719 Lines: 56 There is a well defined list of expected values for MODULE_LICENSE so warn the user upon usage of unknown values. Signed-off-by: Bjorn Andersson --- Thanks for the review Joe! "Proprietary" is in the list because this is the full list of "valid" values mentioned in include/linux/module.h. So it's the list of licenses valid for submission, but rather the list of valid values. Changes since v1: - Fixed nits pointed out by Joe - Added comment to clarify the purpose, as well as origin of the values scripts/checkpatch.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9a8b2bd..ca10d79 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5431,6 +5431,24 @@ sub process { } } } + +# validate content of MODULE_LICENSE against list from include/linux/module.h + if ($line =~ /\bMODULE_LICENSE\s*\(\s*($String)\s*\)/) { + my $extracted_string = get_quoted_string($line, $rawline); + my $valid_licenses = qr{ + GPL| + GPL\ v2| + GPL\ and\ additional\ rights| + Dual\ BSD/GPL| + Dual\ MIT/GPL| + Dual\ MPL/GPL| + Proprietary + }x; + if ($extracted_string !~ /^"(?:$valid_licenses)"$/x) { + WARN("MODULE_LICENSE", + "unknown module license " . $extracted_string . "\n" . $herecurr); + } + } } # If we have no input at all, then there is nothing to report on -- 1.8.2.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/