Re: [PATCH] drm/xe: use %z format string for ptrdiff_t

From: Arnd Bergmann

Date: Mon Mar 16 2026 - 19:08:33 EST


On Mon, Mar 16, 2026, at 23:51, Matt Roper wrote:
> On Mon, Mar 16, 2026 at 11:43:46PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@xxxxxxxx>
>>
>> ptrdiff_t, size_t and long are the same size on all supported architectures,
>> but gcc requires the use of the %zx modifier instead of %lx. On 32-bit
>
> Nathan Chancellor just sent a fix here:
>
> https://lore.kernel.org/all/20260316-drm-xe-fix-32-bit-wformat-ptrdiff-v1-1-0108b10b2b6b@xxxxxxxxxx/
>
> His solution uses %tx rather than %zx, which according to
> Documentation/core-api/printk-formats.rst sounds like it's probably the
> most accurate format string for this case?
>

Right, Nathan's version is correct. I wasn't aware that size_t
and ptrdiff_t have different modifiers.

Arnd