From 377e3a96571b12d23662131b461a033618ab805c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 2 Jun 2016 22:40:41 -0400 Subject: [PATCH] misc: fix gcc -Wall complaints Especially when compiling for a 32-bit architecture. Signed-off-by: Theodore Ts'o --- misc/e2fuzz.c | 5 +++-- misc/e2undo.c | 4 ++-- misc/fuse2fs.c | 36 +++++++++++++++++++++++------------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/misc/e2fuzz.c b/misc/e2fuzz.c index 5e33239f..8576d4ee 100644 --- a/misc/e2fuzz.c +++ b/misc/e2fuzz.c @@ -276,8 +276,9 @@ static int process_fs(const char *fsname) if ((rand() % 2) && c < 128) c |= 0x80; if (verbose) - printf("Corrupting byte %zu in block %zu to 0x%x\n", - off % fs->blocksize, off / fs->blocksize, c); + printf("Corrupting byte %lld in block %lld to 0x%x\n", + (long long) off % fs->blocksize, + (long long) off / fs->blocksize, c); if (dryrun) continue; #ifdef HAVE_PWRITE64 diff --git a/misc/e2undo.c b/misc/e2undo.c index 9ef3d96a..72e756aa 100644 --- a/misc/e2undo.c +++ b/misc/e2undo.c @@ -303,7 +303,7 @@ int main(int argc, char *argv[]) __u32 key_crc, blk_crc, hdr_crc; blk64_t lblk; ext2_filsys fs; - __u64 offset; + __u64 offset = 0; char opt_offset_string[40] = { 0 }; #ifdef ENABLE_NLS @@ -455,7 +455,7 @@ int main(int argc, char *argv[]) offset = ext2fs_le64_to_cpu(undo_ctx.hdr.fs_offset); retval = snprintf(opt_offset_string, sizeof(opt_offset_string), "offset=%llu", offset); - if (retval >= sizeof(opt_offset_string)) { + if ((size_t) retval >= sizeof(opt_offset_string)) { /* should not happen... */ com_err(prg_name, 0, _("specified offset is too large")); exit(1); diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 5a19f233..9fdbf30a 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -2125,7 +2125,7 @@ static int __op_open(struct fuse2fs *ff, const char *path, } else goto out; } - fp->fh = (uint64_t)file; + fp->fh = (uintptr_t)file; out: if (ret) @@ -2152,7 +2152,8 @@ static int op_read(const char *path EXT2FS_ATTR((unused)), char *buf, { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; ext2_file_t efp; errcode_t err; @@ -2208,7 +2209,8 @@ static int op_write(const char *path EXT2FS_ATTR((unused)), { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; ext2_file_t efp; errcode_t err; @@ -2279,7 +2281,8 @@ static int op_release(const char *path EXT2FS_ATTR((unused)), { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; errcode_t err; int ret = 0; @@ -2308,7 +2311,8 @@ static int op_fsync(const char *path EXT2FS_ATTR((unused)), { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; errcode_t err; int ret = 0; @@ -2767,7 +2771,8 @@ static int op_readdir(const char *path EXT2FS_ATTR((unused)), { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; errcode_t err; struct readdir_iter i; @@ -2952,7 +2957,8 @@ static int op_ftruncate(const char *path EXT2FS_ATTR((unused)), { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; ext2_file_t efp; errcode_t err; @@ -3005,7 +3011,8 @@ static int op_fgetattr(const char *path EXT2FS_ATTR((unused)), struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; ext2_filsys fs; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; int ret = 0; FUSE2FS_CHECK_CONTEXT(ff); @@ -3258,7 +3265,8 @@ static int op_ioctl(const char *path EXT2FS_ATTR((unused)), int cmd, { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; int ret = 0; @@ -3333,7 +3341,8 @@ static int fallocate_helper(struct fuse_file_info *fp, int mode, off_t offset, { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; struct ext2_inode_large inode; blk64_t start, end; @@ -3468,7 +3477,8 @@ static int punch_helper(struct fuse_file_info *fp, int mode, off_t offset, { struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; - struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)fp->fh; + struct fuse2fs_file_handle *fh = + (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; ext2_filsys fs; struct ext2_inode_large inode; blk64_t start, end; @@ -3815,8 +3825,8 @@ int main(int argc, char *argv[]) printf("%s", _("Warning: Maximal mount count reached, running " "e2fsck is recommended.\n")); if (global_fs->super->s_checkinterval > 0 && - global_fs->super->s_lastcheck + - global_fs->super->s_checkinterval <= time(0)) + (time_t) (global_fs->super->s_lastcheck + + global_fs->super->s_checkinterval) <= time(0)) printf("%s", _("Warning: Check time reached; running e2fsck " "is recommended.\n")); if (global_fs->super->s_last_orphan)