From patchwork Thu Sep 5 19:57:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 11133893 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04A78112B for ; Thu, 5 Sep 2019 19:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7B1B2137B for ; Thu, 5 Sep 2019 19:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567713490; bh=eGJBkaPf3i/03H75Ui1ZA3fc5FWUK4xk+D6etZpFnr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ymD3brummYytlv5q/BtIcfMK+LVyQcXGxVmIxtq52gf9NDKN8QLpaAI/eIoCsRkxq CqulkJV8cdbogzKJuFQdaVjWlgRiwbZLJk3oK3BSHOxHh8z5ZVX6CYrmpmnE+H5Yuy gszSIWW/N1QA07uJZ4zZfd07kHnBoThGLEsMueHU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391585AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58448 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388288AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Gd5Si23CQTkjXHrd1kfDMwHId0XN7lelZ5t8iFh3FtY=; b=BrtD79bFD5K3xtPjdEaW3pbgwz gcZgG8ITxBxpgcjmB/Y3/Kyg5p59py1ioeRWv9FJS0ZHvNUFdVAnipHLDDqvVPEkuxWqda/y38XvD 1NkoueT79wVL4hjNE3RV4zL8do/GSBWYoKVOIV5QtR5Q51hGLQt2H5/qbfbSR5mo60n+zx945n8Gm rYmViAH2APBfgLqGkwkkR6PqpUob4q4KESNWy/4c4XGGC8F7PeGZGPIH5pav/ySV1a9qsEDcpzXf5 J2WKY8+EXWFDTLHjjOqg/JRstUiusjYyDw4wwOzywWF0WOji5Odi5MTtOpWHl0pLP1SPGccDFVB4B qajF/gGA==; Received: from [177.159.253.249] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i5xtF-0000IB-7r; Thu, 05 Sep 2019 19:57:57 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92.1) (envelope-from ) id 1i5xtC-0005m4-Kz; Thu, 05 Sep 2019 16:57:54 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Greg Kroah-Hartman , Joe Perches , linux-kernel@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH 1/6] docs: sphinx: add SPDX header for some sphinx extensions Date: Thu, 5 Sep 2019 16:57:48 -0300 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Those extensions are released under GPLv2, as stated at the :license: markup tag. Add the corresponding SPDX tags for such license. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/kernel_include.py | 1 + Documentation/sphinx/rstFlatTable.py | 1 + 2 files changed, 2 insertions(+) diff --git a/Documentation/sphinx/kernel_include.py b/Documentation/sphinx/kernel_include.py index f523aa68a36b..7aaea4e31f78 100755 --- a/Documentation/sphinx/kernel_include.py +++ b/Documentation/sphinx/kernel_include.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- +# SPDX-License-Identifier: GPL-2.0 # pylint: disable=R0903, C0330, R0914, R0912, E0401 u""" diff --git a/Documentation/sphinx/rstFlatTable.py b/Documentation/sphinx/rstFlatTable.py index 2019a55f6b18..15769d01831b 100755 --- a/Documentation/sphinx/rstFlatTable.py +++ b/Documentation/sphinx/rstFlatTable.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- +# SPDX-License-Identifier: GPL-2.0 # pylint: disable=C0330, R0903, R0912 u""" From patchwork Thu Sep 5 19:57:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 11133891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D03C14B4 for ; Thu, 5 Sep 2019 19:58:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF21620692 for ; Thu, 5 Sep 2019 19:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567713489; bh=mJJv7bKaAYOsFT1lvu/Ibyo80Mbk4EazeWj8qD3RaDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=z6nId1ggJ77zZN6pdot5Y7B+lBA6veIqItNdEAHAfEd0PQ5e/ZqRfjXLjaiW3gTbj 5zjpVEFTRpBdFl0w2GWqrg4wuaxVS+kriifcJq8yFJSPx2bIrfwFXcEmyI6v2Umto9 7HTerH3jjNt8wNL9lSN9u9N26NQmSvoCWiJ7K2qQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391588AbfIET57 (ORCPT ); Thu, 5 Sep 2019 15:57:59 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58456 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388596AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=btp8OApGG/3UFKYYTxwfb9hcf8w0H2Q+kH4+OloUAmQ=; b=Mo0egFykTZYm3jAW18Ny4uIu0/ os3uteHN//gSLMFWyQTtMjcyZ5rPrlhFwny4sc0p/KOc5OKVK5cpC/FcLnfh4Qj0SvCoeITdie5or Kg7Hn7oKL4brXaLz8lZ1wKnTmD2tz0+LrKhJ7FxYw/0ZEcA71LbQMKKzithJbdTEDS2QYorlA2txU dRtRNtkEYQ8jCsSdQMyzDeLq1qBEMf/ZtIYgJyq3rapo8xbxGDjabroWkeoe7MFz4F0AXxEF4r/A3 wVao44R7iYYkrP/Ho6FHoRu/0A0yC7Qqn/f8QFheY3WEJaBmI+1zogti22c2a5R3tYnRwYcuwXkak sGLtS4Nw==; Received: from [177.159.253.249] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i5xtF-0000IF-Ce; Thu, 05 Sep 2019 19:57:57 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92.1) (envelope-from ) id 1i5xtC-0005m8-Lu; Thu, 05 Sep 2019 16:57:54 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Greg Kroah-Hartman , Joe Perches , linux-kernel@vger.kernel.org, Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Armijn Hemel , Allison Randal , Thomas Gleixner Subject: [PATCH 2/6] tools: perf: fix SPDX header in the light of PEP-263 Date: Thu, 5 Sep 2019 16:57:49 -0300 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As stated at PEP-263, the coding tag should be at the first or second line. On those two scripts, the tag is at the wrong line. It also contains a separate e-macs line to tell it to consider the file as a python one. Merge this with the encoding tag, using the same coding line that we're using on other python files. Signed-off-by: Mauro Carvalho Chehab --- tools/perf/python/tracepoint.py | 3 +-- tools/perf/python/twatch.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/perf/python/tracepoint.py b/tools/perf/python/tracepoint.py index eb76f6516247..b7717b501fd8 100755 --- a/tools/perf/python/tracepoint.py +++ b/tools/perf/python/tracepoint.py @@ -1,7 +1,6 @@ #! /usr/bin/python +# -*- coding: utf-8; mode: python -*- # SPDX-License-Identifier: GPL-2.0 -# -*- python -*- -# -*- coding: utf-8 -*- import perf diff --git a/tools/perf/python/twatch.py b/tools/perf/python/twatch.py index ff87ccf5b708..a95e59373ebd 100755 --- a/tools/perf/python/twatch.py +++ b/tools/perf/python/twatch.py @@ -1,7 +1,6 @@ #! /usr/bin/python +# -*- coding: utf-8; mode: python -*- # SPDX-License-Identifier: GPL-2.0-only -# -*- python -*- -# -*- coding: utf-8 -*- # twatch - Experimental use of the perf python interface # Copyright (C) 2011 Arnaldo Carvalho de Melo # From patchwork Thu Sep 5 19:57:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 11133897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96A5114B4 for ; Thu, 5 Sep 2019 19:58:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 475DA20870 for ; Thu, 5 Sep 2019 19:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567713498; bh=kmwjHPFU1JbSFrNJzH99A3LUKqJd2p+4I7VkSc68g0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kLCdAsCf5MqVLHk259zRivSsvHCtevJMO+GxePuMFOBZ9BVXAAiCIM/V84XmeKKpC fJp/2+dFmOiR2gIaB+lUWPmiTdjtSxj3+cug7RiSk2sJaMuSmcGPavKhpovwvKgSPV lM1qzq6ioh6hv2+PYLe18/puZwCqUksSWKK4Qe2Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391580AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58454 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388357AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Es/zISrtwllZAcTDfnj7OAQJAy+Bnf95m2mw7+BsncA=; b=cRUQgJXyebsUtHonyp0KxzifBH WglPXPcpQ/tfLzvGpVcV8nitEA4RYBci9KhrGdaTMBQuneXeGyrnRlpEpTOncpRDfrdZ+xQgdDaUG IEj53CSxz0Q7OmCTXdW1YlexxFQQzsFLCj6gHmxBIWo7Uglgt/ipRI0JSwesg9s2ATpAd9R547Gwa eLPNjxXk2XEt/GCA5PP430YL2f+mUGJsG17K/tRohChOHwTgggbb6dbPwmKvUOEPvrzQJ6as2QlfM jb0yhBWgB1+RumQLT8g/yLeXKx5GMt2EdNyq8V+NPU41Ab8WWH1IISteSEv9wQ/Y46uwaNILtNRO7 BLPrG5KQ==; Received: from [177.159.253.249] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i5xtF-0000IE-CY; Thu, 05 Sep 2019 19:57:57 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92.1) (envelope-from ) id 1i5xtC-0005mC-Mj; Thu, 05 Sep 2019 16:57:54 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Greg Kroah-Hartman , Joe Perches , linux-kernel@vger.kernel.org, Jonathan Corbet , Doug Smythies , "Rafael J. Wysocki" , Allison Randal , Thomas Gleixner Subject: [PATCH 3/6] tools: intel_pstate_tracer.py: fix SPDX header in the light of PEP-263 Date: Thu, 5 Sep 2019 16:57:50 -0300 Message-Id: <51e941b6b028ed619dfa93e29ab0c2930050af5b.1567712829.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As stated at PEP-263, the coding tag should be at the first or second line. On those two scripts, the tag is at the wrong line. Place it at the right place and use the same kind of line that we're using on other python scripts that also work fine with emacs. Signed-off-by: Mauro Carvalho Chehab --- tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py index 2d6d342b148f..1009be489f9a 100755 --- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py +++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py @@ -1,6 +1,6 @@ #!/usr/bin/python +# -*- coding: utf-8; mode: python -*- # SPDX-License-Identifier: GPL-2.0-only -# -*- coding: utf-8 -*- # """ This utility can be used to debug and tune the performance of the intel_pstate driver. This utility can be used in two ways: From patchwork Thu Sep 5 19:57:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 11133903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 626EB14B4 for ; Thu, 5 Sep 2019 19:58:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1332D20CC7 for ; Thu, 5 Sep 2019 19:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567713510; bh=FM76sK1BeWDS2lV+QlGP7EfkJLzR+yGBWlteGpGZ/4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ye47vH4rtQxJ6bq7/kJAJWXFh2RKjcYzLkHyCIx6ZUZiFvKS1pvL+tqN/L0I8VTfk ctk4FM2bbEJ+qxd4r30Rr2gfa4PEm7dy6DS8VSLf5nqyjoNlt/bmwR1fDVeCIh1naL G2WcFwMcNxUO6ZR1Fw9RVdij1/3VafM+xL0DDJH4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389208AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58444 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728262AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Nq0/AIfadmx52mPl01oTaYnDgOBbCeLTbcoEAfHL7Zg=; b=P0VyW60vKrlgkIq79p4R03w8gf D9QfNlomgkxG2Cr+83PxymCjoetMrZOfaLhcUyW7gwmZefv1Ep6tAmRUzXmsYX2F9cSCzf6VY3fa3 zhLtjFyF1TV5QbXZUMSTpXITid8E/0DsIqVSjo4MJC/fz9tYcTKtGcjczfU2Z32CNM2eK1SVHpctY Lu61SKIZ1QQhvQ8jez38uUTtGXrbEDtIHEo0+Djys6D1s4xt6jLWkTHZvLpQpSNIallR0jn8G85uu yrUUdk1VDRPBrdieFq0IRYIwQZWTkALicLLVAcDcdrQnpKs2Y+5LhorQtAwFAopOPMIS6KH4cQyVm YKtTA2eg==; Received: from [177.159.253.249] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i5xtF-0000IC-B2; Thu, 05 Sep 2019 19:57:57 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92.1) (envelope-from ) id 1i5xtC-0005mG-NY; Thu, 05 Sep 2019 16:57:54 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Greg Kroah-Hartman , Joe Perches , linux-kernel@vger.kernel.org, Jonathan Corbet , Federico Vaga , Thomas Gleixner , linux-doc@vger.kernel.org Subject: [PATCH 4/6] docs: license-rules.txt: cover SPDX headers on Python scripts Date: Thu, 5 Sep 2019 16:57:51 -0300 Message-Id: <9dfa708fea2f9df22fa9df60dff0b3152241af8d.1567712829.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The author of the license-rules.rst file wanted to be very restrict with regards to the location of the SPDX header. It says that the SPDX header "shall be added at the first possible line in a file which can contain a comment". Not happy with this already restrictive requiement, it goes further: "For the majority of files this is the first line, except for scripts", opening an exception to have the SPDX header at the second line, if the first line starts with "#!". Well, it turns that this is too restrictive for Python scripts, and may cause regressions if this would be enforced. As mentioned on: https://stackoverflow.com/questions/728891/correct-way-to-define-python-source-code-encoding Python's PEP-263 [1] dictates that an script that needs to default to UTF-8 encoding has to follow this rule: 'Python will default to ASCII as standard encoding if no other encoding hints are given. To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file' And: 'More precisely, the first or second line must match the following regular expression: ^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)' [1] https://www.python.org/dev/peps/pep-0263/ If a script has both "#!" and the charset encoding line, we can't place a SPDX tag without either violating license-rules.rst or breaking the script by making it crash with non-ASCII characters. So, add a sort notice saying that, for Python scripts, the SPDX header may be up to the third line, in order to cover the case where both "#!" and "# .*coding.*UTF-8" lines are found. Signed-off-by: Mauro Carvalho Chehab --- Documentation/process/license-rules.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/process/license-rules.rst b/Documentation/process/license-rules.rst index 2ef44ada3f11..5d23e3498b1c 100644 --- a/Documentation/process/license-rules.rst +++ b/Documentation/process/license-rules.rst @@ -64,9 +64,12 @@ License identifier syntax possible line in a file which can contain a comment. For the majority of files this is the first line, except for scripts which require the '#!PATH_TO_INTERPRETER' in the first line. For those scripts the SPDX - identifier goes into the second line. + identifier goes into the second line\ [1]_. -| +.. [1] Please notice that Python scripts may also need an encoding rule + as defined on PEP-263, which should be defined either at the first + or the second line. So, for such scripts, the SPDX identifier may + go up to the third line. 2. Style: From patchwork Thu Sep 5 19:57:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 11133899 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 144DF112B for ; Thu, 5 Sep 2019 19:58:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7E9120870 for ; Thu, 5 Sep 2019 19:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567713498; bh=4tD/3m4+ACwtWwJ5nq8/462PLH5hGfV1UFx4WLgnz6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FyKkHfK2S/gmzLY0cFmnh7/CJCo89Ng0IP2KW6jg4H2PavBXu1eCRR3Ja50ONHalO d9EXWIT9YMt52WjtHCei0J+9aUkrPkm9vmMXUrf4YesaHCC2E9mMu5coGJ7mRGEJqp MzpI7Y2W+CV9ikmmJoFQqivgCXVctRT2vOSWAoOA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391620AbfIET6R (ORCPT ); Thu, 5 Sep 2019 15:58:17 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58474 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389054AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hjTNA3WcjVQ1uVRvCaEO2GNT0hn8OZTUbCOvEeEU8T0=; b=PeK9oXTeWZIh4q39Lc0Fzifyff Vomz2Nj7gjmbp+rqmEckZ6W1mQRiPm1kkimuh3rjPZK7SU2tGXFXdqSxVuvrsw637KDqx/FjlMxOk ABurgBaVqeALu7Wu0T7wdxNx0IDngBYOtL4rN1C9KsPN1b6ScKcTMdcspMsuOwrLbtLFi8wj1TRnA p0SY9njUWHuFDtU5HA13uK+FzMchk4sLgG4IhZIOop+yUWpYF5ra7K2y/4byTDv4YKS7NB5FovOyN K0TWcyk20eMsVZtmvhQMtiAfcHRfBgEpXzlkIe8Rv6aNkUQpUBJL1VO0NXb0RQMoIX84PQ2L3MxCu 31tEXKiw==; Received: from [177.159.253.249] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i5xtF-0000ID-Bg; Thu, 05 Sep 2019 19:57:57 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92.1) (envelope-from ) id 1i5xtC-0005mK-OO; Thu, 05 Sep 2019 16:57:54 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Greg Kroah-Hartman , Joe Perches , linux-kernel@vger.kernel.org, Jonathan Corbet , Andrew Morton , Sven Eckelmann , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Thomas Gleixner , Thierry Reding , Vincenzo Frascino Subject: [PATCH 5/6] scripts/spdxcheck.py: keep track on what line SPDX header was found Date: Thu, 5 Sep 2019 16:57:52 -0300 Message-Id: <8d73ce62170345f748f990861bf5352c4423281b.1567712829.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org According with Documentation/process/license-rules.rst, SPDX headers can be found only at the first lines. However, this script doesn't enforce it, and several files violate that. It could be useful to be able to show a histogram with the number of files that have the SPDX header on each line number. This feature is optional, enabled with -H or --histogram. Signed-off-by: Mauro Carvalho Chehab --- scripts/spdxcheck.py | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py index 6374e078a5f2..c969b050366f 100755 --- a/scripts/spdxcheck.py +++ b/scripts/spdxcheck.py @@ -189,7 +189,9 @@ class id_parser(object): # Should we check for more SPDX ids in the same file and # complain if there are any? # - break + return self.curline - 1 + + return -1 except ParserException as pe: if pe.tok: @@ -200,7 +202,7 @@ class id_parser(object): sys.stdout.write('%s: %d:0 %s\n' %(fname, self.curline, col, pe.txt)) self.spdx_errors += 1 -def scan_git_tree(tree): +def scan_git_tree(ln_count, tree): for el in tree.traverse(): # Exclude stuff which would make pointless noise # FIXME: Put this somewhere more sensible @@ -211,12 +213,15 @@ def scan_git_tree(tree): if not os.path.isfile(el.path): continue with open(el.path, 'rb') as fd: - parser.parse_lines(fd, args.maxlines, el.path) + ln = parser.parse_lines(fd, args.maxlines, el.path) + if ln >= 0: + ln_count[ln] += 1; + return ln_count -def scan_git_subtree(tree, path): +def scan_git_subtree(ln_count, tree, path): for p in path.strip('/').split('/'): tree = tree[p] - scan_git_tree(tree) + scan_git_tree(ln_count, tree) if __name__ == '__main__': @@ -225,6 +230,7 @@ if __name__ == '__main__': ap.add_argument('-m', '--maxlines', type=int, default=15, help='Maximum number of lines to scan in a file. Default 15') ap.add_argument('-v', '--verbose', action='store_true', help='Verbose statistics output') + ap.add_argument('-H', '--histogram', action='store_true', help='Verbose histogram about SPDX header position') args = ap.parse_args() # Sanity check path arguments @@ -255,23 +261,31 @@ if __name__ == '__main__': sys.stderr.write('%s\n' %traceback.format_exc()) sys.exit(1) + ln_count= [0] * args.maxlines + try: if len(args.path) and args.path[0] == '-': stdin = os.fdopen(sys.stdin.fileno(), 'rb') - parser.parse_lines(stdin, args.maxlines, '-') + ln = parser.parse_lines(stdin, args.maxlines, '-') + if ln >= 0: + ln_count[ln] += 1; + else: if args.path: for p in args.path: if os.path.isfile(p): - parser.parse_lines(open(p, 'rb'), args.maxlines, p) + ln = parser.parse_lines(open(p, 'rb'), args.maxlines, p) + if ln >= 0: + ln_count[ln] += 1; + elif os.path.isdir(p): - scan_git_subtree(repo.head.reference.commit.tree, p) + scan_git_subtree(ln_count, repo.head.reference.commit.tree, p) else: sys.stderr.write('path %s does not exist\n' %p) sys.exit(1) else: # Full git tree scan - scan_git_tree(repo.head.commit.tree) + scan_git_tree(ln_count, repo.head.commit.tree) if args.verbose: sys.stderr.write('\n') @@ -284,6 +298,11 @@ if __name__ == '__main__': sys.stderr.write('Lines checked: %12d\n' %parser.lines_checked) sys.stderr.write('Files with SPDX: %12d\n' %parser.spdx_valid) sys.stderr.write('Files with errors: %12d\n' %parser.spdx_errors) + sys.stderr.write('\n') + if args.histogram: + for i in range(0, len(ln_count)): + if ln_count[i] > 0: + sys.stderr.write('Files with SPDX at line #%-5d: %12d\n' % (i + 1, ln_count[i])) sys.exit(0) From patchwork Thu Sep 5 19:57:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 11133901 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FC4C14B4 for ; Thu, 5 Sep 2019 19:58:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA00B20870 for ; Thu, 5 Sep 2019 19:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567713508; bh=L2ilzE9mvYsv/6VrlXpNDiE8ACMdK7qUnTglrB7XykE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c8SG8iIBTQzBqTDNp+qZQFBP0hwNHtWbRmsKScuA8FktB3Vhwj8HdvQ1oEKgo41Zt X5EhYhY/PCfuUd6HyzP/Px5x5ziY2t9CO5HPf8/Nh01pU9dmhjY7iMV6CZ3BOMS9Wl AuGjfzxRRWm2wBNBcC2UGv9qL53Q6kLCHrONETqI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391629AbfIET6X (ORCPT ); Thu, 5 Sep 2019 15:58:23 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58466 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389223AbfIET56 (ORCPT ); Thu, 5 Sep 2019 15:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lmKR/QfPflgztvdRJ0TtD1IDJABz8ilaEopVRFO1xZk=; b=BKqaFdapbjhlq/k/T7gDhH0z9l OUEh17fjaZsvdHiHqYWIwk0of2f24eoQpwVvWiBwjLKOk5LNzP37/dnhgx701sDuqLvmKYVgs87Qx mr4YG+mqZoFkOF/F77Otea1denCJwSSAfIqyIkno+0GQEmvrTgPtVa8gO6NYKpMFTxJw3i2LVGzEf GX14OjhKmh1EJleZQmAefzxiufUpSz8QqQtnn39fulF1KmTFr+Ir2YiA+8Py0lkMwNP/jGT9icWAT Bes9gP4w2nOYu6rTiv3+rsK3n/rx89LXTsE61lOC92ieXt+AupbWVmRRxoab0RvUwq7/eWqfQtbhs xbuoIX9Q==; Received: from [177.159.253.249] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i5xtF-0000IG-Es; Thu, 05 Sep 2019 19:57:57 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92.1) (envelope-from ) id 1i5xtC-0005mO-PD; Thu, 05 Sep 2019 16:57:54 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Greg Kroah-Hartman , Joe Perches , linux-kernel@vger.kernel.org, Jonathan Corbet , Andrew Morton , Sven Eckelmann , Thierry Reding , =?utf-8?q?Aur=C3=A9lien_Cedeyn?= , =?utf-8?q?Uwe?= =?utf-8?q?_Kleine-K=C3=B6nig?= , Thomas Gleixner , Vincenzo Frascino Subject: [PATCH 6/6] scripts/spdxcheck.py: check if the line number follows the strict rule Date: Thu, 5 Sep 2019 16:57:53 -0300 Message-Id: <1b7b5c906646f8165fd818ec9e400609d7a7290b.1567712829.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is a very strict rule saying on what line a SPDX header should be. Add an optional pedantic check for it. When the check is enabled, it will verify if the file has the SPDX header "at the first possible line in a file which can contain a comment", as stated at: Documentation/process/license-rules.rst Signed-off-by: Mauro Carvalho Chehab --- scripts/spdxcheck.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py index c969b050366f..f3260391f091 100755 --- a/scripts/spdxcheck.py +++ b/scripts/spdxcheck.py @@ -164,9 +164,15 @@ class id_parser(object): self.lastid = None self.parser.parse(expr, lexer = self.lexer) - def parse_lines(self, fd, maxlines, fname): + def parse_lines(self, fd, maxlines, fname, strict): self.checked += 1 self.curline = 0 + self.max_line = 1 + self.is_python = False + + if fname.find("COPYING") >= 0: + self.max_line = maxlines + try: for line in fd: line = line.decode(locale.getpreferredencoding(False), errors='ignore') @@ -174,6 +180,13 @@ class id_parser(object): if self.curline > maxlines: break self.lines_checked += 1 + if self.curline == 1: + if re.match("\#\!", line): + self.max_line = 2 + if re.match("\#\!.*python", line): + is_python = True + if self.curline == 2 and self.is_python and re.match("^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)", line): + self.max_line = 3 if line.find("SPDX-License-Identifier:") < 0: continue expr = line.split(':')[1].strip() @@ -189,6 +202,8 @@ class id_parser(object): # Should we check for more SPDX ids in the same file and # complain if there are any? # + if strict and self.curline > self.max_line: + sys.stderr.write('Warning: SPDX header for file %s is at line %d\n' % (fname,self.curline)) return self.curline - 1 return -1 @@ -202,7 +217,7 @@ class id_parser(object): sys.stdout.write('%s: %d:0 %s\n' %(fname, self.curline, col, pe.txt)) self.spdx_errors += 1 -def scan_git_tree(ln_count, tree): +def scan_git_tree(ln_count, tree, strict): for el in tree.traverse(): # Exclude stuff which would make pointless noise # FIXME: Put this somewhere more sensible @@ -213,15 +228,15 @@ def scan_git_tree(ln_count, tree): if not os.path.isfile(el.path): continue with open(el.path, 'rb') as fd: - ln = parser.parse_lines(fd, args.maxlines, el.path) + ln = parser.parse_lines(fd, args.maxlines, el.path, strict) if ln >= 0: ln_count[ln] += 1; return ln_count -def scan_git_subtree(ln_count, tree, path): +def scan_git_subtree(ln_count, tree, path, strict): for p in path.strip('/').split('/'): tree = tree[p] - scan_git_tree(ln_count, tree) + scan_git_tree(ln_count, tree, strict) if __name__ == '__main__': @@ -231,6 +246,7 @@ if __name__ == '__main__': help='Maximum number of lines to scan in a file. Default 15') ap.add_argument('-v', '--verbose', action='store_true', help='Verbose statistics output') ap.add_argument('-H', '--histogram', action='store_true', help='Verbose histogram about SPDX header position') + ap.add_argument('-s', '--strict', action='store_true', help='Enable strict mode, making it complain about SPDX line position') args = ap.parse_args() # Sanity check path arguments @@ -266,7 +282,7 @@ if __name__ == '__main__': try: if len(args.path) and args.path[0] == '-': stdin = os.fdopen(sys.stdin.fileno(), 'rb') - ln = parser.parse_lines(stdin, args.maxlines, '-') + ln = parser.parse_lines(stdin, args.maxlines, '-', args.strict) if ln >= 0: ln_count[ln] += 1; @@ -274,18 +290,18 @@ if __name__ == '__main__': if args.path: for p in args.path: if os.path.isfile(p): - ln = parser.parse_lines(open(p, 'rb'), args.maxlines, p) + ln = parser.parse_lines(open(p, 'rb'), args.maxlines, p, args.strict) if ln >= 0: ln_count[ln] += 1; elif os.path.isdir(p): - scan_git_subtree(ln_count, repo.head.reference.commit.tree, p) + scan_git_subtree(ln_count, repo.head.reference.commit.tree, p, args.strict) else: sys.stderr.write('path %s does not exist\n' %p) sys.exit(1) else: # Full git tree scan - scan_git_tree(ln_count, repo.head.commit.tree) + scan_git_tree(ln_count, repo.head.commit.tree, args.strict) if args.verbose: sys.stderr.write('\n')