From: Theodore Ts'o Date: Mon, 20 Dec 2010 15:42:57 +0000 (-0500) Subject: mke2fs: Use ext2fs_div_ceil to simplify write_inode_tables() X-Git-Tag: v1.42-WIP-0702~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e16324210286dc72a013e66d91bd3a59c3ab7538;p=thirdparty%2Fe2fsprogs.git mke2fs: Use ext2fs_div_ceil to simplify write_inode_tables() Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 9c632ff9d..9010f535d 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -305,7 +305,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed) errcode_t retval; blk64_t blk; dgrp_t i; - int num, ipb; + int num; struct ext2fs_numeric_progress_struct progress; ext2fs_numeric_progress_init(fs, &progress, @@ -318,14 +318,11 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed) blk = ext2fs_inode_table_loc(fs, i); num = fs->inode_blocks_per_group; - if (lazy_flag) { - ipb = fs->blocksize / EXT2_INODE_SIZE(fs->super); - num = ((((fs->super->s_inodes_per_group - - ext2fs_bg_itable_unused(fs, i)) * - EXT2_INODE_SIZE(fs->super)) + - EXT2_BLOCK_SIZE(fs->super) - 1) / - EXT2_BLOCK_SIZE(fs->super)); - } + if (lazy_flag) + num = ext2fs_div_ceil((fs->super->s_inodes_per_group - + ext2fs_bg_itable_unused(fs, i)) * + EXT2_INODE_SIZE(fs->super), + EXT2_BLOCK_SIZE(fs->super)); if (!lazy_flag || itable_zeroed) { /* The kernel doesn't need to zero the itable blocks */ ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_ZEROED);