All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: tree-checker: use %zu format string for size_t
@ 2017-12-06 14:18 Arnd Bergmann
  2017-12-06 14:23 ` David Sterba
  2017-12-07  0:32 ` Qu Wenruo
  0 siblings, 2 replies; 7+ messages in thread
From: Arnd Bergmann @ 2017-12-06 14:18 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: Arnd Bergmann, Qu Wenruo, Su Yue, Nikolay Borisov, linux-btrfs,
	linux-kernel

The return value of sizeof() is of type size_t, so we must print it
using the %z format modifier rather than %l to avoid this warning
on some architectures:

fs/btrfs/tree-checker.c: In function 'check_dir_item':
fs/btrfs/tree-checker.c:273:50: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'u32' {aka 'unsigned int'} [-Werror=format=]

Fixes: 005887f2e3e0 ("btrfs: tree-checker: Add checker for dir item")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 66dac0a4b01f..7c55e3ba5a6c 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -270,7 +270,7 @@ static int check_dir_item(struct btrfs_root *root,
 		/* header itself should not cross item boundary */
 		if (cur + sizeof(*di) > item_size) {
 			dir_item_err(root, leaf, slot,
-		"dir item header crosses item boundary, have %lu boundary %u",
+		"dir item header crosses item boundary, have %zu boundary %u",
 				cur + sizeof(*di), item_size);
 			return -EUCLEAN;
 		}
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] btrfs: tree-checker: use %zu format string for size_t
  2017-12-06 14:18 [PATCH] btrfs: tree-checker: use %zu format string for size_t Arnd Bergmann
@ 2017-12-06 14:23 ` David Sterba
  2017-12-07  0:32 ` Qu Wenruo
  1 sibling, 0 replies; 7+ messages in thread
From: David Sterba @ 2017-12-06 14:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Chris Mason, Josef Bacik, David Sterba, Qu Wenruo, Su Yue,
	Nikolay Borisov, linux-btrfs, linux-kernel

On Wed, Dec 06, 2017 at 03:18:14PM +0100, Arnd Bergmann wrote:
> The return value of sizeof() is of type size_t, so we must print it
> using the %z format modifier rather than %l to avoid this warning
> on some architectures:
> 
> fs/btrfs/tree-checker.c: In function 'check_dir_item':
> fs/btrfs/tree-checker.c:273:50: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'u32' {aka 'unsigned int'} [-Werror=format=]
> 
> Fixes: 005887f2e3e0 ("btrfs: tree-checker: Add checker for dir item")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] btrfs: tree-checker: use %zu format string for size_t
  2017-12-06 14:18 [PATCH] btrfs: tree-checker: use %zu format string for size_t Arnd Bergmann
  2017-12-06 14:23 ` David Sterba
@ 2017-12-07  0:32 ` Qu Wenruo
  2017-12-07  9:06   ` Arnd Bergmann
  2017-12-07 15:08   ` David Sterba
  1 sibling, 2 replies; 7+ messages in thread
From: Qu Wenruo @ 2017-12-07  0:32 UTC (permalink / raw)
  To: Arnd Bergmann, Chris Mason, Josef Bacik, David Sterba
  Cc: Qu Wenruo, Su Yue, Nikolay Borisov, linux-btrfs, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1443 bytes --]



On 2017年12月06日 22:18, Arnd Bergmann wrote:
> The return value of sizeof() is of type size_t, so we must print it
> using the %z format modifier rather than %l to avoid this warning
> on some architectures:
> 
> fs/btrfs/tree-checker.c: In function 'check_dir_item':
> fs/btrfs/tree-checker.c:273:50: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'u32' {aka 'unsigned int'} [-Werror=format=]

Any idea about which architecture will cause such warning?
On x86_64 I always fail to get such warning.

