Re: [PATCH v2 05/19] gendwarfksyms: Expand base_type
From: Sami Tolvanen
Date: Wed Aug 28 2024 - 18:19:34 EST
On Wed, Aug 28, 2024 at 02:46:03PM +0200, Petr Pavlu wrote:
> > +static int process_fmt(struct state *state, const char *fmt, ...)
>
> Nit: The state parameter is unused by a number of these process_*()
> functions, including the leaf process(). I suggest removing it so it
> doesn't need to be passed around unnecessarily.
Good point, I'll clean this up.
> > + char buf[MAX_FMT_BUFFER_SIZE];
> > + va_list args;
> > + int res;
> > +
> > + va_start(args, fmt);
> > +
> > + res = checkp(vsnprintf(buf, sizeof(buf), fmt, args));
> > + if (res >= MAX_FMT_BUFFER_SIZE - 1) {
>
> This check looks off by one, though on the safe side:
> res >= sizeof(buf)
True, I'll fix this too.
> > + if (dwarf_tag(&scopes[i]) == DW_TAG_compile_unit)
> > + continue;
> > +
> > + name = get_name(&scopes[i]);
> > + name = name ?: "<unnamed>";
> > + check(process(state, name));
> > + if (i > 0)
> > + check(process(state, "::"));
>
> Failed check(process()) calls here return immediately and so would leak
> scopes. However, I see this is fixed in the following patch
> "gendwarfksyms: Add a cache for processed DIEs" so it's ok.
Yeah, I noticed this as well. I think Masahiro's suggestion to just
exit immediately on errors cleans up this situation a bit.
Sami