DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: [PATCH v2] check-spdk: check that tag is on first line
Date: Wed,  5 Nov 2025 17:22:00 -0800	[thread overview]
Message-ID: <20251106012200.921242-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20251105222827.904627-1-stephen@networkplumber.org>

For C files the tag needs to be on the first line.

Change how -q flag works; if no errors then command is completely
silent.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/check-spdx-tag.sh | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/devtools/check-spdx-tag.sh b/devtools/check-spdx-tag.sh
index 984825026e..65f00f6e5e 100755
--- a/devtools/check-spdx-tag.sh
+++ b/devtools/check-spdx-tag.sh
@@ -6,6 +6,7 @@
 
 missing_spdx=0
 wrong_license=0
+errors=0
 warnings=0
 quiet=false
 verbose=false
@@ -29,15 +30,16 @@ check_spdx() {
     git grep -L SPDX-License-Identifier -- $no_license_list > $tmpfile
 
     missing_spdx=$(wc -l < $tmpfile)
+    errors=$((errors + missing_spdx))
     $quiet || cat $tmpfile
 }
 
 build_exceptions_list() {
     grep '.*|.*|.*|.*' license/exceptions.txt | grep -v 'TB Approval Date' |
     while IFS='|' read license tb_date gb_date pattern ; do
-        license=$(echo $license) # trim spaces
-        git grep -l "SPDX-License-Identifier:[[:space:]]*$license" $pattern |
-        sed -e 's/^/:^/'
+	license=$(echo $license) # trim spaces
+	git grep -l "SPDX-License-Identifier:[[:space:]]*$license" $pattern |
+	sed -e 's/^/:^/'
     done
 }
 
@@ -51,6 +53,7 @@ check_licenses() {
     xargs grep -L -E 'SPDX-License-Identifier:[[:space:]]*(\(?|.* OR )BSD-3-Clause' > $tmpfile
 
     wrong_license=$(wc -l < $tmpfile)
+    errors=$((errors + wrong_license))
     $quiet || cat $tmpfile
 }
 
@@ -63,7 +66,19 @@ check_boilerplate() {
     git grep -l Redistribution -- \
 	':^license/' ':^/devtools/check-spdx-tag.sh' > $tmpfile
 
-    warnings=$(wc -l <$tmpfile)
+    warnings=$(wc -l < $tmpfile)
+    $quiet || cat $tmpfile
+}
+
+check_firstline() {
+    if $verbose ; then
+	echo "Files with license text not on first line"
+	echo "-----------------------------------------"
+    fi
+    git grep -n SPDX-License-Identifier -- '*.[ch]' | awk -F: '$2 != 1 { print $1}' >$tmpfile
+
+    first_line=$(wc -l < $tmpfile)
+    warnings=$((warnings + first_line))
     $quiet || cat $tmpfile
 }
 
@@ -89,5 +104,10 @@ $verbose && echo
 check_boilerplate
 $verbose && echo
 
+check_firstline
+$verbose && echo
+
+$quiet && [ $errors = 0 ] && exit
+
 echo "total: $missing_spdx missing SPDX, $wrong_license license errors, $warnings warnings"
-exit $((missing_spdx + wrong_license))
+exit $errors
-- 
2.51.0


      parent reply	other threads:[~2025-11-06  1:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 14:20 [PATCH 1/1] move SPDX tag on the " Thomas Monjalon
2025-10-31 14:55 ` Morten Brørup
2025-11-05 21:31   ` Thomas Monjalon
2025-11-05 22:28 ` [PATCH] check-spdk: check that tag is on " Stephen Hemminger
2025-11-05 22:37   ` Thomas Monjalon
2025-11-06  1:22   ` Stephen Hemminger [this message]

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=20251106012200.921242-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).