Re: [PATCH V8 1/2] printk: remove tabular output for NULL pointer
From: Joe Perches
Date: Thu Oct 26 2017 - 10:47:31 EST
On Thu, 2017-10-26 at 20:37 +1100, Tobin C. Harding wrote:
> On Thu, Oct 26, 2017 at 01:05:39AM -0700, Joe Perches wrote:
> > On Thu, 2017-10-26 at 17:27 +1100, Tobin C. Harding wrote:
> > > Hi Joe,
> > >
> > > thanks for your review.
> > >
> > > On Wed, Oct 25, 2017 at 09:57:23PM -0700, Joe Perches wrote:
> > > > On Thu, 2017-10-26 at 13:53 +1100, Tobin C. Harding wrote:
> > > > > Currently pointer() checks for a NULL pointer argument and then if so
> > > > > attempts to print "(null)" with _some_ standard width. This width cannot
> > > > > correctly be ascertained here because many of the printk specifiers
> > > > > print pointers of varying widths.
> > > >
> > > > I believe this is not a good change.
> > > > Only pointers without a <foo> extension call pointer()
> > >
> > > Sorry, I don't understand what you mean here. All the %p<foo> specifier code is
> > > handled by pointer()?
> >
> > Sorry, I was imprecise/wrong.
> >
> > None of the %p<foo> extensions except %pK and %p<invalid_foo>
> > actually use this bit of the pointer() call.
>
> if (!ptr && *fmt != 'K') {
> /*
> * Print (null) with the same width as a pointer so it makes
> * tabular output look nice.
> */
> if (spec.field_width == -1)
> spec.field_width = default_width;
> return string(buf, end, "(null)", spec);
> }
>
> Is there something I'm missing here? This code reads like its all %p<foo>
> (including %p and %p<invalid_foo>) except %pK that hit this block when
> a NULL pointer is passed in.
The idea for aligning is described in commit 5e0579812834a
$ git log --stat -p -1 --format=email 5e0579812834a