Re: [PATCH v4 2/2] kallsyms: Don't leak pointers for unresolved symbols
From: Sebastian Andrzej Siewior
Date: Mon Oct 19 2026 - 06:55:01 EST
On 2026-10-19 13:34:35 [+0300], Andy Shevchenko wrote:
> > +int snprintf_default_pointer(char *buf, unsigned int len, const void *ptr)
> > +{
> > + struct printf_spec spec = {
> > + .base = 10,
> > + .precision = -1,
> > + .field_width = -1,
> > + };
>
> Isn't it the same as default_dec_spec?
Except for .field_width, yes.
> > + unsigned int w;
> > + char *endp;
> > +
> > + endp = default_pointer(buf, buf + len, ptr, spec);
> > + w = min_t(unsigned int, len - 1, endp - buf);
>
> May we avoid min_t()?
min() complains about signedness (len unsigned and ptr diff signed).
endp is >= buf so it will be unsigned.
An alternative would be manual comparison if the buffer size has been
exceeded or not and act upon it but this looks simpler.
> > + buf[w] = '\0';
> > + return endp - buf;
> > +}
Sebastian