From: Francesco Cosoleto Date: Tue, 8 Nov 2011 22:14:52 +0000 (+0100) Subject: fsck.minix: remove unnecessary memset calls X-Git-Tag: v2.21-rc1~209 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d73af2ac4bf2cbac9d73650b3e1fdc5b85204d58;p=thirdparty%2Futil-linux.git fsck.minix: remove unnecessary memset calls The program aborts without using this unintialized allocated memory, setting to zero doesn't look needed. memset calls with sizeof() of pointer as argument (reported by clang). [kzak@redhat.com: - replace malloc with calloc for {zone,inode}_count to make code more robust] Signed-off-by: Francesco Cosoleto Signed-off-by: Karel Zak --- diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index eb02f9ea6d..ccbb7a9705 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -611,15 +611,13 @@ read_tables(void) { zone_map = malloc(zmaps * MINIX_BLOCK_SIZE); if (!inode_map) die(_("Unable to allocate buffer for zone map")); - memset(inode_map,0,sizeof(inode_map)); - memset(zone_map,0,sizeof(zone_map)); inode_buffer = malloc(buffsz); if (!inode_buffer) die(_("Unable to allocate buffer for inodes")); - inode_count = malloc(inodes + 1); + inode_count = calloc(1, inodes + 1); if (!inode_count) die(_("Unable to allocate buffer for inode count")); - zone_count = malloc(zones); + zone_count = calloc(1, zones); if (!zone_count) die(_("Unable to allocate buffer for zone count"));