[PATCH v2] devtools: fix symbol change check for non-lib patches
David Marchand
david.marchand at redhat.com
Thu Mar 5 14:50:32 CET 2026
Hello Ali,
Just repeating what we discussed offlist for visibility.
On Thu, 5 Mar 2026 at 11:52, Ali Alnubani <alialnu at nvidia.com> wrote:
>
> Handle patches that do not touch lib/drivers (e.g. doc-only) without
> crashing. Treat every '--- a/' line 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 at redhat.com
>
> Suggested-by: David Marchand <david.marchand at redhat.com>
No need for a suggested-by, you caught the issue and I am just
reviewing the fix :-).
> Signed-off-by: Ali Alnubani <alialnu at 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.
>
> devtools/check-symbol-change.py | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/devtools/check-symbol-change.py b/devtools/check-symbol-change.py
> index 1efeb82fcd..a476ceae5e 100755
> --- a/devtools/check-symbol-change.py
> +++ b/devtools/check-symbol-change.py
> @@ -29,17 +29,21 @@
> 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 ln.startswith("--- a/"):
This line above must be updated to also catch +++ b/ or the subsequent
regexp won't be called in the "addition" case.
> + 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))
> -
> - if lib not in symbols:
> - symbols[lib] = {}
> + lib = None
> continue
>
> if export_exp_sym_regexp.match(ln):
> @@ -54,6 +58,8 @@
> else:
> continue
>
> + if lib is None:
> + continue
We can move this check before evaluating all export_* regexps.
> if symbol not in symbols[lib]:
> symbols[lib][symbol] = {}
> added = ln[0] == "+"
> --
> 2.53.0
>
--
David Marchand
More information about the dev
mailing list