Re: [PATCH] x86/vdso: Use proper modifier for len's printf in extract

From: Jarkko Sakkinen
Date: Wed Mar 03 2021 - 13:24:14 EST


On Wed, Mar 03, 2021 at 07:43:57AM +0100, Jiri Slaby wrote:
> Commit 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO
> functions") added a printf of len which is size_t. Compilers now
> complain on 32b:
> In file included from arch/x86/entry/vdso/vdso2c.c:162:
> arch/x86/entry/vdso/vdso2c.h: In function 'extract64':
> arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'}
>
> So use proper modifier (%zu) for size_t.
>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Fixes: 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions")
> Cc: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
> Cc: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
> Cc: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxx>
> Cc: Jethro Beekman <jethro@xxxxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> Cc: x86@xxxxxxxxxx


Acked-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>

> ---
> arch/x86/entry/vdso/vdso2c.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
> index 1c7cfac7e64a..5264daa8859f 100644
> --- a/arch/x86/entry/vdso/vdso2c.h
> +++ b/arch/x86/entry/vdso/vdso2c.h
> @@ -35,7 +35,7 @@ static void BITSFUNC(extract)(const unsigned char *data, size_t data_len,
> if (offset + len > data_len)
> fail("section to extract overruns input data");
>
> - fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);
> + fprintf(outfile, "static const unsigned char %s[%zu] = {", name, len);
> BITSFUNC(copy)(outfile, data + offset, len);
> fprintf(outfile, "\n};\n\n");
> }
> --
> 2.30.1
>
>

/Jarkko