]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
e2fsprogs: introduce ext2fs_close_free() helper
authorLukas Czerner <lczerner@redhat.com>
Sun, 6 Jul 2014 01:06:29 +0000 (21:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 6 Jul 2014 01:06:48 +0000 (21:06 -0400)
commit47fee2ef6a23ae06f680336ffde57caa64604a4c
treef676e46cb15b8629cf46eca18185d1489395bd67
parente7822c1f40281195dbae84a83faf0f57e7e7eb81
e2fsprogs: introduce ext2fs_close_free() helper

Currently there are many uses of ext2fs_close() which might be wrong.
First of all ext2fs_close() does not set the ext2_filsys pointer to NULL
so the caller is responsible for clearing it, however there are some
cases there we do not do it.

Second of all very small number of users of ext2fs_close() actually
check the return value. If there is a problem in ext2fs_close() it will
not even free the ext2_filsys structure, but majority of users expect it
to do so.

To fix both problems this commit introduces a new helper
ext2fs_close_free() which will not only check for the return value and
free the ext2_filsys structure if the call to ext2fs_close2() failed,
but it will also set the ext2_filsys pointer to NULL.

Replace every use of ext2fs_close() in e2fsprogs tools with
ext2fs_close_free() - there is no real reason to keep using
ext2fs_close().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
18 files changed:
debian/e2fslibs.symbols
debugfs/debugfs.c
e2fsck/scantest.c
e2fsck/unix.c
e2fsck/util.c
lib/ext2fs/closefs.c
lib/ext2fs/ext2fs.h
lib/ext2fs/mkjournal.c
lib/ext2fs/tst_bitmaps.c
misc/dumpe2fs.c
misc/e2freefrag.c
misc/e2image.c
misc/e4defrag.c
misc/mke2fs.c
misc/tune2fs.c
misc/util.c
resize/main.c
resize/resize2fs.c