mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-17 20:05:24 +00:00
btrfs-progs: fix printf formats on 32bit x86
When compiling btrfs-progs on 32bit x86 using GCC 11.1.0, there are several warnings: In file included from ./common/utils.h:30, from check/main.c:36: check/main.c: In function 'run_next_block': ./common/messages.h:42:31: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'u32' {aka 'unsigned int'} [-Wformat=] 42 | __btrfs_error((fmt), ##__VA_ARGS__); \ | ^~~~~ check/main.c:6496:33: note: in expansion of macro 'error' 6496 | error( | ^~~~~ In file included from ./common/utils.h:30, from kernel-shared/volumes.c:32: kernel-shared/volumes.c: In function 'btrfs_check_chunk_valid': ./common/messages.h:42:31: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'u32' {aka 'unsigned int'} [-Wformat=] 42 | __btrfs_error((fmt), ##__VA_ARGS__); \ | ^~~~~ kernel-shared/volumes.c:2052:17: note: in expansion of macro 'error' 2052 | error("invalid chunk item size, have %u expect [%zu, %lu)", | ^~~~~ image/main.c: In function 'search_for_chunk_blocks': ./common/messages.h:42:31: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=] 42 | __btrfs_error((fmt), ##__VA_ARGS__); \ | ^~~~~ image/main.c:2122:33: note: in expansion of macro 'error' 2122 | error( | ^~~~~ There are two types of problems: - __BTRFS_LEAF_DATA_SIZE() This macro has no type definition, making it behaves differently on different arches. Fix this by following kernel to use inline function to make its return value fixed to u32. - size_t related output For x86_64 %lu is OK but not for x86. Fix this by using %zu. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b1d8f945c9
commit
5bee5c99bf
@ -6494,7 +6494,7 @@ static int run_next_block(struct btrfs_root *root,
|
||||
if (btrfs_item_size_nr(buf, i) < inline_offset) {
|
||||
ret = -EUCLEAN;
|
||||
error(
|
||||
"invalid file extent item size, have %u expect (%lu, %lu]",
|
||||
"invalid file extent item size, have %u expect (%lu, %u]",
|
||||
btrfs_item_size_nr(buf, i),
|
||||
inline_offset,
|
||||
BTRFS_LEAF_DATA_SIZE(gfs_info));
|
||||
|
@ -2120,7 +2120,7 @@ static int search_for_chunk_blocks(struct mdrestore_struct *mdres)
|
||||
current_cluster);
|
||||
if (ret < 0) {
|
||||
error(
|
||||
"failed to search tree blocks in item bytenr %llu size %lu",
|
||||
"failed to search tree blocks in item bytenr %llu size %zu",
|
||||
item_bytenr, size);
|
||||
goto out;
|
||||
}
|
||||
|
@ -354,7 +354,11 @@ struct btrfs_header {
|
||||
u8 level;
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
|
||||
static inline u32 __BTRFS_LEAF_DATA_SIZE(u32 nodesize)
|
||||
{
|
||||
return nodesize - sizeof(struct btrfs_header);
|
||||
}
|
||||
|
||||
#define BTRFS_LEAF_DATA_SIZE(fs_info) \
|
||||
(__BTRFS_LEAF_DATA_SIZE(fs_info->nodesize))
|
||||
|
||||
|
@ -2094,7 +2094,7 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
|
||||
*/
|
||||
if (slot >= 0 &&
|
||||
btrfs_item_size_nr(leaf, slot) < sizeof(struct btrfs_chunk)) {
|
||||
error("invalid chunk item size, have %u expect [%zu, %lu)",
|
||||
error("invalid chunk item size, have %u expect [%zu, %u)",
|
||||
btrfs_item_size_nr(leaf, slot),
|
||||
sizeof(struct btrfs_chunk),
|
||||
BTRFS_LEAF_DATA_SIZE(fs_info));
|
||||
|
Loading…
Reference in New Issue
Block a user