diff options
author | Andreas Dilger <adilger@whamcloud.com> | 2020-02-06 18:09:45 -0700 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-03-04 18:10:14 -0500 |
commit | 70303df16ca6fb5939b5091b9cef6fac378c87d7 (patch) | |
tree | 1d27cc6e07f8f259013b77d2ee26bbeffde108ab /e2fsck/extend.c | |
parent | 102993ec1c841ef9392652db5a7a546f470a1004 (diff) | |
download | e2fsprogs-70303df16ca6fb5939b5091b9cef6fac378c87d7.tar.gz |
e2fsck: consistently use ext2fs_get_mem()
Consistently use ext2fs_get_mem() and ext2fs_free_mem() instead of
calling malloc() and free() directly in e2fsck. In several places
it is possible to use ext2fs_get_memzero() instead of explicitly
calling memset() on the memory afterward.
This is just a code cleanup, and does not fix any specific bugs.
[ Fix up library dependencies in e2fsck/Makefile.in to fix "make
check" breakages. -- TYT ]
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'e2fsck/extend.c')
-rw-r--r-- | e2fsck/extend.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/e2fsck/extend.c b/e2fsck/extend.c index bdb62c3e..9d17e440 100644 --- a/e2fsck/extend.c +++ b/e2fsck/extend.c @@ -31,6 +31,7 @@ int main(int argc, char **argv) int nblocks, blocksize; int fd; char *block; + errcode_t retval; int ret; if (argc != 4) @@ -45,13 +46,12 @@ int main(int argc, char **argv) exit(1); } - block = malloc(blocksize); - if (block == 0) { + retval = ext2fs_get_memzero(blocksize, &block); + if (retval) { fprintf(stderr, _("Couldn't allocate block buffer (size=%d)\n"), blocksize); exit(1); } - memset(block, 0, blocksize); fd = open(filename, O_RDWR); if (fd < 0) { @@ -78,5 +78,6 @@ int main(int argc, char **argv) perror("read"); exit(1); } - exit(0); + ext2fs_free_mem(&block); + return(0); } |