Skip to contentSkip to conversation

btrfs: tree-checker: use %zu format string for size_t

PATCH In review Arnd Bergmann 3 participants 5 messages Dec 6, 2017 – Dec 7, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: tree-checker: use %zu format string for size_t

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")
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-checker.c +1 -1
index 66dac0a4b01f..7c55e3ba5a6c 100644
@@ -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;
 		}
Signature · 1 line
2.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnd Bergmann

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")
Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

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.

Quoted 2 lines
Fixes 005887f2e3e0 ("btrfs: tree-checker: Add checker for dir item")

Thanks,
Qu

Quoted 19 lines
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-checker.c +1 -1
index 66dac0a4b01f..7c55e3ba5a6c 100644
@@ -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;
 		}
#3 lore raw
Quoted 7 lines · Qu Wenruo
Quoted 4 lines · Arnd Bergmann

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:

Quoted 5 lines
Quoted 2 lines

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

#4 lore raw
In reply to Qu Wenruo
Quoted 7 lines · Qu Wenruo
Quoted 4 lines · Arnd Bergmann

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:

Quoted 5 lines
Quoted 2 lines

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.