[PATCH] bcachefs: Fix format specifier in validate_bset_keys()

Nathan Chancellor posted 1 patch 1 year, 9 months ago
fs/bcachefs/btree_io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] bcachefs: Fix format specifier in validate_bset_keys()
Posted by Nathan Chancellor 1 year, 9 months ago
When building for 32-bit platforms, for which size_t is 'unsigned int',
there is a warning from a format string in validate_bset_keys():

  fs/bcachefs/btree_io.c: In function 'validate_bset_keys':
  fs/bcachefs/btree_io.c:891:34: error: format '%lu' expects argument of type 'long unsigned int', but argument 12 has type 'unsigned int' [-Werror=format=]
    891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
        |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  fs/bcachefs/btree_io.c:603:32: note: in definition of macro 'btree_err'
    603 |                                msg, ##__VA_ARGS__);                     \
        |                                ^~~
  fs/bcachefs/btree_io.c:887:21: note: in expansion of macro 'btree_err_on'
    887 |                 if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
        |                     ^~~~~~~~~~~~
  fs/bcachefs/btree_io.c:891:64: note: format string is defined here
    891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
        |                                                              ~~^
        |                                                                |
        |                                                                long unsigned int
        |                                                              %u
  cc1: all warnings being treated as errors

BKEY_U64s is size_t so the entire expression is promoted to size_t. Use
the '%zu' specifier so that there is no warning regardless of the width
of size_t.

Fixes: 031ad9e7dbd1 ("bcachefs: Check for packed bkeys that are too big")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202404130747.wH6Dd23p-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202404131536.HdAMBOVc-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 fs/bcachefs/btree_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index 9678b2375bed..debb0edc3455 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -888,7 +888,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
 				 -BCH_ERR_btree_node_read_err_fixable,
 				 c, NULL, b, i,
 				 btree_node_bkey_bad_u64s,
-				 "bad k->u64s %u (min %u max %lu)", k->u64s,
+				 "bad k->u64s %u (min %u max %zu)", k->u64s,
 				 bkeyp_key_u64s(&b->format, k),
 				 U8_MAX - BKEY_U64s + bkeyp_key_u64s(&b->format, k)))
 			goto drop_this_key;

---
base-commit: 96fca68c4fbf77a8185eb10f7557e23352732ea2
change-id: 20240416-bcachefs-fix-format-specifier-validate_bset_keys-693c1daad9c9

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>
Re: [PATCH] bcachefs: Fix format specifier in validate_bset_keys()
Posted by Kent Overstreet 1 year, 9 months ago
On Tue, Apr 16, 2024 at 08:16:02AM -0700, Nathan Chancellor wrote:
> When building for 32-bit platforms, for which size_t is 'unsigned int',
> there is a warning from a format string in validate_bset_keys():
> 
>   fs/bcachefs/btree_io.c: In function 'validate_bset_keys':
>   fs/bcachefs/btree_io.c:891:34: error: format '%lu' expects argument of type 'long unsigned int', but argument 12 has type 'unsigned int' [-Werror=format=]
>     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
>         |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   fs/bcachefs/btree_io.c:603:32: note: in definition of macro 'btree_err'
>     603 |                                msg, ##__VA_ARGS__);                     \
>         |                                ^~~
>   fs/bcachefs/btree_io.c:887:21: note: in expansion of macro 'btree_err_on'
>     887 |                 if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
>         |                     ^~~~~~~~~~~~
>   fs/bcachefs/btree_io.c:891:64: note: format string is defined here
>     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
>         |                                                              ~~^
>         |                                                                |
>         |                                                                long unsigned int
>         |                                                              %u
>   cc1: all warnings being treated as errors
> 
> BKEY_U64s is size_t so the entire expression is promoted to size_t. Use
> the '%zu' specifier so that there is no warning regardless of the width
> of size_t.
> 
> Fixes: 031ad9e7dbd1 ("bcachefs: Check for packed bkeys that are too big")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202404130747.wH6Dd23p-lkp@intel.com/
> Closes: https://lore.kernel.org/oe-kbuild-all/202404131536.HdAMBOVc-lkp@intel.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Thanks, applied
Re: [PATCH] bcachefs: Fix format specifier in validate_bset_keys()
Posted by Geert Uytterhoeven 1 year, 9 months ago
Hi Kent,

