On Tue, Sep 16, 2025 at 04:59:28PM +0000, Nabih Estefan wrote:
> When running the license check, if we are updating a license it is
> possible for the checkpatch script to test against old license lines
> instead of newer ones, since the removal lines appear before the
> addition lines in a .patch file.

While we match the "SPDX-License-Identifier" text in any context,
the "file must have SDPX" validation is only performed against
files that are entirely new: 

  # Called at the end of processing a diff hunk for a file
  sub process_end_of_file {
        my $fileinfo = shift;

        if ($fileinfo->{action} eq "new" &&
            !exists $fileinfo->{facts}->{sawspdx}) {
             ...raise error ....

> Fix this by skipping over lines that start with "-" in the checkpatch
> script.

A new file cannot have any "-" lines present, so there isn't any
bug that needs fixing AFAICT.  Can you show any patch or commit
where this would have made a difference to what checkpatch.pl
reports ?

> 
> Signed-off-by: Nabih Estefan <nabiheste...@google.com>
> ---
>  scripts/checkpatch.pl | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 833f20f555..c57a423f9f 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1813,7 +1813,8 @@ sub process {
>               }
>  
>  # Check SPDX-License-Identifier references a permitted license
> -             if ($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) {
> +             if (($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) &&
> +                     $rawline !~ /^-/) {
>                       $fileinfo->{facts}->{sawspdx} = 1;
>                       &checkspdx($realfile, $1);
>               }
> -- 
> 2.51.0.384.g4c02a37b29-goog
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to