[PATCH] vsprintf.c: use default pointer field size for "(null)" strings

From: Joe Perches
Date: Tue Oct 26 2010 - 17:22:50 EST


It might be nicer to align the output.

For instance, ACPI messages sometimes have "(null)" pointers.

$ dmesg | grep "(null)" -A 1 -B 1
[ 0.198733] ACPI: Dynamic OEM Table Load:
[ 0.198745] ACPI: SSDT (null) 00239 (v02 PmRef Cpu0Ist 00003000 INTL 20051117)
[ 0.199294] ACPI: SSDT 7f596e10 001C7 (v02 PmRef Cpu0Cst 00003001 INTL 20051117)
[ 0.200708] ACPI: Dynamic OEM Table Load:
[ 0.200721] ACPI: SSDT (null) 001C7 (v02 PmRef Cpu0Cst 00003001 INTL 20051117)
[ 0.201950] ACPI: SSDT 7f597f10 000D0 (v02 PmRef Cpu1Ist 00003000 INTL 20051117)
[ 0.203386] ACPI: Dynamic OEM Table Load:
[ 0.203398] ACPI: SSDT (null) 000D0 (v02 PmRef Cpu1Ist 00003000 INTL 20051117)
[ 0.203871] ACPI: SSDT 7f595f10 00083 (v02 PmRef Cpu1Cst 00003000 INTL 20051117)
[ 0.205301] ACPI: Dynamic OEM Table Load:
[ 0.205315] ACPI: SSDT (null) 00083 (v02 PmRef Cpu1Cst 00003000 INTL 20051117)

> > All of the other valid %p<foo> extension uses do not end up
> > at this block being executed so it's effectively only regular
> > pointers being output by number()

Because passing NULL to any of the %p<foo> extensions
excluding %pK is probably a defect.

> > > > > Remove the attempt to print NULL pointers with a correct width.
> > > >
> > > > the correct width for a %p is the default width.
> > >
> > > It is the default width if we are printing addresses. Once we hash 64
> > > bit address to a 32 bit identifier then we don't have a default width.
> >
> > Perhaps that 32 bit identifier should use leading 0's for
> > the default width.
>
> That's a fair comment.
>
> > aside:
> >
> > Why hash 64 bits to 32?
> > Why shouldn't the hash width be 64 bits on 64 bit systems?
>
> Quoted from Linus in an earlier thread discussing this change
>
> Date: Thu, 12 Oct 2017 11:37:22 -0700 Linus Torvalds wrote:
>
> In fact, I'd prefer mapping the pointer to a 32-bit value, even on
> 64-bit architectures. When people use these things for debugging and
> for identifying which device node or socket or whatever they are
> tracking, we're generally talking a (small) handful of different
> devices or whatever.

I wonder about this and userland programs and API breakage.

I'd expect there could be cases of userland parsers that
expect a certain width for pointer fields.

$ git grep -E "\bseq_.*%p\W" | wc -l
112