patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: kent.overstreet@linux.dev
Cc: bfoster@redhat.com, linux-bcachefs@vger.kernel.org,
	 linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	patches@lists.linux.dev,  Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 3/7] bcachefs: Fix -Wformat in bch2_alloc_v4_invalid()
Date: Tue, 12 Sep 2023 12:15:40 -0700	[thread overview]
Message-ID: <20230912-bcachefs-warning-fixes-v1-3-a1cc83a38836@kernel.org> (raw)
In-Reply-To: <20230912-bcachefs-warning-fixes-v1-0-a1cc83a38836@kernel.org>

When building bcachefs for 32-bit ARM, there is a compiler warning in
bch2_alloc_v4_invalid() due to use of an incorrect format specifier:

  fs/bcachefs/alloc_background.c:246:30: error: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Werror,-Wformat]
    245 |                 prt_printf(err, "bad val size (%u > %lu)",
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |                                                     %u
    246 |                        alloc_v4_u64s(a.v), bkey_val_u64s(k.k));
        |                        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
  fs/bcachefs/bkey.h:58:27: note: expanded from macro 'bkey_val_u64s'
     58 | #define bkey_val_u64s(_k)       ((_k)->u64s - BKEY_U64s)
        |                                 ^
  fs/bcachefs/util.h:223:54: note: expanded from macro 'prt_printf'
    223 | #define prt_printf(_out, ...)           bch2_prt_printf(_out, __VA_ARGS__)
        |                                                               ^~~~~~~~~~~

This expression is of type 'size_t'. On 64-bit architectures, size_t is
'unsigned long', so there is no warning when using %lu but on 32-bit
architectures, size_t is 'unsigned int'. Use '%zu', the format specifier
for 'size_t' to eliminate the warning.

Fixes: 11be8e8db283 ("bcachefs: New on disk format: Backpointers")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 fs/bcachefs/alloc_background.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 540d94c0cceb..67e73864823c 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -242,7 +242,7 @@ int bch2_alloc_v4_invalid(const struct bch_fs *c, struct bkey_s_c k,
 	struct bkey_s_c_alloc_v4 a = bkey_s_c_to_alloc_v4(k);
 
 	if (alloc_v4_u64s(a.v) > bkey_val_u64s(k.k)) {
-		prt_printf(err, "bad val size (%u > %lu)",
+		prt_printf(err, "bad val size (%u > %zu)",
 		       alloc_v4_u64s(a.v), bkey_val_u64s(k.k));
 		return -BCH_ERR_invalid_bkey;
 	}

-- 
2.42.0


  parent reply	other threads:[~2023-09-12 19:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12 19:15 [PATCH 0/7] bcachefs compiler warning fixes for 32-bit Nathan Chancellor
2023-09-12 19:15 ` [PATCH 1/7] bcachefs: Fix -Wformat in bch2_set_bucket_needs_journal_commit() Nathan Chancellor
2023-09-13 21:42   ` Justin Stitt
2023-09-12 19:15 ` [PATCH 2/7] bcachefs: Fix -Wformat in bch2_btree_key_cache_to_text() Nathan Chancellor
2023-09-13 21:43   ` Justin Stitt
2023-09-12 19:15 ` Nathan Chancellor [this message]
2023-09-13 21:46   ` [PATCH 3/7] bcachefs: Fix -Wformat in bch2_alloc_v4_invalid() Justin Stitt
2023-09-12 19:15 ` [PATCH 4/7] bcachefs: Fix -Wformat in bch2_bucket_gens_invalid() Nathan Chancellor
2023-09-13 21:46   ` Justin Stitt
2023-09-12 19:15 ` [PATCH 5/7] bcachefs: Fix -Wincompatible-function-pointer-types-strict from key_invalid callbacks Nathan Chancellor
2023-09-13 21:57   ` Justin Stitt
2023-09-12 19:15 ` [PATCH 6/7] bcachefs: Fix -Wcompare-distinct-pointer-types in do_encrypt() Nathan Chancellor
2023-09-13 21:59   ` Justin Stitt
2023-09-12 19:15 ` [PATCH 7/7] bcachefs: Fix -Wcompare-distinct-pointer-types in bch2_copygc_get_buckets() Nathan Chancellor
2023-09-13 22:06   ` Justin Stitt
2023-09-12 19:36 ` [PATCH 0/7] bcachefs compiler warning fixes for 32-bit Kent Overstreet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230912-bcachefs-warning-fixes-v1-3-a1cc83a38836@kernel.org \
    --to=nathan@kernel.org \
    --cc=bfoster@redhat.com \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=patches@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).