mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: TAKANO Mitsuhiro <takano32@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-doc@vger.kernel.org
Cc: "Shuah Khan" <skhan@linuxfoundation.org>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	"Jiri Kosina" <jikos@kernel.org>,
	"Benjamin Tissoires" <bentiss@kernel.org>,
	linux-input@vger.kernel.org, "Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Vadim Pasternak" <vadimp@nvidia.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] docs: python: abi_parser: Detect a symbol repeated on one file
Date: Thu, 3 Dec 2026 16:59:34 -0800	[thread overview]
Message-ID: <e1067f41-ce75-4a33-94c8-018e8510ff76@infradead.org> (raw)
In-Reply-To: <20261125221758.2535044-4-takano32@gmail.com>



On 11/25/26 2:17 PM, TAKANO Mitsuhiro wrote:
> check_issues() warns when a symbol shows up on more than one file, but
> it never looks at a symbol that two entries on the same file claim:
> "if len(files) == 1: continue" skips that case.
> 
> The parser stores every entry under a key of its own, so a repeated
> symbol on one file is visible as two entries with the same file.
> Compare at that level and warn, and keep the cross-file case
> informational, because two drivers may expose an attribute with the
> same name for different devices, as sysfs-driver-hid-lenovo-go and
> sysfs-driver-hid-lenovo-go-s do.
> 
> Verification: get_abi.py --dir Documentation/ABI validate used to
> print four warnings for the cross-file case and nothing for the
> repeated one.  It now prints four informational messages for the
> former and two warnings for the latter, at sysfs-driver-mlxreg-io
> lines 348 and 744 and at sysfs-driver-hid-lenovo-go lines 389 and
> 566.
> 
> Signed-off-by: TAKANO Mitsuhiro <takano32@gmail.com>

Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.

> ---
> Changes in v2:
> - The documents are fixed before the checker is added, so the tree
>   does not gain warnings in the middle of the series.
> - The internal MCU protocol_version entry points at the top-level
>   attribute; v1 gave it the prefix of the removable controller's
>   group, which made it name the same file as that entry.
> - The checker keeps its warning for an entry without a file, counts
>   lines rather than occurrences, and drops an unused loop key.
> 
>  tools/lib/python/abi/abi_parser.py | 48 ++++++++++++++++++++----------
>  1 file changed, 32 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/lib/python/abi/abi_parser.py b/tools/lib/python/abi/abi_parser.py
> index d7bb20ef3acc..8b51659fb6ca 100644
> --- a/tools/lib/python/abi/abi_parser.py
> +++ b/tools/lib/python/abi/abi_parser.py
> @@ -554,28 +554,44 @@ class AbiParser:
>      def check_issues(self):
>          """Warn about duplicated ABI entries."""
>  
> -        for what, v in self.what_symbols.items():
> -            files = v.get("file")
> -            if not files:
> +        # Two entries on the same file that claim the same symbol are a
> +        # copy-and-paste mistake.  The parser gives every entry a key of its
> +        # own, so such a pair shows up as two entries here.
> +        per_file = {}
> +        for v in self.data.values():
> +            if v.get("type") == "File":
> +                continue
> +
> +            file_ref = v.get("file")
> +            if not file_ref:
>                  # Should never happen if the parser works properly
> -                self.log.warning("%s doesn't have a file associated", what)
> +                self.log.warning("%s doesn't have a file associated",
> +                                 v.get("what"))
>                  continue
>  
> -            if len(files) == 1:
> +            fname = file_ref[0][0]
> +            for what in v.get("what", []):
> +                per_file.setdefault((fname, what), set()).add(v.get("line_no"))
> +
> +        for (fname, what), lines in sorted(per_file.items()):
> +            if len(lines) < 2:
>                  continue
>  
> -            f = []
> -            for fname, lines in sorted(files.items()):
> -                if not lines:
> -                    f.append(f"{fname}")
> -                elif len(lines) == 1:
> -                    f.append(f"{fname}:{lines[0]}")
> -                else:
> -                    m = fname + "lines "
> -                    m += ", ".join(str(x) for x in lines)
> -                    f.append(m)
> +            self.log.warning("%s is defined %d times at %s: lines %s",
> +                             what, len(lines), fname,
> +                             ", ".join(str(x) for x in sorted(lines)))
> +
> +        # The same symbol on more than one file is normal: two drivers may
> +        # expose an attribute with the same name for different devices, as
> +        # sysfs-driver-hid-lenovo-go and sysfs-driver-hid-lenovo-go-s do.
> +        # Report it, but do not call it a problem.
> +        for what, v in self.what_symbols.items():
> +            files = v.get("file")
> +            if not files or len(files) < 2:
> +                continue
>  
> -            self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f))
> +            self.log.info("%s is documented on %d files: %s", what,
> +                          len(files), "; ".join(sorted(files)))
>  
>      def search_symbols(self, expr):
>          """ Searches for ABI symbols."""

-- 
~Randy


  reply	other threads:[~2026-12-04  0:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 22:17 [PATCH v2 0/3] docs: ABI: report a symbol that one file describes twice TAKANO Mitsuhiro
2026-11-25 22:17 ` [PATCH v2 1/3] docs: ABI: mlxreg-io: Drop the second shutdown_unlock entry TAKANO Mitsuhiro
2026-12-04  0:59   ` Randy Dunlap
2026-11-25 22:17 ` [PATCH v2 2/3] docs: ABI: hid-lenovo-go: Point one entry at the top-level attribute TAKANO Mitsuhiro
2026-12-04  0:59   ` Randy Dunlap
2026-11-25 22:17 ` [PATCH v2 3/3] docs: python: abi_parser: Detect a symbol repeated on one file TAKANO Mitsuhiro
2026-12-04  0:59   ` Randy Dunlap [this message]
2026-12-01 14:51 ` [PATCH v2 0/3] docs: ABI: report a symbol that one file describes twice Ilpo Järvinen
2026-12-01 14:54   ` Jonathan Corbet
2026-12-01 14:58     ` Ilpo Järvinen
2026-12-01 15:16       ` Jonathan Corbet

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=e1067f41-ce75-4a33-94c8-018e8510ff76@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=bentiss@kernel.org \
    --cc=corbet@lwn.net \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=takano32@gmail.com \
    --cc=vadimp@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®