]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fsck.minix: remove unnecessary memset calls
authorFrancesco Cosoleto <cosoleto@gmail.com>
Tue, 8 Nov 2011 22:14:52 +0000 (23:14 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Nov 2011 09:03:07 +0000 (10:03 +0100)
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 <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fsck.minix.c

index eb02f9ea6def0e3a912af580747310a5202f9ead..ccbb7a97055b3420eb4fe2d9460261e27364222e 100644 (file)
@@ -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"));