Re: [PATCH v2 58/58] perf python: Improve perf script -l descriptions

sashiko-bot
2026-04-23T04:50:46Z

Sashiko AI review found 1 potential issue(s):
- [Medium] The patch fails to improve the descriptions for `twatch.py` and `exported-sql-viewer.py` as claimed in the commit message, and it introduces additional memory leaks due to a pre-existing parser bug.
--

commit eb1bf023eba14ef9575f31d47d28eb599d1896ec
Author: Ian Rogers <irogers@google.com>

perf python: Improve perf script -l descriptions

This commit updates the descriptions of several python scripts for "perf
script -l" by adding or modifying the docstrings at the beginning of the
files.

> $ perf script -l
> List of available scripts:
[ ... ]
> exported-sql-viewer exported-sql-viewer.py: view data from sql database.
[ ... ]
> twatch Example to show how to enable a tracepoint and access its fields.
[ ... ]

Will the output for these scripts actually match this description?

[ ... ]
> diff --git a/tools/perf/python/exported-sql-viewer.py b/tools/perf/python/exported-sql-viewer.py
> index f3ac96ada1f51..6d526a2502ca1 100755
> --- a/tools/perf/python/exported-sql-viewer.py
> +++ b/tools/perf/python/exported-sql-viewer.py
> @@ -1,6 +1,6 @@
> #!/usr/bin/env python
> # SPDX-License-Identifier: GPL-2.0
> -# exported-sql-viewer.py: view data from sql database
> +"""exported-sql-viewer.py: view data from sql database."""

Looking at read_script_info() in builtin-script.c, when it matches a
single-line docstring, it breaks out of the quote-matching loop but fails
to break out of the file-reading while loop.

Because both twatch.py and exported-sql-viewer.py contain subsequent
triple-quote blocks later in the file, does read_script_info() continue
scanning and overwrite desc->half_liner with those later blocks instead of
displaying this text?

If so, does this also leak the memory allocated for these new descriptions
when strdup() is called again without freeing the previous allocation?

[ ... ]

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260423035526.1537178-1-irogers@google.com?part=58