diff options
author | Theodore Ts'o <tytso@mit.edu> | 2021-01-21 16:34:57 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2021-01-21 16:34:57 -0500 |
commit | 7b8cf296b0317d4c7ff58f1d7a2810786a61588e (patch) | |
tree | 6ec2f232a78afad73548ada2c73c90dde0d685b5 | |
parent | ecbe47df0456337e830a05e2527524fde2661ab3 (diff) | |
download | e2fsprogs-7b8cf296b0317d4c7ff58f1d7a2810786a61588e.tar.gz |
libext2fs: fix minor Coverity nits in ext2fs_rw_bitmaps()
Addresses-Coverity-Bug: 1472252
Addresses-Coverity-Bug: 1472253
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | lib/ext2fs/rw_bitmaps.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index e3be4b894..e3f6312ae 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -266,7 +266,6 @@ static errcode_t read_bitmaps_range_prepare(ext2_filsys fs, int flags) goto cleanup; } ext2fs_free_mem(&buf); - return retval; cleanup: @@ -278,8 +277,7 @@ cleanup: ext2fs_free_inode_bitmap(fs->inode_map); fs->inode_map = 0; } - if (buf) - ext2fs_free_mem(&buf); + ext2fs_free_mem(&buf); return retval; } @@ -547,19 +545,19 @@ errcode_t ext2fs_rw_bitmaps(ext2_filsys fs, int flags, int num_threads) (num_threads == 1) || (fs->flags & EXT2_FLAG_IMAGE_FILE)) goto fallback; - if (num_threads < 0) { #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_CONF) + if (num_threads < 0) num_threads = sysconf(_SC_NPROCESSORS_CONF); -#else - /* - * Guess for now; eventually we should probably define - * ext2fs_get_num_cpus() and teach it how to get this info on - * MacOS, FreeBSD, etc. - * ref: https://stackoverflow.com/questions/150355 - */ +#endif + /* + * Guess for now; eventually we should probably define + * ext2fs_get_num_cpus() and teach it how to get this info on + * MacOS, FreeBSD, etc. + * ref: https://stackoverflow.com/questions/150355 + */ + if (num_threads < 0) num_threads = 4; -#endif /* HAVE_SYSCONF */ - } + if (num_threads > fs->group_desc_count) num_threads = fs->group_desc_count; average_group = fs->group_desc_count / num_threads; |