Skip to contentSkip to conversation

btrfs: fix size_t format string

PATCH In review Arnd Bergmann 4 participants 6 messages Jul 17, 2018 – Jul 24, 2018 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix size_t format string

The newly added check_block_group_item() function causes a build warning on 32-bit architectures:

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

The type of a sizeof() expression is size_t, which is correctly printed using the %zu format string.

Fixes 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-checker.c +1 -1
index e9414c3f375e..4c82a628df85 100644
@@ -401,7 +401,7 @@ static int check_block_group_item(struct btrfs_fs_info *fs_info,
 
 	if (item_size != sizeof(bgi)) {
 		block_group_err(fs_info, leaf, slot,
-			"invalid item size, have %u expect %lu",
+			"invalid item size, have %u expect %zu",
 				item_size, sizeof(bgi));
 		return -EUCLEAN;
 	}
Signature · 1 line
2.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

The newly added check_block_group_item() function causes a build warning on 32-bit architectures:

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

The type of a sizeof() expression is size_t, which is correctly printed using the %zu format string.

Fixes 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")

My fault again. :(

Is there anyway to make gcc report such problem even under x86_64?

Quoted 1 line

Thanks,
Qu

Quoted 18 lines
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-checker.c +1 -1
index e9414c3f375e..4c82a628df85 100644
@@ -401,7 +401,7 @@ static int check_block_group_item(struct btrfs_fs_info *fs_info,
 
 	if (item_size != sizeof(bgi)) {
 		block_group_err(fs_info, leaf, slot,
-			"invalid item size, have %u expect %lu",
+			"invalid item size, have %u expect %zu",
 				item_size, sizeof(bgi));
 		return -EUCLEAN;
 	}
#3 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

The newly added check_block_group_item() function causes a build warning on 32-bit architectures:

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

The type of a sizeof() expression is size_t, which is correctly printed using the %zu format string.

Fixes 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")

Folded to the commit, thanks.

#2 lore raw
In reply to Qu Wenruo
Quoted 9 lines · Qu Wenruo
Quoted 6 lines · Arnd Bergmann

The newly added check_block_group_item() function causes a build warning on 32-bit architectures:

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

Quoted 8 lines
Quoted 4 lines

The type of a sizeof() expression is size_t, which is correctly printed using the %zu format string.

Fixes 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")

My fault again. :(

Is there anyway to make gcc report such problem even under x86_64?

I don't think so. However, if you post a patch to the mainling list, the 0-day bot should report any build regressions within a day.

Arnd

#4 lore raw
In reply to David Sterba
Quoted 7 lines · David Sterba
Quoted 6 lines · Arnd Bergmann

The newly added check_block_group_item() function causes a build warning on 32-bit architectures:

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

Quoted 7 lines
Quoted 4 lines

The type of a sizeof() expression is size_t, which is correctly printed using the %zu format string.

Fixes 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")

Folded to the commit, thanks.

Hi David,
Where did this patch end up? linux-next-20180723 is still showing this format warning.

thanks,

Signature · 1 line
~Randy
#5 lore raw
Quoted 11 lines · Randy Dunlap
Quoted 10 lines · David Sterba
Quoted 9 lines · Arnd Bergmann

The newly added check_block_group_item() function causes a build warning on 32-bit architectures:

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

The type of a sizeof() expression is size_t, which is correctly printed using the %zu format string.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Fixes 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")

Folded to the commit, thanks.

Hi David,
Where did this patch end up? linux-next-20180723 is still showing this format warning.

It's still in a local branch, I haven't pushed for-next for a few days but will do today.