Re: [PATCH v6 16/59] perf python: Add syscall name/id to convert syscall number and name

sashiko-bot
2026-04-25T18:15:04Z

Sashiko AI review found 2 potential issue(s):
- [High] Missing libtraceevent guard around syscalltbl logic causes build failure when NO_LIBTRACEEVENT=1.
- [High] Declaring `kwlist` as `static char * const kwlist[]` triggers a compiler warning that breaks the build under `-Werror` on standard Python versions.
--

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

perf python: Add syscall name/id to convert syscall number and name

This commit introduces functionality to use perf's syscalltbl support
to convert syscall numbers to names and vice versa within the python
extension. This helps avoid the need for python libaudit support in
certain scripts.

> diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> index d10359abd1ea..a10c4a292756 100644
> --- a/tools/perf/util/python.c
> +++ b/tools/perf/util/python.c

[ ... ]

> @@ -2635,6 +2637,40 @@ static int pyrf_session__setup_types(void)
> return PyType_Ready(&pyrf_session__type);
> }
>
> +static PyObject *pyrf__syscall_name(PyObject *self, PyObject *args, PyObject *kwargs)
> +{
> + const char *name;
> + int id;
> + int elf_machine = EM_HOST;
> + static char * const kwlist[] = { "id", "elf_machine", NULL };

Can this trigger a compiler warning that breaks the build under -Werror
on systems with Python 3.12 or older?

Prior to Python 3.13, PyArg_ParseTupleAndKeywords() expects a char ** for
its keywords argument. Passing a char * const * discards the const
qualifier, which might generate a -Wincompatible-pointer-types warning.

> +
> + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|$i", kwlist, &id, &elf_machine))
> + return NULL;
> +
> + name = syscalltbl__name(elf_machine, id);

Does this cause a build failure when perf is built with NO_LIBTRACEEVENT=1?

The syscalltbl.o object is only compiled if CONFIG_TRACE is set, which is
enabled only if NO_LIBTRACEEVENT is not set.

Because python.c calls syscalltbl__name() and syscalltbl__id() unconditionally
without checking if libtraceevent is available, linking the python extension
might fail with an undefined reference when libtraceevent is omitted.

[ ... ]

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