Skip to content

Commit

Permalink
[PATCH] fs: Conversions from kmalloc+memset to k(z|c)alloc
Browse files Browse the repository at this point in the history
Conversions from kmalloc+memset to kzalloc.

Signed-off-by: Panagiotis Issaris <[email protected]>
Jffs2-bit-acked-by: David Woodhouse <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
takis authored and Linus Torvalds committed Sep 27, 2006
1 parent 32c2d2b commit f8314dc
Show file tree
Hide file tree
Showing 35 changed files with 43 additions and 84 deletions.
3 changes: 1 addition & 2 deletions fs/adfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,10 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)

sb->s_flags |= MS_NODIRATIME;

asb = kmalloc(sizeof(*asb), GFP_KERNEL);
asb = kzalloc(sizeof(*asb), GFP_KERNEL);
if (!asb)
return -ENOMEM;
sb->s_fs_info = asb;
memset(asb, 0, sizeof(*asb));

/* set default options */
asb->s_uid = 0;
Expand Down
3 changes: 1 addition & 2 deletions fs/affs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,10 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_op = &affs_sops;
sb->s_flags |= MS_NODIRATIME;

sbi = kmalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
memset(sbi, 0, sizeof(*sbi));
init_MUTEX(&sbi->s_bmlock);

if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
Expand Down
3 changes: 1 addition & 2 deletions fs/afs/vlocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,10 @@ int afs_vlocation_lookup(struct afs_cell *cell,
spin_unlock(&cell->vl_gylock);

/* not in the cell's in-memory lists - create a new record */
vlocation = kmalloc(sizeof(struct afs_vlocation), GFP_KERNEL);
vlocation = kzalloc(sizeof(struct afs_vlocation), GFP_KERNEL);
if (!vlocation)
return -ENOMEM;

memset(vlocation, 0, sizeof(struct afs_vlocation));
atomic_set(&vlocation->usage, 1);
INIT_LIST_HEAD(&vlocation->link);
rwlock_init(&vlocation->lock);
Expand Down
3 changes: 1 addition & 2 deletions fs/afs/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,10 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath,
_debug("creating new volume record");

ret = -ENOMEM;
volume = kmalloc(sizeof(struct afs_volume), GFP_KERNEL);
volume = kzalloc(sizeof(struct afs_volume), GFP_KERNEL);
if (!volume)
goto error_up;

memset(volume, 0, sizeof(struct afs_volume));
atomic_set(&volume->usage, 1);
volume->type = type;
volume->type_force = force;
Expand Down
3 changes: 1 addition & 2 deletions fs/autofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
struct autofs_sb_info *sbi;
int minproto, maxproto;

sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if ( !sbi )
goto fail_unlock;
memset(sbi, 0, sizeof(*sbi));
DPRINTK(("autofs: starting up, sbi = %p\n",sbi));

s->s_fs_info = sbi;
Expand Down
6 changes: 2 additions & 4 deletions fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,10 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
unsigned i, imap_len;
struct bfs_sb_info * info;

info = kmalloc(sizeof(*info), GFP_KERNEL);
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
s->s_fs_info = info;
memset(info, 0, sizeof(*info));

sb_set_blocksize(s, BFS_BSIZE);

Expand All @@ -338,10 +337,9 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
+ BFS_ROOT_INO - 1;

imap_len = info->si_lasti/8 + 1;
info->si_imap = kmalloc(imap_len, GFP_KERNEL);
info->si_imap = kzalloc(imap_len, GFP_KERNEL);
if (!info->si_imap)
goto out;
memset(info->si_imap, 0, imap_len);
for (i=0; i<BFS_ROOT_INO; i++)
set_bit(i, info->si_imap);

Expand Down
3 changes: 1 addition & 2 deletions fs/configfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,8 @@ static int check_perm(struct inode * inode, struct file * file)
/* No error? Great, allocate a buffer for the file, and store it
* it in file->private_data for easy access.
*/
buffer = kmalloc(sizeof(struct configfs_buffer),GFP_KERNEL);
buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL);
if (buffer) {
memset(buffer,0,sizeof(struct configfs_buffer));
init_MUTEX(&buffer->sem);
buffer->needs_read_fill = 1;
buffer->ops = ops;
Expand Down
3 changes: 1 addition & 2 deletions fs/configfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)

if (!sd_iattr) {
/* setting attributes for the first time, allocate now */
sd_iattr = kmalloc(sizeof(struct iattr), GFP_KERNEL);
sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
if (!sd_iattr)
return -ENOMEM;
/* assign default attributes */
memset(sd_iattr, 0, sizeof(struct iattr));
sd_iattr->ia_mode = sd->s_mode;
sd_iattr->ia_uid = 0;
sd_iattr->ia_gid = 0;
Expand Down
3 changes: 1 addition & 2 deletions fs/cramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,10 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)

