Re: [PATCH next 1/2] btrfs: tree-checker: Fix error format string

From: Geert Uytterhoeven
Date: Tue Nov 26 2019 - 05:37:36 EST


Hi David,

On Mon, Nov 11, 2019 at 7:32 PM David Sterba <dsterba@xxxxxxx> wrote:
> On Fri, Nov 08, 2019 at 10:38:52PM +0100, Andreas FÃrber wrote:
> > From: Andreas FÃrber <afaerber@xxxxxxxx>
> >
> > Argument BTRFS_FILE_EXTENT_INLINE_DATA_START is defined as offsetof(),
> > which returns type size_t, so we need %zu instead of %lu.
> >
> > This fixes a build warning on 32-bit arm:
> >
> > ../fs/btrfs/tree-checker.c: In function 'check_extent_data_item':
> > ../fs/btrfs/tree-checker.c:230:43: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'unsigned int' [-Wformat=]
> > 230 | "invalid item size, have %u expect [%lu, %u)",
> > | ~~^
> > | |
> > | long unsigned int
> > | %u
>
> Is there a gcc warning option that can catch that on 64bit too?
> -Wformat=2 does not and I don't see any other of the option family to do
> that. We've had fixups of the size_t printk formats and I'd like to
> catch that when the patches are added to the devel branches. I can't run
> 32bit build check each time but this seems to be the only way so far.

Yep. On 64-bit, size_t _is_ unsigned long.
So you have to compile for both 32-bit and 64-bit.

Acked-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>

> > Fixes: a31ccb4b7ba2 ("btrfs: tree-checker: Check item size before reading file extent type")
>
> As the patch is still in the devel branch, the commit id is not stable

It indeed is not:
Fixes: 153a6d299956983d ("btrfs: tree-checker: Check item size before
reading file extent type")

> and I'll fold the change to to the patch. Thanks.

Apparently that was forgotten, and now the issue is part of Linus' tree.

Gr{oetje,eeting}s,

Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds