[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251020085643.14007a29@sal.lan>
Date: Mon, 20 Oct 2025 08:56:43 -0300
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: Hans Verkuil <hverkuil+cisco@...nel.org>
Cc: Jonathan Corbet <corbet@....net>, Linux Doc Mailing List
<linux-doc@...r.kernel.org>, Mauro Carvalho Chehab <mchehab@...nel.org>,
linux-kernel@...r.kernel.org, linux-media@...r.kernel.org
Subject: Re: [PATCH 02/23] tools: docs: parse_data_structs.py: output a line
number
Em Mon, 20 Oct 2025 12:46:50 +0200
Hans Verkuil <hverkuil+cisco@...nel.org> escreveu:
> On 01/10/2025 16:49, Mauro Carvalho Chehab wrote:
>
> Missing commit message!
Weird, I'm almost sure I filled some description.
>
> I'm less concerned about the missing message (it's clear what is happening here),
> than I am about the fact that checkpatch wasn't run.
My mailbomb script does run checkpatch for each patch, but I probably
missed the warnings(*).
(*) By the time I sent this series, I was playing with a new version
written in Python. It had several issues, however, mostly because I
was unable to find a way for Python to read an e-mail formatted with
git format-patch without mangling with content encoding. I got problems
on translations, with binary file patches and even with \n at the code.
On my original script, written in 2015, it was easy to lose checkpatch
messages in the crowd on big series. I did several improvements on
it, like running checkpatch in parallel and re-ordering warnings to
avoid losing them, but it was done only after sending this series.
In any case, checkpatch currently doesn't have any logic for Python
or ReST files. It only reports patch descriptions issues like this.
IMO what it is needed for checkpatch to be more useful for tools is:
1. to define a coding style for Python;
2. to add some code at checkpatch to handle Python as well.
>
> Regards,
>
> Hans
>
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
> > ---
> > tools/docs/lib/parse_data_structs.py | 29 ++++++++++++++--------------
> > 1 file changed, 15 insertions(+), 14 deletions(-)
> >
> > diff --git a/tools/docs/lib/parse_data_structs.py b/tools/docs/lib/parse_data_structs.py
> > index 6c868f84f029..d28471a045f1 100755
> > --- a/tools/docs/lib/parse_data_structs.py
> > +++ b/tools/docs/lib/parse_data_structs.py
> > @@ -143,7 +143,7 @@ class ParseDataStructs:
> > for symbol_type in self.DEF_SYMBOL_TYPES:
> > self.symbols[symbol_type] = {}
> >
> > - def store_type(self, symbol_type: str, symbol: str,
> > + def store_type(self, ln, symbol_type: str, symbol: str,
> > ref_name: str = None, replace_underscores: bool = True):
> > """
> > Stores a new symbol at self.symbols under symbol_type.
> > @@ -172,7 +172,7 @@ class ParseDataStructs:
> > else:
> > ref_link = symbol
> >
> > - self.symbols[symbol_type][symbol] = f"{prefix}{ref_link}{suffix}"
> > + self.symbols[symbol_type][symbol] = (f"{prefix}{ref_link}{suffix}", ln)
> >
> > def store_line(self, line):
> > """Stores a line at self.data, properly indented"""
> > @@ -240,20 +240,20 @@ class ParseDataStructs:
> > if is_enum:
> > match = re.match(r"^\s*([_\w][\w\d_]+)\s*[\,=]?", line)
> > if match:
> > - self.store_type("symbol", match.group(1))
> > + self.store_type(line_no, "symbol", match.group(1))
> > if "}" in line:
> > is_enum = False
> > continue
> >
> > match = re.match(r"^\s*#\s*define\s+([\w_]+)\s+_IO", line)
> > if match:
> > - self.store_type("ioctl", match.group(1),
> > + self.store_type(line_no, "ioctl", match.group(1),
> > replace_underscores=False)
> > continue
> >
> > match = re.match(r"^\s*#\s*define\s+([\w_]+)(\s+|$)", line)
> > if match:
> > - self.store_type("define", match.group(1))
> > + self.store_type(line_no, "define", match.group(1))
> > continue
> >
> > match = re.match(r"^\s*typedef\s+([_\w][\w\d_]+)\s+(.*)\s+([_\w][\w\d_]+);",
> > @@ -261,20 +261,20 @@ class ParseDataStructs:
> > if match:
> > name = match.group(2).strip()
> > symbol = match.group(3)
> > - self.store_type("typedef", symbol, ref_name=name)
> > + self.store_type(line_no, "typedef", symbol, ref_name=name)
> > continue
> >
> > for re_enum in self.RE_ENUMS:
> > match = re_enum.match(line)
> > if match:
> > - self.store_type("enum", match.group(1))
> > + self.store_type(line_no, "enum", match.group(1))
> > is_enum = True
> > break
> >
> > for re_struct in self.RE_STRUCTS:
> > match = re_struct.match(line)
> > if match:
> > - self.store_type("struct", match.group(1))
> > + self.store_type(line_no, "struct", match.group(1))
> > break
> >
> > def process_exceptions(self, fname: str):
> > @@ -342,7 +342,8 @@ class ParseDataStructs:
> >
> > # Change self.symbols to use the replacement rule
> > if old in self.symbols[c_type]:
> > - self.symbols[c_type][old] = new_ref
> > + (_, ln) = self.symbols[c_type][old]
> > + self.symbols[c_type][old] = (new_ref, ln)
> > else:
> > print(f"{name}:{ln}: Warning: can't find {old} {c_type}")
> >
> > @@ -360,8 +361,8 @@ class ParseDataStructs:
> >
> > print(f"{c_type}:")
> >
> > - for symbol, ref in sorted(refs.items()):
> > - print(f" {symbol} -> {ref}")
> > + for symbol, (ref, ln) in sorted(refs.items()):
> > + print(f" #{ln:<5d} {symbol} -> {ref}")
> >
> > print()
> >
> > @@ -384,7 +385,7 @@ class ParseDataStructs:
> >
> > # Process all reference types
> > for ref_dict in self.symbols.values():
> > - for symbol, replacement in ref_dict.items():
> > + for symbol, (replacement, _) in ref_dict.items():
> > symbol = re.escape(re.sub(r"([\_\`\*\<\>\&\\\\:\/])", r"\\\1", symbol))
> > text = re.sub(fr'{start_delim}{symbol}{end_delim}',
> > fr'\1{replacement}\2', text)
> > @@ -420,8 +421,8 @@ class ParseDataStructs:
> > text.append("")
> >
> > # Sort symbols alphabetically
> > - for symbol, ref in sorted(refs.items()):
> > - text.append(f"* :{ref}:")
> > + for symbol, (ref, ln) in sorted(refs.items()):
> > + text.append(f"* {ref}: line #{ln}")
> >
> > text.append("") # Add empty line between categories
> >
>
Powered by blists - more mailing lists