sb->s_flags |= MS_RDONLY;

sbi = kmalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
sbi = kzalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
memset(sbi, 0, sizeof(struct cramfs_sb_info));

/* Invalidate the read buffers on mount: think disk change.. */
mutex_lock(&read_mutex);
Expand Down
3 changes: 1 addition & 2 deletions fs/efs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,10 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
struct buffer_head *bh;
struct inode *root;

sb = kmalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
if (!sb)
return -ENOMEM;
s->s_fs_info = sb;
memset(sb, 0, sizeof(struct efs_sb_info));

s->s_magic = EFS_SUPER_MAGIC;
if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
Expand Down
3 changes: 1 addition & 2 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
int i, j;
__le32 features;

sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
memset(sbi, 0, sizeof(*sbi));

/*
* See what the current blocksize for the device is, and
Expand Down
3 changes: 1 addition & 2 deletions fs/ext2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,10 @@ bad_block: ext2_error(sb, "ext2_xattr_set",
}
} else {
/* Allocate a buffer where we construct the new block. */
header = kmalloc(sb->s_blocksize, GFP_KERNEL);
header = kzalloc(sb->s_blocksize, GFP_KERNEL);
error = -ENOMEM;
if (header == NULL)
goto cleanup;
memset(header, 0, sb->s_blocksize);
end = (char *)header + sb->s_blocksize;
header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC);
header->h_blocks = header->h_refcount = cpu_to_le32(1);
Expand Down
3 changes: 1 addition & 2 deletions fs/ext3/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,9 @@ int ext3_htree_store_dirent(struct file *dir_file, __u32 hash,

/* Create and allocate the fname structure */
len = sizeof(struct fname) + dirent->name_len + 1;
new_fn = kmalloc(len, GFP_KERNEL);
new_fn = kzalloc(len, GFP_KERNEL);
if (!new_fn)
return -ENOMEM;
memset(new_fn, 0, len);
new_fn->hash = hash;
new_fn->minor_hash = minor_hash;
new_fn->inode = le32_to_cpu(dirent->inode);
Expand Down
3 changes: 1 addition & 2 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1407,11 +1407,10 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
int needs_recovery;
__le32 features;

sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
memset(sbi, 0, sizeof(*sbi));
sbi->s_mount_opt = 0;
sbi->s_resuid = EXT3_DEF_RESUID;
sbi->s_resgid = EXT3_DEF_RESGID;
Expand Down
3 changes: 1 addition & 2 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,11 +1168,10 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
long error;
char buf[50];

sbi = kmalloc(sizeof(struct msdos_sb_info), GFP_KERNEL);
sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
memset(sbi, 0, sizeof(struct msdos_sb_info));

sb->s_flags |= MS_NODIRATIME;
sb->s_magic = MSDOS_SUPER_MAGIC;
Expand Down
3 changes: 1 addition & 2 deletions fs/hfs/bnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,9 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
sb = tree->inode->i_sb;
size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
sizeof(struct page *);
node = kmalloc(size, GFP_KERNEL);
node = kzalloc(size, GFP_KERNEL);
if (!node)
return NULL;
memset(node, 0, size);
node->tree = tree;
node->this = cnid;
set_bit(HFS_BNODE_NEW, &node->flags);
Expand Down
3 changes: 1 addition & 2 deletions fs/hfs/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
struct page *page;
unsigned int size;

tree = kmalloc(sizeof(*tree), GFP_KERNEL);
tree = kzalloc(sizeof(*tree), GFP_KERNEL);
if (!tree)
return NULL;
memset(tree, 0, sizeof(*tree));

init_MUTEX(&tree->tree_lock);
spin_lock_init(&tree->hash_lock);
Expand Down
3 changes: 1 addition & 2 deletions fs/hfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,10 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
struct inode *root_inode;
int res;

sbi = kmalloc(sizeof(struct hfs_sb_info), GFP_KERNEL);
sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
memset(sbi, 0, sizeof(struct hfs_sb_info));
INIT_HLIST_HEAD(&sbi->rsrc_inodes);

res = -EINVAL;
Expand Down
3 changes: 1 addition & 2 deletions fs/hfsplus/bnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,9 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
sb = tree->inode->i_sb;
size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
sizeof(struct page *);
node = kmalloc(size, GFP_KERNEL);
node = kzalloc(size, GFP_KERNEL);
if (!node)
return NULL;
memset(node, 0, size);
node->tree = tree;
node->this = cnid;
set_bit(HFS_BNODE_NEW, &node->flags);
Expand Down
3 changes: 1 addition & 2 deletions fs/hfsplus/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
struct page *page;
unsigned int size;

tree = kmalloc(sizeof(*tree), GFP_KERNEL);
tree = kzalloc(sizeof(*tree), GFP_KERNEL);
if (!tree)
return NULL;
memset(tree, 0, sizeof(*tree));

init_MUTEX(&tree->tree_lock);
spin_lock_init(&tree->hash_lock);
Expand Down
3 changes: 1 addition & 2 deletions fs/hpfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,10 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)