On Wed, Apr 17, 2024 at 12:09 AM Kent Overstreet
<kent.overstreet@linux.dev> wrote:
> On Tue, Apr 16, 2024 at 08:16:02AM -0700, Nathan Chancellor wrote:
> > When building for 32-bit platforms, for which size_t is 'unsigned int',
> > there is a warning from a format string in validate_bset_keys():
> >
> >   fs/bcachefs/btree_io.c: In function 'validate_bset_keys':
> >   fs/bcachefs/btree_io.c:891:34: error: format '%lu' expects argument of type 'long unsigned int', but argument 12 has type 'unsigned int' [-Werror=format=]
> >     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
> >         |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   fs/bcachefs/btree_io.c:603:32: note: in definition of macro 'btree_err'
> >     603 |                                msg, ##__VA_ARGS__);                     \
> >         |                                ^~~
> >   fs/bcachefs/btree_io.c:887:21: note: in expansion of macro 'btree_err_on'
> >     887 |                 if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
> >         |                     ^~~~~~~~~~~~
> >   fs/bcachefs/btree_io.c:891:64: note: format string is defined here
> >     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
> >         |                                                              ~~^
> >         |                                                                |
> >         |                                                                long unsigned int
> >         |                                                              %u
> >   cc1: all warnings being treated as errors
> >
> > BKEY_U64s is size_t so the entire expression is promoted to size_t. Use
> > the '%zu' specifier so that there is no warning regardless of the width
> > of size_t.
> >
> > Fixes: 031ad9e7dbd1 ("bcachefs: Check for packed bkeys that are too big")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202404130747.wH6Dd23p-lkp@intel.com/
> > Closes: https://lore.kernel.org/oe-kbuild-all/202404131536.HdAMBOVc-lkp@intel.com/
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Thanks, applied

This is still not fixed in today's linux-next, while the issue is now
causing breakage on several 32-bit defconfs in v6.9-rc5.

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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
Re: [PATCH] bcachefs: Fix format specifier in validate_bset_keys()
Posted by Kent Overstreet 1 year, 9 months ago
On Mon, Apr 22, 2024 at 02:47:32PM +0200, Geert Uytterhoeven wrote:
> Hi Kent,
> 
> On Wed, Apr 17, 2024 at 12:09 AM Kent Overstreet
> <kent.overstreet@linux.dev> wrote:
> > On Tue, Apr 16, 2024 at 08:16:02AM -0700, Nathan Chancellor wrote:
> > > When building for 32-bit platforms, for which size_t is 'unsigned int',
> > > there is a warning from a format string in validate_bset_keys():
> > >
> > >   fs/bcachefs/btree_io.c: In function 'validate_bset_keys':
> > >   fs/bcachefs/btree_io.c:891:34: error: format '%lu' expects argument of type 'long unsigned int', but argument 12 has type 'unsigned int' [-Werror=format=]
> > >     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
> > >         |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >   fs/bcachefs/btree_io.c:603:32: note: in definition of macro 'btree_err'
> > >     603 |                                msg, ##__VA_ARGS__);                     \
> > >         |                                ^~~
> > >   fs/bcachefs/btree_io.c:887:21: note: in expansion of macro 'btree_err_on'
> > >     887 |                 if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
> > >         |                     ^~~~~~~~~~~~
> > >   fs/bcachefs/btree_io.c:891:64: note: format string is defined here
> > >     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
> > >         |                                                              ~~^
> > >         |                                                                |
> > >         |                                                                long unsigned int
> > >         |                                                              %u
> > >   cc1: all warnings being treated as errors
> > >
> > > BKEY_U64s is size_t so the entire expression is promoted to size_t. Use
> > > the '%zu' specifier so that there is no warning regardless of the width
> > > of size_t.
> > >
> > > Fixes: 031ad9e7dbd1 ("bcachefs: Check for packed bkeys that are too big")
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202404130747.wH6Dd23p-lkp@intel.com/
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202404131536.HdAMBOVc-lkp@intel.com/
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> >
> > Thanks, applied
> 
> This is still not fixed in today's linux-next, while the issue is now
> causing breakage on several 32-bit defconfs in v6.9-rc5.

