[PATCH] fs: Conversions from kmalloc+memset to k(z|c)alloc
[powerpc.git] / fs / minix / inode.c
index a6fb509..e24be7f 100644 (file)
@@ -145,11 +145,10 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
        struct inode *root_inode;
        struct minix_sb_info *sbi;
 
-       sbi = kmalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
+       sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
        if (!sbi)
                return -ENOMEM;
        s->s_fs_info = sbi;
-       memset(sbi, 0, sizeof(struct minix_sb_info));
 
        /* N.B. These should be compile-time tests.
           Unfortunately that is impossible. */
@@ -204,11 +203,12 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
        /*
         * Allocate the buffer map to keep the superblock small.
         */
+       if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
+               goto out_illegal_sb;
        i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh);
-       map = kmalloc(i, GFP_KERNEL);
+       map = kzalloc(i, GFP_KERNEL);
        if (!map)
                goto out_no_map;
-       memset(map, 0, i);
        sbi->s_imap = &map[0];
        sbi->s_zmap = &map[sbi->s_imap_blocks];
 
@@ -263,7 +263,7 @@ out_no_root:
 
 out_no_bitmap:
        printk("MINIX-fs: bad superblock or unable to read bitmaps\n");
-    out_freemap:
+out_freemap:
        for (i = 0; i < sbi->s_imap_blocks; i++)
                brelse(sbi->s_imap[i]);
        for (i = 0; i < sbi->s_zmap_blocks; i++)
@@ -276,11 +276,16 @@ out_no_map:
                printk("MINIX-fs: can't allocate map\n");
        goto out_release;
 
+out_illegal_sb:
+       if (!silent)
+               printk("MINIX-fs: bad superblock\n");
+       goto out_release;
+
 out_no_fs:
        if (!silent)
                printk("VFS: Can't find a Minix or Minix V2 filesystem "
                        "on device %s\n", s->s_id);
-    out_release:
+out_release:
        brelse(bh);
        goto out;
 
@@ -290,7 +295,7 @@ out_bad_hblock:
 
 out_bad_sb:
        printk("MINIX-fs: unable to read superblock\n");
- out:
+out:
        s->s_fs_info = NULL;
        kfree(sbi);
        return -EINVAL;
@@ -335,7 +340,7 @@ static sector_t minix_bmap(struct address_space *mapping, sector_t block)
 {
        return generic_block_bmap(mapping,block,minix_get_block);
 }
-static struct address_space_operations minix_aops = {
+static const struct address_space_operations minix_aops = {
        .readpage = minix_readpage,
        .writepage = minix_writepage,
        .sync_page = block_sync_page,