Re: [PATCH mm] kfence: fix printk format for ptrdiff_t

From: Christophe Leroy
Date: Tue Mar 16 2021 - 11:41:50 EST

Le 16/03/2021 à 16:33, Segher Boessenkool a écrit :
On Tue, Mar 16, 2021 at 09:32:32AM +0100, Christophe Leroy wrote:

I cannot see through the wood of #defines here, sorry.

Still a problem.

I don't understand, gcc bug ?

Rule #1: If you do not understand what is happening, it is not a
compiler bug. I'm not saying that it isn't, just that it is much more
likely something else.

The offending argument is 'const ptrdiff_t object_index'

We have:

arch/powerpc/include/uapi/asm/posix_types.h:typedef long

So this is a 64-bit build.

No it's 32 bits. The code in posix-types.h is

#ifdef __powerpc64__
typedef long __kernel_ptrdiff_t;

include/linux/types.h:typedef __kernel_ptrdiff_t ptrdiff_t;

And get:

CC mm/kfence/report.o
In file included from ./include/linux/printk.h:7,
from ./include/linux/kernel.h:16,
from mm/kfence/report.c:10:
mm/kfence/report.c: In function 'kfence_report_error':
./include/linux/kern_levels.h:5:18: warning: format '%td' expects argument
of type 'ptrdiff_t', but argument 6 has type 'long int' [-Wformat=]

This is declared as
const ptrdiff_t object_index = meta ? meta - kfence_metadata : -1;
so maybe something with that goes wrong? What happens if you delete the
(useless) "const" here?

No change.