From: Andreas Dilger Date: Tue, 18 Feb 2014 17:12:32 +0000 (-0500) Subject: build: fix LLVM compiler warnings X-Git-Tag: v1.42.10~62 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d46e6c737947b336fd412f43c060955b07bd319;p=thirdparty%2Fe2fsprogs.git build: fix LLVM compiler warnings Fix a number of non-literal string format warnings from LLVM due to the use of _() that were not fixed in commit 45ff69ffeb. Fix mismatched int vs. __u64 format warnings in blkmap64_rb.c. There were also some comparisons of __u64 start or count <= 0. Change them to be comparisons == 0, or start + count overflow. Fix operator precedence warning for (value & (value - 1) != 0) introduced in 11d1116a7c0b. It seems "&" is lower precedence than "!=", so the above didn't fail for power-of-two values, but only odd values. Fortunately, either s_desc_size nor s_inode_size is valid if odd. Signed-off-by: Andreas Dilger Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/quota.c b/e2fsck/quota.c index 2fd98c945..42569bb98 100644 --- a/e2fsck/quota.c +++ b/e2fsck/quota.c @@ -31,7 +31,8 @@ static void move_quota_inode(ext2_filsys fs, ext2_ino_t from_ino, retval = ext2fs_read_inode(fs, from_ino, &inode); if (retval) { - com_err("ext2fs_read_inode", retval, _("in move_quota_inode")); + com_err("ext2fs_read_inode", retval, "%s", + _("in move_quota_inode")); return; } @@ -44,7 +45,7 @@ static void move_quota_inode(ext2_filsys fs, ext2_ino_t from_ino, retval = ext2fs_write_new_inode(fs, to_ino, &inode); if (retval) { - com_err("ext2fs_write_new_inode", retval, + com_err("ext2fs_write_new_inode", retval, "%s", _("in move_quota_inode")); return; } diff --git a/e2fsck/super.c b/e2fsck/super.c index b0cc440fb..736cfea6a 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -30,9 +30,9 @@ static void check_super_value(e2fsck_t ctx, const char *descr, { struct problem_context pctx; - if (((flags & MIN_CHECK) && (value < min_val)) || - ((flags & MAX_CHECK) && (value > max_val)) || - ((flags & LOG2_CHECK) && (value & (value - 1) != 0))) { + if ((flags & MIN_CHECK && value < min_val) || + (flags & MAX_CHECK && value > max_val) || + (flags & LOG2_CHECK && (value & (value - 1)) != 0)) { clear_problem_context(&pctx); pctx.num = value; pctx.str = descr; diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c index 148f85655..a48475108 100644 --- a/lib/ext2fs/blkmap64_rb.c +++ b/lib/ext2fs/blkmap64_rb.c @@ -89,15 +89,15 @@ static void check_tree(struct rb_root *root, const char *msg) for (node = ext2fs_rb_first(root); node; node = ext2fs_rb_next(node)) { ext = node_to_extent(node); - if (ext->count <= 0) { - printf("Tree Error: count is crazy\n"); - printf("extent: %llu -> %llu (%u)\n", ext->start, + if (ext->count == 0) { + printf("Tree Error: count is zero\n"); + printf("extent: %llu -> %llu (%llu)\n", ext->start, ext->start + ext->count, ext->count); goto err_out; } - if (ext->start < 0) { - printf("Tree Error: start is crazy\n"); - printf("extent: %llu -> %llu (%u)\n", ext->start, + if (ext->start + ext->count < ext->start) { + printf("Tree Error: start or count is crazy\n"); + printf("extent: %llu -> %llu (%llu)\n", ext->start, ext->start + ext->count, ext->count); goto err_out; } @@ -105,20 +105,20 @@ static void check_tree(struct rb_root *root, const char *msg) if (old) { if (old->start > ext->start) { printf("Tree Error: start is crazy\n"); - printf("extent: %llu -> %llu (%u)\n", + printf("extent: %llu -> %llu (%llu)\n", old->start, old->start + old->count, old->count); - printf("extent next: %llu -> %llu (%u)\n", + printf("extent next: %llu -> %llu (%llu)\n", ext->start, ext->start + ext->count, ext->count); goto err_out; } if ((old->start + old->count) >= ext->start) { printf("Tree Error: extent is crazy\n"); - printf("extent: %llu -> %llu (%u)\n", + printf("extent: %llu -> %llu (%llu)\n", old->start, old->start + old->count, old->count); - printf("extent next: %llu -> %llu (%u)\n", + printf("extent next: %llu -> %llu (%llu)\n", ext->start, ext->start + ext->count, ext->count); goto err_out; diff --git a/misc/e2image.c b/misc/e2image.c index 6c5113779..338d239c7 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -165,7 +165,7 @@ static void generic_write(int fd, void *buf, int blocksize, blk64_t block) free_buf = 1; err = ext2fs_get_arrayzero(1, blocksize, &buf); if (err) { - com_err(program_name, err, + com_err(program_name, err, "%s", _("while allocating buffer")); exit(1); } @@ -187,7 +187,8 @@ static void generic_write(int fd, void *buf, int blocksize, blk64_t block) com_err(program_name, err, _("error writing block %llu"), block); else - com_err(program_name, err, _("error in write()")); + com_err(program_name, err, "%s", + _("error in generic_write()")); exit(1); } @@ -571,16 +572,18 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd, int flags) retval = ext2fs_get_mem(fs->blocksize, &buf); if (retval) { - com_err(program_name, retval, _("while allocating buffer")); + com_err(program_name, retval, "%s", + _("while allocating buffer")); exit(1); } retval = ext2fs_get_memzero(fs->blocksize, &zero_buf); if (retval) { - com_err(program_name, retval, _("while allocating buffer")); + com_err(program_name, retval, "%s", + _("while allocating buffer")); exit(1); } if (show_progress) { - fprintf(stderr, _("Copying ")); + fprintf(stderr, "%s", _("Copying ")); bscount = print_progress(total_written, meta_blocks_count); fflush(stderr); last_update = time(NULL); @@ -604,21 +607,23 @@ more_blocks: if (got_sigint) { if (distance) { /* moving to the right */ - if (distance >= ext2fs_blocks_count(fs->super) || - start == ext2fs_blocks_count(fs->super) - distance) - kill (getpid(), SIGINT); + if (distance >= ext2fs_blocks_count(fs->super)|| + start == ext2fs_blocks_count(fs->super) - + distance) + kill(getpid(), SIGINT); } else { /* moving to the left */ - if (blk < (source_offset - dest_offset) / fs->blocksize) - kill (getpid(), SIGINT); + if (blk < (source_offset - dest_offset) / + fs->blocksize) + kill(getpid(), SIGINT); } if (show_progress) fputc('\r', stderr); - fprintf(stderr, + fprintf(stderr, "%s", _("Stopping now will destroy the filesystem, " "interrupt again if you are sure\n")); if (show_progress) { - fprintf(stderr, _("Copying ")); + fprintf(stderr, "%s", _("Copying ")); bscount = print_progress(total_written, meta_blocks_count); fflush(stderr); @@ -639,11 +644,12 @@ more_blocks: total_written) - duration; char buff[30]; strftime(buff, 30, "%T", gmtime(&est)); - bscount += fprintf(stderr, - _(" %s remaining at %.2f MB/s"), - buff, calc_rate(total_written, - fs->blocksize, - duration)); + bscount += + fprintf(stderr, + _(" %s remaining at %.2f MB/s"), + buff, calc_rate(total_written, + fs->blocksize, + duration)); } fflush (stderr); } @@ -745,7 +751,8 @@ static void init_l1_table(struct ext2_qcow2_image *image) ret = ext2fs_get_arrayzero(image->l1_size, sizeof(__u64), &l1_table); if (ret) { - com_err(program_name, ret, _("while allocating l1 table")); + com_err(program_name, ret, "%s", + _("while allocating l1 table")); exit(1); } @@ -790,7 +797,7 @@ static void init_l2_cache(struct ext2_qcow2_image *image) return; alloc_err: - com_err(program_name, ret, _("while allocating l2 cache")); + com_err(program_name, ret, "%s", _("while allocating l2 cache")); exit(1); } @@ -813,9 +820,10 @@ again: } if (cache->free != cache->count) { - fprintf(stderr, _("Warning: There are still tables in the " - "cache while putting the cache, data will " - "be lost so the image may not be valid.\n")); + fprintf(stderr, "%s", _("Warning: There are still tables in " + "the cache while putting the cache, " + "data will be lost so the image may " + "not be valid.\n")); table = cache->used_head; cache->used_head = NULL; goto again; @@ -1133,14 +1141,14 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd) /* allocate struct ext2_qcow2_image */ retval = ext2fs_get_mem(sizeof(struct ext2_qcow2_image), &img); if (retval) { - com_err(program_name, retval, + com_err(program_name, retval, "%s", _("while allocating ext2_qcow2_image")); exit(1); } retval = initialize_qcow2_image(fd, fs, img); if (retval) { - com_err(program_name, retval, + com_err(program_name, retval, "%s", _("while initializing ext2_qcow2_image")); exit(1); } @@ -1166,7 +1174,8 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd) retval = ext2fs_get_mem(fs->blocksize, &buf); if (retval) { - com_err(program_name, retval, _("while allocating buffer")); + com_err(program_name, retval, "%s", + _("while allocating buffer")); exit(1); } /* Write qcow2 data blocks */ @@ -1198,9 +1207,10 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd) * block should not be created! */ if (update_refcount(fd, img, offset, offset)) { - fprintf(stderr, _("Programming error: " - "multiple sequential refcount " - "blocks created!\n")); + fprintf(stderr, "%s", + _("Programming error: multiple " + "sequential refcount blocks " + "created!\n")); exit(1); } } @@ -1215,7 +1225,7 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd) offset += img->cluster_size; if (update_refcount(fd, img, offset, offset)) { - fprintf(stderr, + fprintf(stderr, "%s", _("Programming error: multiple sequential refcount " "blocks created!\n")); exit(1); @@ -1255,7 +1265,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags) retval = ext2fs_allocate_block_bitmap(fs, _("in-use block map"), &meta_block_map); if (retval) { - com_err(program_name, retval, + com_err(program_name, retval, "%s", _("while allocating block bitmap")); exit(1); } @@ -1264,7 +1274,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags) retval = ext2fs_allocate_block_bitmap(fs, "scramble block map", &scramble_block_map); if (retval) { - com_err(program_name, retval, + com_err(program_name, retval, "%s", _("while allocating scramble block bitmap")); exit(1); } @@ -1272,11 +1282,11 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags) mark_table_blocks(fs); if (show_progress) - printf(_("Scanning inodes...\n")); + printf("%s", _("Scanning inodes...\n")); retval = ext2fs_open_inode_scan(fs, 0, &scan); if (retval) { - com_err(program_name, retval,"%s", + com_err(program_name, retval, "%s", _("while opening inode scan")); exit(1); } @@ -1367,8 +1377,8 @@ static void install_image(char *device, char *image_fn, int type) io_channel io; if (type) { - com_err(program_name, 0, _("Raw and qcow2 images cannot" - "be installed")); + com_err(program_name, 0, "%s", + _("Raw and qcow2 images cannot be installed")); exit(1); } @@ -1383,14 +1393,14 @@ static void install_image(char *device, char *image_fn, int type) retval = ext2fs_open (image_fn, open_flag, 0, 0, io_ptr, &fs); if (retval) { - com_err (program_name, retval, _("while trying to open %s"), - image_fn); + com_err(program_name, retval, _("while trying to open %s"), + image_fn); exit(1); } retval = ext2fs_read_bitmaps (fs); if (retval) { - com_err(program_name, retval, _("error reading bitmaps")); + com_err(program_name, retval, "%s", _("error reading bitmaps")); exit(1); } @@ -1402,7 +1412,7 @@ static void install_image(char *device, char *image_fn, int type) retval = io_ptr->open(device, IO_FLAG_RW, &io); if (retval) { - com_err(device, 0, _("while opening device file")); + com_err(device, 0, "%s", _("while opening device file")); exit(1); } @@ -1412,7 +1422,8 @@ static void install_image(char *device, char *image_fn, int type) retval = ext2fs_image_inode_read(fs, fd, 0); if (retval) { - com_err(image_fn, 0, _("while restoring the image table")); + com_err(image_fn, 0, "%s", + _("while restoring the image table")); exit(1); } @@ -1509,22 +1520,22 @@ int main (int argc, char ** argv) usage(); if (all_data && !img_type) { - com_err(program_name, 0, _("-a option can only be used " - "with raw or QCOW2 images.")); + com_err(program_name, 0, "%s", _("-a option can only be used " + "with raw or QCOW2 images.")); exit(1); } if ((source_offset || dest_offset) && img_type != E2IMAGE_RAW) { - com_err(program_name, 0, + com_err(program_name, 0, "%s", _("Offsets are only allowed with raw images.")); exit(1); } if (move_mode && img_type != E2IMAGE_RAW) { - com_err(program_name, 0, + com_err(program_name, 0, "%s", _("Move mode is only allowed with raw images.")); exit(1); } if (move_mode && !all_data) { - com_err(program_name, 0, + com_err(program_name, 0, "%s", _("Move mode requires all data mode.")); exit(1); } @@ -1535,14 +1546,14 @@ int main (int argc, char ** argv) retval = ext2fs_check_if_mounted(device_name, &mount_flags); if (retval) { - com_err(program_name, retval, _("checking if mounted")); + com_err(program_name, retval, "%s", _("checking if mounted")); exit(1); } if (img_type && !ignore_rw_mount && (mount_flags & EXT2_MF_MOUNTED) && !(mount_flags & EXT2_MF_READONLY)) { - fprintf(stderr, _("\nRunning e2image on a R/W mounted " + fprintf(stderr, "%s", _("\nRunning e2image on a R/W mounted " "filesystem can result in an\n" "inconsistent image which will not be useful " "for debugging purposes.\n" @@ -1593,13 +1604,14 @@ skip_device: seek_set(fd, dest_offset); if ((img_type & E2IMAGE_QCOW2) && (fd == 1)) { - com_err(program_name, 0, _("QCOW2 image can not be written to " - "the stdout!\n")); + com_err(program_name, 0, "%s", + _("QCOW2 image can not be written to the stdout!\n")); exit(1); } if (fd != 1) { if (fstat(fd, &st)) { - com_err(program_name, 0, _("Can not stat output\n")); + com_err(program_name, 0, "%s", + _("Can not stat output\n")); exit(1); } if (S_ISBLK(st.st_mode)) @@ -1624,25 +1636,25 @@ skip_device: if (check) { if (img_type != E2IMAGE_RAW) { - fprintf(stderr, _("The -c option only supported " - "in raw mode\n")); + fprintf(stderr, "%s", _("The -c option only supported " + "in raw mode\n")); exit(1); } if (fd == 1) { - fprintf(stderr, _("The -c option is not supported " - "when writing to stdout\n")); + fprintf(stderr, "%s", _("The -c option not supported " + "when writing to stdout\n")); exit(1); } retval = ext2fs_get_mem(fs->blocksize, &check_buf); if (retval) { - com_err(program_name, retval, + com_err(program_name, retval, "%s", _("while allocating check_buf")); exit(1); } } if (show_progress && (img_type != E2IMAGE_RAW)) { - fprintf(stderr, _("The -p option only supported " - "in raw mode\n")); + fprintf(stderr, "%s", + _("The -p option only supported in raw mode\n")); exit(1); } if (img_type) @@ -1652,7 +1664,7 @@ skip_device: ext2fs_close (fs); if (check) - printf(_("%d blocks already contained the data to be copied.\n"), + printf(_("%d blocks already contained the data to be copied\n"), skipped_blocks); out: diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c index debc3fe4a..d4dadc454 100644 --- a/misc/mk_hugefiles.c +++ b/misc/mk_hugefiles.c @@ -409,7 +409,7 @@ errcode_t mk_hugefiles(ext2_filsys fs) if (!quiet) { if (zero_hugefile && verbose) - printf(_("Huge files will be zero'ed\n")); + printf("%s", _("Huge files will be zero'ed\n")); printf(_("Creating %lu huge file(s) "), num_files); if (num_blocks) printf(_("with %llu blocks each"), num_blocks); diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 4eef9b20f..e56055242 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -369,7 +369,7 @@ static int check_fsck_needed(ext2_filsys fs) return 0; printf("\n%s\n", _(please_fsck)); if (mount_flags & EXT2_MF_READONLY) - printf(_("(and reboot afterwards!)\n")); + printf("%s", _("(and reboot afterwards!)\n")); return 1; }