Whamcloud - gitweb
Fix signed vs unsigned printf format strings for block and inode numbers
authorEric Sandeen <esandeen@redhat.com>
Tue, 12 Sep 2006 18:56:15 +0000 (14:56 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 12 Sep 2006 18:56:15 +0000 (14:56 -0400)
There were still some %d's lurking when we print blocks & inodes; also
many of the counters in the e2fsck_struct were signed, and probably
need to be unsigned to avoid overflows.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
22 files changed:
debugfs/ChangeLog
debugfs/htree.c
e2fsck/ChangeLog
e2fsck/e2fsck.h
e2fsck/emptydir.c
e2fsck/iscan.c
e2fsck/unix.c
lib/ext2fs/ChangeLog
lib/ext2fs/bmove.c
lib/ext2fs/getsize.c
lib/ext2fs/icount.c
lib/ext2fs/tst_badblocks.c
lib/ext2fs/tst_getsize.c
lib/ext2fs/tst_iscan.c
lib/ext2fs/unix_io.c
lib/ext2fs/write_bb_file.c
misc/ChangeLog
misc/dumpe2fs.c
misc/e2image.c
misc/mke2fs.c
resize/ChangeLog
resize/online.c

index c451651..96cae61 100644 (file)
@@ -1,3 +1,7 @@
+2006-08-30  Eric Sandeen <esandeen@redhat.com>
+
+       * htree.c (htree_dump_int_node): Fix printf formats.
+
 2006-08-29  Theodore Tso  <tytso@mit.edu>
 
        * lsdel.c (do_lsdel): Fix core-dumping bug.  Don't depend on
index a266cb3..4e5286f 100644 (file)
@@ -114,7 +114,7 @@ static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
 
        for (i=0; i < limit.count; i++) {
                hash = i ? ext2fs_le32_to_cpu(ent[i].hash) : 0;
-               fprintf(pager, "Entry #%d: Hash 0x%08x%s, block %d\n", i,
+               fprintf(pager, "Entry #%d: Hash 0x%08x%s, block %u\n", i,
                        hash, (hash & 1) ? " (**)" : "",
                        ext2fs_le32_to_cpu(ent[i].block));
                }
index d2e2e29..48920d5 100644 (file)
@@ -1,5 +1,12 @@
 2006-08-30  Eric Sandeen <esandeen@redhat.com>
 
+       * e2fsck.h (e2fsck): Use unsigned types for filesystem counters.
+       * emptydir.c (add_empty_dirblock):
+       * iscan.c (main):
+       * unix.c (show_stats, check_if_skip): Fix printf formats.
+
+2006-08-30  Eric Sandeen <esandeen@redhat.com>
+
        * pass1.c (handle_fs_bad_blocks): Remove unused variables.
 
 2006-08-30  Eric Sandeen <esandeen@redhat.com>
index 4fbe467..638249e 100644 (file)
@@ -309,24 +309,24 @@ struct e2fsck_struct {
        char start_meta[2], stop_meta[2];
        
        /* File counts */
-       int fs_directory_count;
-       int fs_regular_count;
-       int fs_blockdev_count;
-       int fs_chardev_count;
-       int fs_links_count;
-       int fs_symlinks_count;
-       int fs_fast_symlinks_count;
-       int fs_fifo_count;
-       int fs_total_count;
-       int fs_badblocks_count;
-       int fs_sockets_count;
-       int fs_ind_count;
-       int fs_dind_count;
-       int fs_tind_count;
-       int fs_fragmented;
-       int large_files;
-       int fs_ext_attr_inodes;
-       int fs_ext_attr_blocks;
+       __u32 fs_directory_count;
+       __u32 fs_regular_count;
+       __u32 fs_blockdev_count;
+       __u32 fs_chardev_count;
+       __u32 fs_links_count;
+       __u32 fs_symlinks_count;
+       __u32 fs_fast_symlinks_count;
+       __u32 fs_fifo_count;
+       __u32 fs_total_count;
+       __u32 fs_badblocks_count;
+       __u32 fs_sockets_count;
+       __u32 fs_ind_count;
+       __u32 fs_dind_count;
+       __u32 fs_tind_count;
+       __u32 fs_fragmented;
+       __u32 large_files;
+       __u32 fs_ext_attr_inodes;
+       __u32 fs_ext_attr_blocks;
 
        time_t now;
 
index ea39a09..d29f08f 100644 (file)
@@ -94,7 +94,7 @@ void add_empty_dirblock(empty_dir_info edi,
        if (db->ino == 11)
                return;         /* Inode number 11 is usually lost+found */
 
-       printf(_("Empty directory block %u (#%d) in inode %d\n"),
+       printf(_("Empty directory block %u (#%d) in inode %u\n"),
               db->blk, db->blockcnt, db->ino);
 
        ext2fs_mark_block_bitmap(edi->empty_dir_blocks, db->blk);
index 6501e1f..7e1bbd3 100644 (file)
@@ -98,7 +98,7 @@ int main (int argc, char *argv[])
        int             exit_value = FSCK_OK;
        ext2_filsys     fs;
        ext2_ino_t      ino;
-       int     num_inodes = 0;
+       __u32   num_inodes = 0;
        struct ext2_inode inode;
        ext2_inode_scan scan;
        
@@ -135,7 +135,7 @@ int main (int argc, char *argv[])
        }
        
        print_resource_track(NULL, &global_rtrack);
-       printf(_("%d inodes scanned.\n"), num_inodes);
+       printf(_("%u inodes scanned.\n"), num_inodes);
        
        exit(0);
 }
index 77f56f6..6cd2dfe 100644 (file)
@@ -98,7 +98,7 @@ static void usage(e2fsck_t ctx)
 static void show_stats(e2fsck_t        ctx)
 {
        ext2_filsys fs = ctx->fs;
-       int inodes, inodes_used;
+       __u32 inodes, inodes_used;
        blk_t blocks, blocks_used;
        int dir_links;
        int num_files, num_links;
@@ -118,49 +118,48 @@ static void show_stats(e2fsck_t   ctx)
        frag_percent = (frag_percent + 5) / 10;
        
        if (!verbose) {
-               printf(_("%s: %d/%d files (%0d.%d%% non-contiguous), %u/%u blocks\n"),
+               printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %u/%u blocks\n"),
                       ctx->device_name, inodes_used, inodes,
                       frag_percent / 10, frag_percent % 10,
                       blocks_used, blocks);
                return;
        }
-       printf (P_("\n%8d inode used (%d%%)\n", "\n%8d inodes used (%d%%)\n",
-                  inodes_used), inodes_used, 100 * inodes_used / inodes);
-       printf (P_("%8d non-contiguous inode (%0d.%d%%)\n",
-                  "%8d non-contiguous inodes (%0d.%d%%)\n",
+       printf (P_("\n%8u inode used (%2.2f%%)\n", "\n%8u inodes used (%2.2f%%)\n",
+                  inodes_used), inodes_used, 100.0 * inodes_used / inodes);
+       printf (P_("%8u non-contiguous inode (%0d.%d%%)\n",
+                  "%8u non-contiguous inodes (%0d.%d%%)\n",
                   ctx->fs_fragmented),
                ctx->fs_fragmented, frag_percent / 10, frag_percent % 10);
-       printf (_("         # of inodes with ind/dind/tind blocks: %d/%d/%d\n"),
+       printf (_("         # of inodes with ind/dind/tind blocks: %u/%u/%u\n"),
                ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count);
-       printf (P_("%8u block used (%d%%)\n", "%8u blocks used (%d%%)\n",
-                  blocks_used),
-               blocks_used, (int) ((long long) 100 * blocks_used / blocks));
-       printf (P_("%8d bad block\n", "%8d bad blocks\n",
+       printf (P_("%8u block used (%2.2f%%)\n", "%8u blocks used (%2.2f%%)\n",
+                  blocks_used), blocks_used, 100.0 * blocks_used / blocks);
+       printf (P_("%8u bad block\n", "%8u bad blocks\n",
                   ctx->fs_badblocks_count), ctx->fs_badblocks_count);
-       printf (P_("%8d large file\n", "%8d large files\n",
+       printf (P_("%8u large file\n", "%8u large files\n",
                   ctx->large_files), ctx->large_files);
-       printf (P_("\n%8d regular file\n", "\n%8d regular files\n",
+       printf (P_("\n%8u regular file\n", "\n%8u regular files\n",
                   ctx->fs_regular_count), ctx->fs_regular_count);
-       printf (P_("%8d directory\n", "%8d directories\n",
+       printf (P_("%8u directory\n", "%8u directories\n",
                   ctx->fs_directory_count), ctx->fs_directory_count);
-       printf (P_("%8d character device file\n",
-                  "%8d character device files\n", ctx->fs_chardev_count),
+       printf (P_("%8u character device file\n",
+                  "%8u character device files\n", ctx->fs_chardev_count),
                ctx->fs_chardev_count);
-       printf (P_("%8d block device file\n", "%8d block device files\n",
+       printf (P_("%8u block device file\n", "%8u block device files\n",
                   ctx->fs_blockdev_count), ctx->fs_blockdev_count);
-       printf (P_("%8d fifo\n", "%8d fifos\n", ctx->fs_fifo_count),
+       printf (P_("%8u fifo\n", "%8u fifos\n", ctx->fs_fifo_count),
                ctx->fs_fifo_count);
-       printf (P_("%8d link\n", "%8d links\n",
+       printf (P_("%8u link\n", "%8u links\n",
                   ctx->fs_links_count - dir_links),
                ctx->fs_links_count - dir_links);
-       printf (P_("%8d symbolic link", "%8d symbolic links",
+       printf (P_("%8u symbolic link", "%8u symbolic links",
                   ctx->fs_symlinks_count), ctx->fs_symlinks_count);
-       printf (P_(" (%d fast symbolic link)\n", " (%d fast symbolic links)\n",
+       printf (P_(" (%u fast symbolic link)\n", " (%u fast symbolic links)\n",
                   ctx->fs_fast_symlinks_count), ctx->fs_fast_symlinks_count);
-       printf (P_("%8d socket\n", "%8d sockets\n", ctx->fs_sockets_count),
+       printf (P_("%8u socket\n", "%8u sockets\n", ctx->fs_sockets_count),
                ctx->fs_sockets_count);
        printf ("--------\n");
-       printf (P_("%8d file\n", "%8d files\n",
+       printf (P_("%8u file\n", "%8u files\n",
                   ctx->fs_total_count - dir_links),
                ctx->fs_total_count - dir_links);
 }
@@ -300,7 +299,7 @@ static void check_if_skip(e2fsck_t ctx)
                fputs(_(", check forced.\n"), stdout);
                return;
        }
-       printf(_("%s: clean, %d/%d files, %u/%u blocks"), ctx->device_name,
+       printf(_("%s: clean, %u/%u files, %u/%u blocks"), ctx->device_name,
               fs->super->s_inodes_count - fs->super->s_free_inodes_count,
               fs->super->s_inodes_count,
               fs->super->s_blocks_count - fs->super->s_free_blocks_count,
index 179d406..1cf2040 100644 (file)
@@ -1,5 +1,17 @@
 2006-08-30  Eric Sandeen <esandeen@redhat.com>
 
+       * bmove.c (process_block):
+       * getsize.c (main):
+       * icount.c (ext2fs_create_icount2, insert_icount_el):
+       * tst_badblocks.c (print_list, validate_test_seq, do_test_seq):
+       * tst_badblocks.c (invalid_proc):
+       * tst_getsize.c (main):
+       * tst_iscan.c (check_map):
+       * unix_io.c (raw_read_blk, unix_read_blk):
+       * write_bb_file.c (ext2fs_write_bb_FILE): Fix printf formats.
+
+2006-08-30  Eric Sandeen <esandeen@redhat.com>
+
        * closefs.c (write_backup_super):
        * initialize.c (ext2fs_initialize): Remove unused variables.
 
index 0b2ebb1..9946c46 100644 (file)
@@ -73,7 +73,7 @@ static int process_block(ext2_filsys fs, blk_t        *block_nr,
                ext2fs_mark_block_bitmap(pb->alloc_map, block);
                ret = BLOCK_CHANGED;
                if (pb->flags & EXT2_BMOVE_DEBUG)
-                       printf("ino=%ld, blockcnt=%lld, %d->%d\n", pb->ino,
+                       printf("ino=%ld, blockcnt=%lld, %u->%u\n", pb->ino,
                               blockcnt, orig, block);
        }
        if (pb->add_dir) {
index 4f87311..a4daa03 100644 (file)
@@ -303,7 +303,7 @@ int main(int argc, char **argv)
                        "while calling ext2fs_get_device_size");
                exit(1);
        }
-       printf("Device %s has %d 1k blocks.\n", argv[1], blocks);
+       printf("Device %s has %u 1k blocks.\n", argv[1], blocks);
        exit(0);
 }
 #endif
index 5997792..c8cdc25 100644 (file)
@@ -116,7 +116,7 @@ errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, unsigned int size,
        
        bytes = (size_t) (icount->size * sizeof(struct ext2_icount_el));
 #if 0
-       printf("Icount allocated %d entries, %d bytes.\n",
+       printf("Icount allocated %u entries, %d bytes.\n",
               icount->size, bytes);
 #endif
        retval = ext2fs_get_mem(bytes, &icount->list);
@@ -176,7 +176,7 @@ static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount,
                if (new_size < (icount->size + 100))
                        new_size = icount->size + 100;
 #if 0
-               printf("Reallocating icount %d entries...\n", new_size);
+               printf("Reallocating icount %u entries...\n", new_size);
 #endif 
                retval = ext2fs_resize_mem((size_t) icount->size *
                                           sizeof(struct ext2_icount_el),
index 687db0c..2453f47 100644 (file)
@@ -103,7 +103,7 @@ static void print_list(badblocks_list bb, int verify)
        }
        ok = i = 1;
        while (ext2fs_badblocks_list_iterate(iter, &blk)) {
-               printf("%d ", blk);
+               printf("%u ", blk);
                if (i++ != blk)
                        ok = 0;
        }
@@ -130,7 +130,7 @@ static void validate_test_seq(badblocks_list bb, blk_t *vec)
                        ok = 0;
                        test_fail++;
                }
-               printf("\tblock %d is %s --- %s\n", vec[i],
+               printf("\tblock %u is %s --- %s\n", vec[i],
                       match ? "present" : "absent",
                       ok ? "OK" : "NOT OK");
        }
@@ -145,7 +145,7 @@ static void do_test_seq(badblocks_list bb, blk_t *vec)
                case ADD_BLK:
                        ext2fs_badblocks_list_add(bb, vec[i]);
                        match = ext2fs_badblocks_list_test(bb, vec[i]);
-                       printf("Adding block %d --- now %s\n", vec[i], 
+                       printf("Adding block %u --- now %s\n", vec[i],
                               match ? "present" : "absent");
                        if (!match) {
                                printf("FAILURE!\n");
@@ -155,7 +155,7 @@ static void do_test_seq(badblocks_list bb, blk_t *vec)
                case DEL_BLK:
                        ext2fs_badblocks_list_del(bb, vec[i]);
                        match = ext2fs_badblocks_list_test(bb, vec[i]);
-                       printf("Removing block %d --- now %s\n", vec[i], 
+                       printf("Removing block %u --- now %s\n", vec[i],
                               ext2fs_badblocks_list_test(bb, vec[i]) ? 
                               "present" : "absent");
                        if (match) {
@@ -209,7 +209,7 @@ static void invalid_proc(ext2_filsys fs, blk_t blk)
                printf("Expected invalid block\n");
                test_expected_fail++;
        } else {
-               printf("Invalid block #: %d\n", blk);
+               printf("Invalid block #: %u\n", blk);
                test_fail++;
        }
 }
index 08bb8ed..17f900c 100644 (file)
@@ -39,6 +39,6 @@ int main(int argc, const char *argv[])
                com_err(argv[0], retval, "while getting device size");
                exit(1);
        }
-       printf("%s is device has %d blocks.\n", argv[1], blocks);
+       printf("%s is device has %u blocks.\n", argv[1], blocks);
        return 0;
 }
index 2cf4336..d7fdc12 100644 (file)
@@ -175,7 +175,7 @@ static void check_map(void)
 
        for (i=0; test_vec[i]; i++) {
                if (ext2fs_test_block_bitmap(touched_map, test_vec[i])) {
-                       printf("Bad block was touched --- %d\n", test_vec[i]);
+                       printf("Bad block was touched --- %u\n", test_vec[i]);
                        failed++;
                        first_no_comma = 1;
                }
@@ -199,7 +199,7 @@ static void check_map(void)
                                first = 0;
                        else
                                printf(", ");
-                       printf("%d", i);
+                       printf("%u", i);
                }
        }
        printf("\n");
index 0f04cfa..fb33c16 100644 (file)
@@ -170,8 +170,8 @@ static errcode_t raw_read_blk(io_channel channel,
        size = (count < 0) ? -count : count * channel->block_size;
        location = ((ext2_loff_t) block * channel->block_size) + data->offset;
 #ifdef DEBUG
-       printf("count=%d, size=%d, block=%d, blk_size=%d, location=%lx\n",
-                       count, size, block, channel->block_size, location);
+       printf("count=%d, size=%d, block=%lu, blk_size=%d, location=%llx\n",
+                       count, size, block, channel->block_size, (long long)location);
 #endif
        if (ext2fs_llseek(data->dev, location, SEEK_SET) != location) {
                retval = errno ? errno : EXT2_ET_LLSEEK_FAILED;
@@ -553,7 +553,7 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block,
                /* If it's in the cache, use it! */
                if ((cache = find_cached_block(data, block, &reuse[0]))) {
 #ifdef DEBUG
-                       printf("Using cached block %d\n", block);
+                       printf("Using cached block %lu\n", block);
 #endif
                        memcpy(cp, cache->buf, channel->block_size);
                        count--;
@@ -569,7 +569,7 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block,
                        if (find_cached_block(data, block+i, &reuse[i]))
                                break;
 #ifdef DEBUG
-               printf("Reading %d blocks starting at %d\n", i, block);
+               printf("Reading %d blocks starting at %lu\n", i, block);
 #endif
                if ((retval = raw_read_blk(channel, data, block, i, cp)))
                        return retval;
index 269b576..ea31a7d 100644 (file)
@@ -27,7 +27,7 @@ errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
                return retval;
 
        while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) {
-               fprintf(f, "%d\n", blk);
+               fprintf(f, "%u\n", blk);
        }
        ext2fs_badblocks_list_iterate_end(bb_iter);
        return 0;
index 0a5c495..da27353 100644 (file)
@@ -1,5 +1,11 @@
 2006-08-30  Eric Sandeen <esandeen@redhat.com>
 
+       * dumpe2fs.c (list_bad_blocks):
+       * e2image.c (output_meta_data_blocks, write_raw_image_file):
+       * mke2fs.c (test_disk, handle_bad_blocks): Fix printf formats.
+
+2006-08-30  Eric Sandeen <esandeen@redhat.com>
+
        * e2image.c (mark_table_blocks): Remove unused first_block
                incrementing from loop.
 
index 2a3cf53..4488339 100644 (file)
@@ -250,10 +250,10 @@ static void list_bad_blocks(ext2_filsys fs, int dump)
                return;
        }
        if (dump) {
-               header = fmt = "%d\n";
+               header = fmt = "%u\n";
        } else {
-               header =  _("Bad blocks: %d");
-               fmt = ", %d";
+               header =  _("Bad blocks: %u");
+               fmt = ", %u";
        }
        while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) {
                printf(header ? header : fmt, blk);
index 59bf1e4..5bbc49b 100644 (file)
@@ -417,7 +417,7 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd)
                        retval = io_channel_read_blk(fs->io, blk, 1, buf);
                        if (retval) {
                                com_err(program_name, retval,
-                                       "error reading block %d", blk);
+                                       "error reading block %u", blk);
                        }
                        if (scramble_block_map && 
                            ext2fs_test_block_bitmap(scramble_block_map, blk))
@@ -516,7 +516,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag)
                                       block_buf, process_dir_block, &pb);
                        if (retval) {
                                com_err(program_name, retval,
-                                       "while iterating over inode %d", 
+                                       "while iterating over inode %u",
                                        ino);
                                exit(1);
                        }
@@ -529,7 +529,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag)
                                       process_file_block, &pb);
                                if (retval) {
                                        com_err(program_name, retval,
-                                       "while iterating over %d", ino);
+                                       "while iterating over inode %u", ino);
                                        exit(1);
                                }
                        }
index 01ef546..05ee9d8 100644 (file)
@@ -189,7 +189,7 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
        errcode_t       retval;
        char            buf[1024];
 
-       sprintf(buf, "badblocks -b %d -X %s%s%s %d", fs->blocksize,
+       sprintf(buf, "badblocks -b %d -X %s%s%s %u", fs->blocksize,
                quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
                fs->device_name, fs->super->s_blocks_count);
        if (verbose)
@@ -233,7 +233,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
                if (ext2fs_badblocks_list_test(bb_list, i)) {
                        fprintf(stderr, _("Block %d in primary "
                                "superblock/group descriptor area bad.\n"), i);
-                       fprintf(stderr, _("Blocks %u through %d must be good "
+                       fprintf(stderr, _("Blocks %u through %u must be good "
                                "in order to build a filesystem.\n"),
                                fs->super->s_first_data_block, must_be_good);
                        fputs(_("Aborting....\n"), stderr);
index 4aaec36..c0d95ff 100644 (file)
@@ -1,5 +1,9 @@
 2006-08-30  Eric Sandeen  <esandeen@redhat.com>
 
+       * online.c (online_resize_fs): Fix printf formats.
+
+2006-08-30  Eric Sandeen  <esandeen@redhat.com>
+
        * resize2fs.c (mark_table_blocks): Remove unused variable.
 
 2006-08-30  Theodore Tso  <tytso@mit.edu>
index 7701150..26b263e 100644 (file)
@@ -74,7 +74,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
        if (retval)
                return retval;
 
-       printf(_("Performing an on-line resize of %s to %d (%dk) blocks.\n"), 
+       printf(_("Performing an on-line resize of %s to %u (%dk) blocks.\n"),
               fs->device_name, *new_size, fs->blocksize / 1024);
 
        size = fs->group_desc_count * sb->s_blocks_per_group + 
@@ -116,7 +116,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
                printf("new inode table is at 0x%04x-0x%04x\n", 
                       input.inode_table,
                       input.inode_table + new_fs->inode_blocks_per_group-1);
-               printf("new group has %d blocks\n", input.blocks_count);
+               printf("new group has %u blocks\n", input.blocks_count);
                printf("new group will reserve %d blocks\n", 
                       input.reserved_blocks);
                printf("new group has %d free blocks\n",