int o;

sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
s->s_fs_info = sbi;
memset(sbi, 0, sizeof(*sbi));

sbi->sb_bmp_dir = NULL;
sbi->sb_cp_table = NULL;
Expand Down
3 changes: 1 addition & 2 deletions fs/isofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,10 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
struct iso9660_options opt;
struct isofs_sb_info * sbi;

sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
s->s_fs_info = sbi;
memset(sbi, 0, sizeof(*sbi));

if (!parse_options((char *)data, &opt))
goto out_freesbi;
Expand Down
3 changes: 1 addition & 2 deletions fs/jffs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ static int jffs2_get_sb_mtd(struct file_system_type *fs_type,
struct jffs2_sb_info *c;
int ret;

c = kmalloc(sizeof(*c), GFP_KERNEL);
c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c)
return -ENOMEM;
memset(c, 0, sizeof(*c));
c->mtd = mtd;

sb = sget(fs_type, jffs2_sb_compare, jffs2_sb_set, c);
Expand Down
4 changes: 2 additions & 2 deletions fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ nlm_lookup_host(int server, struct sockaddr_in *sin,
/* Ooops, no host found, create it */
dprintk("lockd: creating host entry\n");

if (!(host = (struct nlm_host *) kmalloc(sizeof(*host), GFP_KERNEL)))
host = kzalloc(sizeof(*host), GFP_KERNEL);
if (!host)
goto nohost;
memset(host, 0, sizeof(*host));

addr = sin->sin_addr.s_addr;
sprintf(host->h_name, "%u.%u.%u.%u", NIPQUAD(addr));
Expand Down
3 changes: 1 addition & 2 deletions fs/lockd/svcsubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
nlm_debug_print_fh("creating file for", f);

nfserr = nlm_lck_denied_nolocks;
file = (struct nlm_file *) kmalloc(sizeof(*file), GFP_KERNEL);
file = kzalloc(sizeof(*file), GFP_KERNEL);
if (!file)
goto out_unlock;

memset(file, 0, sizeof(*file));
memcpy(&file->f_handle, f, sizeof(struct nfs_fh));
file->f_hash = hash;
init_MUTEX(&file->f_sema);
Expand Down
6 changes: 2 additions & 4 deletions fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -207,10 +206,9 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
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];

Expand Down
3 changes: 1 addition & 2 deletions fs/ncpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
#endif
struct ncp_entry_info finfo;

server = kmalloc(sizeof(struct ncp_server), GFP_KERNEL);
server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
if (!server)
return -ENOMEM;
sb->s_fs_info = server;
memset(server, 0, sizeof(struct ncp_server));

error = -EFAULT;
if (raw_data == NULL)
Expand Down
3 changes: 1 addition & 2 deletions fs/nfsd/nfs4idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,9 @@ idmap_lookup(struct svc_rqst *rqstp,
struct idmap_defer_req *mdr;
int ret;

mdr = kmalloc(sizeof(*mdr), GFP_KERNEL);
mdr = kzalloc(sizeof(*mdr), GFP_KERNEL);
if (!mdr)
return -ENOMEM;
memset(mdr, 0, sizeof(*mdr));
atomic_set(&mdr->count, 1);
init_waitqueue_head(&mdr->waitq);
mdr->req.defer = idmap_defer;
Expand Down
3 changes: 1 addition & 2 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ alloc_client(struct xdr_netobj name)
{
struct nfs4_client *clp;

if ((clp = kmalloc(sizeof(struct nfs4_client), GFP_KERNEL))!= NULL) {
memset(clp, 0, sizeof(*clp));
if ((clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL))!= NULL) {
if ((clp->cl_name.data = kmalloc(name.len, GFP_KERNEL)) != NULL) {
memcpy(clp->cl_name.data, name.data, name.len);
clp->cl_name.len = name.len;
Expand Down
Loading

0 comments on commit f8314dc

Please sign in to comment.