Apologies, I just neglected to update my for-next branch, it's in now.
bcachefs broken in next (was: Re: [PATCH] bcachefs: Fix format specifier in validate_bset_keys())
Posted by Geert Uytterhoeven 1 year, 9 months ago
Hi Kent,

On Mon, Apr 22, 2024 at 9:32 PM Kent Overstreet
<kent.overstreet@linux.dev> wrote:
> On Mon, Apr 22, 2024 at 02:47:32PM +0200, Geert Uytterhoeven wrote:
> > On Wed, Apr 17, 2024 at 12:09 AM Kent Overstreet
> > <kent.overstreet@linux.dev> wrote:
> > > On Tue, Apr 16, 2024 at 08:16:02AM -0700, Nathan Chancellor wrote:
> > > > When building for 32-bit platforms, for which size_t is 'unsigned int',
> > > > there is a warning from a format string in validate_bset_keys():
> > > >
> > > >   fs/bcachefs/btree_io.c: In function 'validate_bset_keys':
> > > >   fs/bcachefs/btree_io.c:891:34: error: format '%lu' expects argument of type 'long unsigned int', but argument 12 has type 'unsigned int' [-Werror=format=]
> > > >     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
> > > >         |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > >   fs/bcachefs/btree_io.c:603:32: note: in definition of macro 'btree_err'
> > > >     603 |                                msg, ##__VA_ARGS__);                     \
> > > >         |                                ^~~
> > > >   fs/bcachefs/btree_io.c:887:21: note: in expansion of macro 'btree_err_on'
> > > >     887 |                 if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
> > > >         |                     ^~~~~~~~~~~~
> > > >   fs/bcachefs/btree_io.c:891:64: note: format string is defined here
> > > >     891 |                                  "bad k->u64s %u (min %u max %lu)", k->u64s,
> > > >         |                                                              ~~^
> > > >         |                                                                |
> > > >         |                                                                long unsigned int
> > > >         |                                                              %u
> > > >   cc1: all warnings being treated as errors
> > > >
> > > > BKEY_U64s is size_t so the entire expression is promoted to size_t. Use
> > > > the '%zu' specifier so that there is no warning regardless of the width
> > > > of size_t.
> > > >
> > > > Fixes: 031ad9e7dbd1 ("bcachefs: Check for packed bkeys that are too big")
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Closes: https://lore.kernel.org/oe-kbuild-all/202404130747.wH6Dd23p-lkp@intel.com/
> > > > Closes: https://lore.kernel.org/oe-kbuild-all/202404131536.HdAMBOVc-lkp@intel.com/
> > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > >
> > > Thanks, applied
> >
> > This is still not fixed in today's linux-next, while the issue is now
> > causing breakage on several 32-bit defconfs in v6.9-rc5.
>
> Apologies, I just neglected to update my for-next branch, it's in now.

Thank you, I can confirm it is there.

However, linux-next is broken again on lots of configs
http://kisskb.ellerman.id.au/kisskb/head/a59668a9397e7245b26e9be85d23f242ff757ae8/

fs/bcachefs/btree_key_cache.c:1057:64: error: 'struct srcu_struct' has
no member named 'srcu_sup'; did you mean 'srcu_idx'?

I have bisected this to commit f2d47ec26af5b235 ("bcachefs: Btree key
cache instrumentation"), but I cannot find that patch on any mailing list
archived on lore.

Please do not include untested and/or unreviewed patches in any branches
included in linux-next.

Thank you!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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