> 
> Fixes: 005887f2e3e0 ("btrfs: tree-checker: Add checker for dir item")

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  fs/btrfs/tree-checker.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
> index 66dac0a4b01f..7c55e3ba5a6c 100644
> --- a/fs/btrfs/tree-checker.c
> +++ b/fs/btrfs/tree-checker.c
> @@ -270,7 +270,7 @@ static int check_dir_item(struct btrfs_root *root,
>  		/* header itself should not cross item boundary */
>  		if (cur + sizeof(*di) > item_size) {
>  			dir_item_err(root, leaf, slot,
> -		"dir item header crosses item boundary, have %lu boundary %u",
> +		"dir item header crosses item boundary, have %zu boundary %u",
>  				cur + sizeof(*di), item_size);
>  			return -EUCLEAN;
>  		}
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] btrfs: tree-checker: use %zu format string for size_t
  2017-12-07  0:32 ` Qu Wenruo
@ 2017-12-07  9:06   ` Arnd Bergmann
  2017-12-07 15:08   ` David Sterba
  1 sibling, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2017-12-07  9:06 UTC (permalink / raw)
  To: Qu Wenruo
  Cc: Chris Mason, Josef Bacik, David Sterba, Qu Wenruo, Su Yue,
	Nikolay Borisov, linux-btrfs, Linux Kernel Mailing List

On Thu, Dec 7, 2017 at 1:32 AM, Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
>
>
> On 2017年12月06日 22:18, Arnd Bergmann wrote:
>> The return value of sizeof() is of type size_t, so we must print it
>> using the %z format modifier rather than %l to avoid this warning
>> on some architectures:
>>
>> fs/btrfs/tree-checker.c: In function 'check_dir_item':
>> fs/btrfs/tree-checker.c:273:50: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'u32' {aka 'unsigned int'} [-Werror=format=]
>
> Any idea about which architecture will cause such warning?
> On x86_64 I always fail to get such warning.

I think all 32-bit architectures:

#ifndef __kernel_size_t
#if __BITS_PER_LONG != 64
typedef unsigned int    __kernel_size_t;
typedef int             __kernel_ssize_t;
typedef int             __kernel_ptrdiff_t;
#else
typedef __kernel_ulong_t __kernel_size_t;
typedef __kernel_long_t __kernel_ssize_t;
typedef __kernel_long_t __kernel_ptrdiff_t;
#endif
#endif

      Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] btrfs: tree-checker: use %zu format string for size_t
  2017-12-07  0:32 ` Qu Wenruo
  2017-12-07  9:06   ` Arnd Bergmann
@ 2017-12-07 15:08   ` David Sterba
  1 sibling, 0 replies; 7+ messages in thread
From: David Sterba @ 2017-12-07 15:08 UTC (permalink / raw)
  To: Qu Wenruo
  Cc: Arnd Bergmann, Chris Mason, Josef Bacik, David Sterba, Qu Wenruo,
	Su Yue, Nikolay Borisov, linux-btrfs, linux-kernel

On Thu, Dec 07, 2017 at 08:32:04AM +0800, Qu Wenruo wrote:
> 
> 
> On 2017年12月06日 22:18, Arnd Bergmann wrote:
> > The return value of sizeof() is of type size_t, so we must print it
> > using the %z format modifier rather than %l to avoid this warning
> > on some architectures:
> > 
> > fs/btrfs/tree-checker.c: In function 'check_dir_item':
> > fs/btrfs/tree-checker.c:273:50: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'u32' {aka 'unsigned int'} [-Werror=format=]
> 
> Any idea about which architecture will cause such warning?
> On x86_64 I always fail to get such warning.

The intel 0-day build bot compiles on various architectures and 32/64
setups, I'm not sure if this warning has been reported, no such mail in
my mboxes.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] btrfs: tree-checker: use %zu format string for size_t
  2017-10-13  9:27 Arnd Bergmann
@ 2017-10-13 12:06 ` David Sterba
  0 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2017-10-13 12:06 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Chris Mason, Josef Bacik, David Sterba, Qu Wenruo, linux-btrfs,
	linux-kernel

On Fri, Oct 13, 2017 at 11:27:35AM +0200, Arnd Bergmann wrote:
> We now get a harmless compile-time on 32-bit architectures:
> 
> fs/btrfs/tree-checker.c: In function 'check_extent_data_item':
> fs/btrfs/tree-checker.c:189:70: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]
> 
> This changes the format string to use %zu instead of %lu for size_t.
> 
> Fixes: c1f6520bf360 ("btrfs: tree-checker: Enhance output for check_extent_data_item")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] btrfs: tree-checker: use %zu format string for size_t
@ 2017-10-13  9:27 Arnd Bergmann
  2017-10-13 12:06 ` David Sterba
  0 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2017-10-13  9:27 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: Arnd Bergmann, Qu Wenruo, linux-btrfs, linux-kernel

We now get a harmless compile-time on 32-bit architectures:

fs/btrfs/tree-checker.c: In function 'check_extent_data_item':
fs/btrfs/tree-checker.c:189:70: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]

This changes the format string to use %zu instead of %lu for size_t.

Fixes: c1f6520bf360 ("btrfs: tree-checker: Enhance output for check_extent_data_item")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index c7a09cc2a17c..388fb6553aa5 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -186,7 +186,7 @@ static int check_extent_data_item(struct btrfs_root *root,
 	/* Regular or preallocated extent has fixed item size */
 	if (item_size != sizeof(*fi)) {
 		file_extent_err(root, leaf, slot,
-			"invalid item size for reg/prealloc file extent, have %u expect %lu",
+			"invalid item size for reg/prealloc file extent, have %u expect %zu",
 			item_size, sizeof(*fi));
 		return -EUCLEAN;
 	}
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-12-07 15:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06 14:18 [PATCH] btrfs: tree-checker: use %zu format string for size_t Arnd Bergmann
2017-12-06 14:23 ` David Sterba
2017-12-07  0:32 ` Qu Wenruo
2017-12-07  9:06   ` Arnd Bergmann
2017-12-07 15:08   ` David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2017-10-13  9:27 Arnd Bergmann
2017-10-13 12:06 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.