From: Yan Burman <burman.yan@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com, trivial@kernel.org
Subject: [PATCH 2.6.19] ext[2-4]: replace kmalloc+memset with kzalloc
Date: Sat, 02 Dec 2006 13:17:39 +0200 [thread overview]
Message-ID: <1165058259.4523.18.camel@localhost> (raw)
Replace kmalloc+memset with kzalloc
Signed-off-by: Yan Burman <burman.yan@gmail.com>
diff -rubp linux-2.6.19-rc5_orig/fs/ext2/super.c linux-2.6.19-rc5_kzalloc/fs/ext2/super.c
--- linux-2.6.19-rc5_orig/fs/ext2/super.c 2006-11-09 12:16:20.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/fs/ext2/super.c 2006-11-11 22:44:04.000000000 +0200
@@ -883,13 +883,12 @@ static int ext2_fill_super(struct super_
goto failed_mount;
}
bgl_lock_init(&sbi->s_blockgroup_lock);
- sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts),
+ sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts),
GFP_KERNEL);
if (!sbi->s_debts) {
printk ("EXT2-fs: not enough memory\n");
goto failed_mount_group_desc;
}
- memset(sbi->s_debts, 0, sbi->s_groups_count * sizeof(*sbi->s_debts));
for (i = 0; i < db_count; i++) {
block = descriptor_loc(sb, logic_sb_block, i);
sbi->s_group_desc[i] = sb_bread(sb, block);
diff -rubp linux-2.6.19-rc5_orig/fs/ext3/xattr.c linux-2.6.19-rc5_kzalloc/fs/ext3/xattr.c
--- linux-2.6.19-rc5_orig/fs/ext3/xattr.c 2006-11-09 12:16:20.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/fs/ext3/xattr.c 2006-11-11 22:44:04.000000000 +0200
@@ -733,12 +733,11 @@ ext3_xattr_block_set(handle_t *handle, s
}
} else {
/* Allocate a buffer where we construct the new block. */
- s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
+ s->base = kzalloc(sb->s_blocksize, GFP_KERNEL);
/* assert(header == s->base) */
error = -ENOMEM;
if (s->base == NULL)
goto cleanup;
- memset(s->base, 0, sb->s_blocksize);
header(s->base)->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
header(s->base)->h_blocks = cpu_to_le32(1);
header(s->base)->h_refcount = cpu_to_le32(1);
diff -rubp linux-2.6.19-rc5_orig/fs/ext4/extents.c linux-2.6.19-rc5_kzalloc/fs/ext4/extents.c
--- linux-2.6.19-rc5_orig/fs/ext4/extents.c 2006-11-09 12:16:20.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/fs/ext4/extents.c 2006-11-11 22:44:04.000000000 +0200
@@ -641,10 +641,9 @@ static int ext4_ext_split(handle_t *hand
* We need this to handle errors and free blocks
* upon them.
*/
- ablocks = kmalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
+ ablocks = kcalloc(depth, sizeof(ext4_fsblk_t), GFP_NOFS);
if (!ablocks)
return -ENOMEM;
- memset(ablocks, 0, sizeof(ext4_fsblk_t) * depth);
/* allocate all needed blocks */
ext_debug("allocate %d blocks for indexes/leaf\n", depth - at);
@@ -1756,12 +1755,11 @@ int ext4_ext_remove_space(struct inode *
* We start scanning from right side, freeing all the blocks
* after i_size and walking into the tree depth-wise.
*/
- path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL);
+ path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), GFP_KERNEL);
if (path == NULL) {
ext4_journal_stop(handle);
return -ENOMEM;
}
- memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
path[0].p_hdr = ext_inode_hdr(inode);
if (ext4_ext_check_header(__FUNCTION__, inode, path[0].p_hdr)) {
err = -EIO;
diff -rubp linux-2.6.19-rc5_orig/fs/ext4/xattr.c linux-2.6.19-rc5_kzalloc/fs/ext4/xattr.c
--- linux-2.6.19-rc5_orig/fs/ext4/xattr.c 2006-11-09 12:16:20.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/fs/ext4/xattr.c 2006-11-11 22:44:04.000000000 +0200
@@ -733,12 +733,11 @@ ext4_xattr_block_set(handle_t *handle, s
}
} else {
/* Allocate a buffer where we construct the new block. */
- s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
+ s->base = kzalloc(sb->s_blocksize, GFP_KERNEL);
/* assert(header == s->base) */
error = -ENOMEM;
if (s->base == NULL)
goto cleanup;
- memset(s->base, 0, sb->s_blocksize);
header(s->base)->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
header(s->base)->h_blocks = cpu_to_le32(1);
header(s->base)->h_refcount = cpu_to_le32(1);
reply other threads:[~2006-12-02 11:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1165058259.4523.18.camel@localhost \
--to=burman.yan@gmail.com \
--cc=adilger@clusterfs.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sct@redhat.com \
--cc=trivial@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox