Re: [PATCH v1 01/25] lib/vsprintf: Remove useless NULL checks

From: Andy Shevchenko
Date: Thu Jul 20 2017 - 06:23:03 EST


On Thu, 2017-06-08 at 22:59 +0200, Rasmus Villemoes wrote:
> On Thu, Jun 08 2017, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxx
> m> wrote:
> > The pointer can't be NULL since it's first what has been done in the
> > pointer().
Â
> > - if (ZERO_OR_NULL_PTR(addr))
> > - return string(buf, end, NULL, spec); /* NULL
> > pointer */
> > -
> > -
>
> Well, ZERO_OR_NULL_PTR checks for a little more than !addr, but I
> suppose that if anyone passes the result from kmalloc(0) to %ph,
> they'd
> better also pass 0 as the size, so the .field_width tests should be
> sufficient.

If we care about kmalloc(0) check we better to do this in pointer()?

> > - if (!IS_ENABLED(CONFIG_HAVE_CLK) || !clk)
> > - return string(buf, end, NULL, spec);
> > -
>
> Well, it may be safe, but removing the IS_ENABLED(CONFIG_HAVE_CLK)
> check
> means that clock() becomes a much bigger function when
> !IS_ENABLED(CONFIG_HAVE_CLK).

I return back this in v2.

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy