All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Bulwahn <lukas.bulwahn@gmail.com>
To: Mrinal Pandey <mrinalmni@gmail.com>
Cc: Linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [Linux-kernel-mentees] [PATCH] checkpatch: Fix SPDX license check for scripts
Date: Mon, 13 Jul 2020 21:46:12 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.2007132140160.11844@felia> (raw)
In-Reply-To: <20200713095740.mi3cnx7tccoetxgc@mrinalpandey>



On Mon, 13 Jul 2020, Mrinal Pandey wrote:

> In all the scripts, the SPDX license should be on the second line,
> the first line being the "sh-bang", but checkpatch issues a warning
> "Misplaced SPDX-License-Identifier tag - use line 1 instead" for the
> scripts that have SPDX license in the second line.
> 
> However, this warning is not issued when checkpatch is run on a file using
> `-f` option. The case for files has been handled gracefully by changing
> `$checklicenseline` to `2` but a corresponding check when running checkpatch
> on a commit hash is missing.
> 
> I noticed this false positive while running checkpatch on the set of
> commits from v5.7 to v5.8-rc1 of the kernel on the commits which modified
> a script file.
> 
> This check is missing in checkpatch since commit a8da38a9cf0e
> ("checkpatch: add test for SPDX-License-Identifier on wrong line #")
> when the corresponding rule was first commited.
> 
> Fix this by setting `$checklicenseline` to `2` when the diff content that
> is being checked originates from a script, thus, informing checkpatch that
> the SPDX license should be on the second line.
> 
> Signed-off-by: Mrinal Pandey <mrinalmni@gmail.com>
> ---
>  scripts/checkpatch.pl | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 4c820607540b..bbffd0c4449d 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3218,6 +3218,9 @@ sub process {
>  		next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/);
>  
>  # check for using SPDX-License-Identifier on the wrong line number
> +		if ($realfile =~ /^scripts/) {
> +                    $checklicenseline = 2;
> +	        }

I think this is somehow wrong here. The check for checklicenseline = 2 
looks very different above.

Why does -f work and using a patch file not work?

Lukas


>  		if ($realline != $checklicenseline &&
>  		    $rawline =~ /\bSPDX-License-Identifier:/ &&
>  		    substr($line, @-, @+ - @-) eq "$;" x (@+ - @-)) {
> -- 
> 2.25.1
> 
> 
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2020-07-13 19:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13  9:57 [Linux-kernel-mentees] [PATCH] checkpatch: Fix SPDX license check for scripts Mrinal Pandey
2020-07-13 19:46 ` Lukas Bulwahn [this message]
2020-07-14  5:35   ` Mrinal Pandey
2020-07-14  6:03     ` Lukas Bulwahn
2020-07-16  5:15       ` Mrinal Pandey
2020-07-16  5:31         ` Lukas Bulwahn
2020-07-17  9:54           ` Mrinal Pandey
2020-07-17 11:47             ` Lukas Bulwahn
2020-07-19  6:27               ` Mrinal Pandey
2020-07-19  7:13                 ` Lukas Bulwahn
2020-07-21  5:44 Mrinal Pandey
2020-07-22 10:20 ` Lukas Bulwahn
2020-07-24  7:02   ` Mrinal Pandey
2020-07-24  8:09     ` Lukas Bulwahn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.2007132140160.11844@felia \
    --to=lukas.bulwahn@gmail.com \
    --cc=Linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=mrinalmni@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.