mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts/spdxcheck.py: fix C++ comment style detection
@ 2019-02-20 21:18 Aurélien Cedeyn
  2019-02-22 15:48 ` Jonathan Corbet
  0 siblings, 1 reply; 2+ messages in thread
From: Aurélien Cedeyn @ 2019-02-20 21:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, akpm, corbet, gregkh

With the last commit to support the SuperH boot code files, we have the
following regression:

$ ./scripts/checkpatch.pl -f <(echo '/* SPDX-License-Identifier: MIT */')
WARNING: 'SPDX-License-Identifier: MIT */' is not supported in LICENSES/..
+/* SPDX-License-Identifier: MIT */

total: 0 errors, 1 warnings, 1 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/dev/fd/63 has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

This is not obvious, but spdxcheck.py is launched in checkpatch.pl with :
    ...
    } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
        my $spdx_license = $1;
        if (!is_SPDX_License_valid($spdx_license)) {
            WARN("SPDX_LICENSE_TAG",
                 "'$spdx_license' is not supported in LICENSES/...\n" . \
                 $herecurr);
        }
    ...
    sub is_SPDX_License_valid {
        my ($license) = @_;
        ...
        my $status = `cd "$root_path"; echo "$license" |
                      python scripts/spdxcheck.py -`;
        ...
    }

The first chars before 'SPDX-License-Identifier:' are ignored.
This commit fixes this regression.

Fixes:959b49687838 (scripts/spdxcheck.py: Handle special quotation mark comments)
Signed-off-by:Aurélien Cedeyn <aurelien.cedeyn@gmail.com>
---
 scripts/spdxcheck.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py
index 3fb020c..4fe392e 100755
--- a/scripts/spdxcheck.py
+++ b/scripts/spdxcheck.py
@@ -177,7 +177,7 @@ class id_parser(object):
                     continue
                 expr = line.split(':')[1].strip()
                 # Remove trailing comment closure
-                if line.startswith('/*'):
+                if line.strip().endswith('*/'):
                     expr = expr.rstrip('*/').strip()
                 # Special case for SH magic boot code files
                 if line.startswith('LIST \"'):
-- 
2.7.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/spdxcheck.py: fix C++ comment style detection
  2019-02-20 21:18 [PATCH] scripts/spdxcheck.py: fix C++ comment style detection Aurélien Cedeyn
@ 2019-02-22 15:48 ` Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2019-02-22 15:48 UTC (permalink / raw)
  To: Aurélien Cedeyn; +Cc: linux-kernel, tglx, akpm, gregkh

On Wed, 20 Feb 2019 22:18:34 +0100
Aurélien Cedeyn <aurelien.cedeyn@gmail.com> wrote:

> With the last commit to support the SuperH boot code files, we have the
> following regression:
> 
> $ ./scripts/checkpatch.pl -f <(echo '/* SPDX-License-Identifier: MIT */')
> WARNING: 'SPDX-License-Identifier: MIT */' is not supported in LICENSES/..
> +/* SPDX-License-Identifier: MIT */
> 
> total: 0 errors, 1 warnings, 1 lines checked
> 
> NOTE: For some of the reported defects, checkpatch may be able to
> mechanically convert to the typical style using --fix or --fix-inplace.
> 
> /dev/fd/63 has style problems, please review.
> 
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.
> 
> This is not obvious, but spdxcheck.py is launched in checkpatch.pl with :
>     ...
>     } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
>         my $spdx_license = $1;
>         if (!is_SPDX_License_valid($spdx_license)) {
>             WARN("SPDX_LICENSE_TAG",
>                  "'$spdx_license' is not supported in LICENSES/...\n" . \
>                  $herecurr);
>         }
>     ...
>     sub is_SPDX_License_valid {
>         my ($license) = @_;
>         ...
>         my $status = `cd "$root_path"; echo "$license" |
>                       python scripts/spdxcheck.py -`;
>         ...
>     }
> 
> The first chars before 'SPDX-License-Identifier:' are ignored.
> This commit fixes this regression.
> 
> Fixes:959b49687838 (scripts/spdxcheck.py: Handle special quotation mark comments)
> Signed-off-by:Aurélien Cedeyn <aurelien.cedeyn@gmail.com>

I've applied this, thanks, though that parsing code still looks a little
fragile.  It needs a proper regex perhaps someday...:)

Thanks,

jon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-22 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20 21:18 [PATCH] scripts/spdxcheck.py: fix C++ comment style detection Aurélien Cedeyn
2019-02-22 15:48 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®