lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230913214341.7qucftdltsljrzpf@google.com>
Date:   Wed, 13 Sep 2023 21:43:41 +0000
From:   Justin Stitt <justinstitt@...gle.com>
To:     Nathan Chancellor <nathan@...nel.org>
Cc:     kent.overstreet@...ux.dev, bfoster@...hat.com,
        linux-bcachefs@...r.kernel.org, linux-kernel@...r.kernel.org,
        llvm@...ts.linux.dev, patches@...ts.linux.dev
Subject: Re: [PATCH 2/7] bcachefs: Fix -Wformat in
 bch2_btree_key_cache_to_text()

On Tue, Sep 12, 2023 at 12:15:39PM -0700, Nathan Chancellor wrote:
> When building bcachefs for 32-bit ARM, there is a compiler warning in
> bch2_btree_key_cache_to_text() due to use of an incorrect format
> specifier:
>
>   fs/bcachefs/btree_key_cache.c:1060:36: error: format specifies type 'size_t' (aka 'unsigned int') but the argument has type 'long' [-Werror,-Wformat]
>    1060 |         prt_printf(out, "nr_freed:\t%zu",       atomic_long_read(&c->nr_freed));
>         |                                     ~~~         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>         |                                     %ld
>   fs/bcachefs/util.h:223:54: note: expanded from macro 'prt_printf'
>     223 | #define prt_printf(_out, ...)           bch2_prt_printf(_out, __VA_ARGS__)
>         |                                                               ^~~~~~~~~~~
>   1 error generated.
>
> On 64-bit architectures, size_t is 'unsigned long', so there is no
> warning when using %zu but on 32-bit architectures, size_t is
> 'unsigned int'. Use '%lu' to match the other format specifiers used in
> this function for printing values returned from atomic_long_read().
>
> Fixes: 6d799930ce0f ("bcachefs: btree key cache pcpu freedlist")
> Signed-off-by: Nathan Chancellor <nathan@...nel.org>
Reviewed-by: Justin Stitt <justinstitt@...gle.com>
> ---
>  fs/bcachefs/btree_key_cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
> index 505e7c365ab7..a74ee6d8a7cf 100644
> --- a/fs/bcachefs/btree_key_cache.c
> +++ b/fs/bcachefs/btree_key_cache.c
> @@ -1053,7 +1053,7 @@ int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc)
>
>  void bch2_btree_key_cache_to_text(struct printbuf *out, struct btree_key_cache *c)
>  {
> -	prt_printf(out, "nr_freed:\t%zu",	atomic_long_read(&c->nr_freed));
> +	prt_printf(out, "nr_freed:\t%lu",	atomic_long_read(&c->nr_freed));
>  	prt_newline(out);
>  	prt_printf(out, "nr_keys:\t%lu",	atomic_long_read(&c->nr_keys));
>  	prt_newline(out);
>
> --
> 2.42.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