public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Ali Alnubani <alialnu@nvidia.com>
To: <dev@dpdk.org>
Cc: <david.marchand@redhat.com>
Subject: [PATCH v3] devtools: fix symbol change check for non-lib patches
Date: Mon, 9 Mar 2026 17:08:56 +0200	[thread overview]
Message-ID: <20260309150856.521907-1-alialnu@nvidia.com> (raw)
In-Reply-To: <20260305105016.1093351-1-alialnu@nvidia.com>

Handle patches that do not touch lib/drivers (e.g. doc-only) without
crashing. Treat every file header (--- a/ or +++ b/) as the start of a
new file: if the path is under lib/ or drivers/, set lib and process
symbol lines; otherwise set lib to None and ignore lines until the next
file. This avoids both NameError exceptions and misattributing
export-like lines from doc (or other) files to the previous lib when
file order varies.

Fixes: 1a0c104a7fa9 ("build: generate symbol maps")
Cc: david.marchand@redhat.com

Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
---

v2:
Treat every '--- a/' as a new file: set lib only for paths under lib/
or drivers/, otherwise set lib to None and skip lines until the next
file, so behavior no longer depends on patch file order.

v3:
Use a regex so both '--- a/' and '+++ b/' start a new file, and run 'if lib
is None: continue; right after the file-header block so non-lib lines are
skipped before any export regex is run.

 devtools/check-symbol-change.py | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/devtools/check-symbol-change.py b/devtools/check-symbol-change.py
index 1efeb82fcd..b1daa2934a 100755
--- a/devtools/check-symbol-change.py
+++ b/devtools/check-symbol-change.py
@@ -7,6 +7,7 @@
 import argparse
 import re
 
+new_file_regexp = re.compile(r"^(\-\-\-|\+\+\+) [ab]/")
 file_header_regexp = re.compile(r"^(\-\-\-|\+\+\+) [ab]/(lib|drivers)/([^/]+)/([^/]+)")
 # From eal_exports.h
 export_exp_sym_regexp = re.compile(r"^.RTE_EXPORT_EXPERIMENTAL_SYMBOL\(([^,]+),")
@@ -29,17 +30,24 @@
 symbols = {}
 
 for file in args.patch:
+    lib = None
     for ln in file.readlines():
-        if file_header_regexp.match(ln):
-            if file_header_regexp.match(ln).group(2) == "lib":
-                lib = "/".join(file_header_regexp.match(ln).group(2, 3))
-            elif file_header_regexp.match(ln).group(3) == "intel":
-                lib = "/".join(file_header_regexp.match(ln).group(2, 3, 4))
+        if new_file_regexp.match(ln):
+            if file_header_regexp.match(ln):
+                m = file_header_regexp.match(ln)
+                if m.group(2) == "lib":
+                    lib = "/".join(m.group(2, 3))
+                elif m.group(3) == "intel":
+                    lib = "/".join(m.group(2, 3, 4))
+                else:
+                    lib = "/".join(m.group(2, 3))
+                if lib not in symbols:
+                    symbols[lib] = {}
             else:
-                lib = "/".join(file_header_regexp.match(ln).group(2, 3))
+                lib = None
+            continue
 
-            if lib not in symbols:
-                symbols[lib] = {}
+        if lib is None:
             continue
 
         if export_exp_sym_regexp.match(ln):
-- 
2.53.0


  parent reply	other threads:[~2026-03-09 15:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-05  9:10 [PATCH] devtools: fix symbol change check for non-lib patches Ali Alnubani
2026-03-05 10:10 ` David Marchand
2026-03-05 10:50 ` [PATCH v2] " Ali Alnubani
2026-03-05 13:50   ` David Marchand
2026-03-09 15:08   ` Ali Alnubani [this message]
2026-03-17 15:45     ` [PATCH v3] " David Marchand

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=20260309150856.521907-1-alialnu@nvidia.com \
    --to=alialnu@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    /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