mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-11-23 18:14:25 +08:00
misc: fix Coverity bugs
Fix Coverity bugs 1297093, 1297096, 1297489, 1297491, 1297493, 1297506, 1297507, 1297514, 1297516, and 1297517. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
8804a96f65
commit
63cd76d6ac
@ -390,7 +390,7 @@ int common_block_args_process(int argc, char *argv[],
|
||||
return 1;
|
||||
if (*block == 0) {
|
||||
com_err(argv[0], 0, "Invalid block number 0");
|
||||
err = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
|
@ -27,6 +27,8 @@ static errcode_t e2fsck_rebuild_extents(e2fsck_t ctx, ext2_ino_t ino);
|
||||
/* Schedule an inode to have its extent tree rebuilt during pass 1E. */
|
||||
errcode_t e2fsck_rebuild_extents_later(e2fsck_t ctx, ext2_ino_t ino)
|
||||
{
|
||||
errcode_t retval = 0;
|
||||
|
||||
if (!EXT2_HAS_INCOMPAT_FEATURE(ctx->fs->super,
|
||||
EXT3_FEATURE_INCOMPAT_EXTENTS) ||
|
||||
(ctx->options & E2F_OPT_NO) ||
|
||||
@ -37,13 +39,15 @@ errcode_t e2fsck_rebuild_extents_later(e2fsck_t ctx, ext2_ino_t ino)
|
||||
return e2fsck_rebuild_extents(ctx, ino);
|
||||
|
||||
if (!ctx->inodes_to_rebuild)
|
||||
e2fsck_allocate_inode_bitmap(ctx->fs,
|
||||
retval = e2fsck_allocate_inode_bitmap(ctx->fs,
|
||||
_("extent rebuild inode map"),
|
||||
EXT2FS_BMAP64_RBTREE,
|
||||
"inodes_to_rebuild",
|
||||
&ctx->inodes_to_rebuild);
|
||||
if (ctx->inodes_to_rebuild)
|
||||
ext2fs_mark_inode_bitmap2(ctx->inodes_to_rebuild, ino);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
ext2fs_mark_inode_bitmap2(ctx->inodes_to_rebuild, ino);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -225,6 +229,8 @@ static errcode_t rebuild_extent_tree(e2fsck_t ctx, struct extent_list *list,
|
||||
/* Collect lblk->pblk mappings */
|
||||
if (inode.i_flags & EXT4_EXTENTS_FL) {
|
||||
retval = load_extents(ctx, list);
|
||||
if (retval)
|
||||
goto err;
|
||||
goto extents_loaded;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ unsigned long long e2fsck_guess_readahead(ext2_filsys fs)
|
||||
* worth of inode table blocks seems to yield the largest reductions
|
||||
* in e2fsck runtime.
|
||||
*/
|
||||
guess = 2 * fs->blocksize * fs->inode_blocks_per_group;
|
||||
guess = 2ULL * fs->blocksize * fs->inode_blocks_per_group;
|
||||
|
||||
/* Disable RA if it'd use more 1/50th of RAM. */
|
||||
if (get_memory_size() > (guess * 50))
|
||||
|
@ -682,6 +682,10 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts)
|
||||
}
|
||||
ctx->ext_attr_ver = ea_ver;
|
||||
} else if (strcmp(token, "readahead_kb") == 0) {
|
||||
if (!arg) {
|
||||
extended_usage++;
|
||||
continue;
|
||||
}
|
||||
reada_kb = strtoull(arg, &p, 0);
|
||||
if (*p) {
|
||||
fprintf(stderr, "%s",
|
||||
|
@ -187,7 +187,7 @@ int e2p_string2feature(char *string, int *compat_type, unsigned int *mask)
|
||||
if (string[9] == 0)
|
||||
return 1;
|
||||
num = strtol(string+9, &eptr, 10);
|
||||
if (num > 32 || num < 0)
|
||||
if (num > 31 || num < 0)
|
||||
return 1;
|
||||
if (*eptr)
|
||||
return 1;
|
||||
@ -261,7 +261,7 @@ int e2p_jrnl_string2feature(char *string, int *compat_type, unsigned int *mask)
|
||||
if (string[9] == 0)
|
||||
return 1;
|
||||
num = strtol(string+9, &eptr, 10);
|
||||
if (num > 32 || num < 0)
|
||||
if (num > 31 || num < 0)
|
||||
return 1;
|
||||
if (*eptr)
|
||||
return 1;
|
||||
|
@ -72,7 +72,7 @@ int e2p_string2mntopt(char *string, unsigned int *mask)
|
||||
if (string[8] == 0)
|
||||
return 1;
|
||||
num = strtol(string+8, &eptr, 10);
|
||||
if (num > 32 || num < 0)
|
||||
if (num > 31 || num < 0)
|
||||
return 1;
|
||||
if (*eptr)
|
||||
return 1;
|
||||
|
@ -387,8 +387,10 @@ static int page_in_core(int fd, struct move_extent defrag_data,
|
||||
*page_num = 0;
|
||||
*page_num = (length + pagesize - 1) / pagesize;
|
||||
*vec = (unsigned char *)calloc(*page_num, 1);
|
||||
if (*vec == NULL)
|
||||
if (*vec == NULL) {
|
||||
munmap(page, length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get information on whether pages are in core */
|
||||
if (mincore(page, (size_t)length, *vec) == -1 ||
|
||||
|
@ -219,7 +219,7 @@ static int run_program(char **argv)
|
||||
sprintf(buffer, "died with signal %d\n",
|
||||
WTERMSIG(status));
|
||||
send_output(buffer, 0, SEND_BOTH);
|
||||
rc = 1;
|
||||
return 1;
|
||||
}
|
||||
rc = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user