From b6346d2e2ede70a986068f9bcff93fabdce7bd75 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Tue, 3 Oct 2017 09:50:39 -0700 Subject: Fix mac build. "u64" is either an unsigned long (in __LP64__ builds) or an unsigned long long (otherwise). This CL adds a format string "PRIext4u64" to be used in place of "PRIu64" when referring to a variable of type "u64". related-to-build Test: make Change-Id: I6ef911dda3ebdcc0f895c54325b8a82b57a62ee6 --- ext4_utils/ext4_utils.c | 2 +- ext4_utils/extent.c | 10 +++++----- ext4_utils/include/ext4_utils/ext4_utils.h | 4 ++++ ext4_utils/make_ext4fs.c | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'ext4_utils') diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c index 07a92119..86098519 100644 --- a/ext4_utils/ext4_utils.c +++ b/ext4_utils/ext4_utils.c @@ -632,7 +632,7 @@ int read_ext(int fd, int verbose) printf(" Inodes per group: %d\n", info.inodes_per_group); printf(" Inode size: %d\n", info.inode_size); printf(" Label: %s\n", info.label); - printf(" Blocks: %"PRIu64"\n", aux_info.len_blocks); + printf(" Blocks: %"PRIext4u64"\n", aux_info.len_blocks); printf(" Block groups: %d\n", aux_info.groups); printf(" Reserved block group size: %d\n", info.bg_desc_reserve_blocks); printf(" Used %d/%d inodes and %d/%d blocks\n", diff --git a/ext4_utils/extent.c b/ext4_utils/extent.c index ff56a141..3cdf6605 100644 --- a/ext4_utils/extent.c +++ b/ext4_utils/extent.c @@ -150,7 +150,7 @@ static struct block_allocation *do_inode_allocate_extents( if (((int)(info.block_size - sizeof(struct ext4_extent_header) / sizeof(struct ext4_extent))) < allocation_len) { - error("File size %"PRIu64" is too big to fit in a single extent block\n", + error("File size %"PRIext4u64" is too big to fit in a single extent block\n", len); return NULL; } @@ -206,14 +206,14 @@ u8 *inode_allocate_data_extents(struct ext4_inode *inode, u64 len, alloc = do_inode_allocate_extents(inode, len, NULL); if (alloc == NULL) { - error("failed to allocate extents for %"PRIu64" bytes", len); + error("failed to allocate extents for %"PRIext4u64" bytes", len); return NULL; } if (backing_len) { data = extent_create_backing(alloc, backing_len); if (!data) - error("failed to create backing for %"PRIu64" bytes", backing_len); + error("failed to create backing for %"PRIext4u64" bytes", backing_len); } free_alloc(alloc); @@ -247,7 +247,7 @@ struct block_allocation* inode_allocate_file_extents(struct ext4_inode *inode, u alloc = do_inode_allocate_extents(inode, len, prealloc); if (alloc == NULL) { - error("failed to allocate extents for %"PRIu64" bytes", len); + error("failed to allocate extents for %"PRIext4u64" bytes", len); return NULL; } @@ -262,7 +262,7 @@ void inode_allocate_extents(struct ext4_inode *inode, u64 len) alloc = do_inode_allocate_extents(inode, len, NULL); if (alloc == NULL) { - error("failed to allocate extents for %"PRIu64" bytes", len); + error("failed to allocate extents for %"PRIext4u64" bytes", len); return; } diff --git a/ext4_utils/include/ext4_utils/ext4_utils.h b/ext4_utils/include/ext4_utils/ext4_utils.h index 75c72bbf..17a8056b 100644 --- a/ext4_utils/include/ext4_utils/ext4_utils.h +++ b/ext4_utils/include/ext4_utils/ext4_utils.h @@ -75,9 +75,13 @@ extern int force; #ifdef __LP64__ typedef unsigned long u64; typedef signed long s64; + +#define PRIext4u64 "lu" #else typedef unsigned long long u64; typedef signed long long s64; + +#define PRIext4u64 PRIu64 #endif typedef unsigned int u32; typedef unsigned short int u16; diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c index e550ac2e..077899a4 100644 --- a/ext4_utils/make_ext4fs.c +++ b/ext4_utils/make_ext4fs.c @@ -816,7 +816,7 @@ int make_ext4fs_internal(int fd, const char *_directory, const char *_target_out ext4_create_fs_aux_info(); - printf(" Blocks: %"PRIu64"\n", aux_info.len_blocks); + printf(" Blocks: %"PRIext4u64"\n", aux_info.len_blocks); printf(" Block groups: %d\n", aux_info.groups); printf(" Reserved block group size: %d\n", info.bg_desc_reserve_blocks); -- cgit v1.2.3