Skip to content

Commit f52720c

Browse files
takisLinus Torvalds
authored andcommitted
[PATCH] fs: Removing useless casts
* Removing useless casts * Removing useless wrapper * Conversion from kmalloc+memset to kzalloc Signed-off-by: Panagiotis Issaris <takis@issaris.org> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent f8314dc commit f52720c

21 files changed

Lines changed: 37 additions & 48 deletions

File tree

‎fs/coda/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ static int coda_venus_readdir(struct file *filp, filldir_t filldir,
513513
ino_t ino;
514514
int ret, i;
515515

516-
vdir = (struct venus_dirent *)kmalloc(sizeof(*vdir), GFP_KERNEL);
516+
vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
517517
if (!vdir) return -ENOMEM;
518518

519519
i = filp->f_pos;

‎fs/ext2/acl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ ext2_acl_to_disk(const struct posix_acl *acl, size_t *size)
8989
size_t n;
9090

9191
*size = ext2_acl_size(acl->a_count);
92-
ext_acl = (ext2_acl_header *)kmalloc(sizeof(ext2_acl_header) +
93-
acl->a_count * sizeof(ext2_acl_entry), GFP_KERNEL);
92+
ext_acl = kmalloc(sizeof(ext2_acl_header) + acl->a_count *
93+
sizeof(ext2_acl_entry), GFP_KERNEL);
9494
if (!ext_acl)
9595
return ERR_PTR(-ENOMEM);
9696
ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION);

‎fs/ext3/acl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ ext3_acl_to_disk(const struct posix_acl *acl, size_t *size)
9090
size_t n;
9191

9292
*size = ext3_acl_size(acl->a_count);
93-
ext_acl = (ext3_acl_header *)kmalloc(sizeof(ext3_acl_header) +
94-
acl->a_count * sizeof(ext3_acl_entry), GFP_KERNEL);
93+
ext_acl = kmalloc(sizeof(ext3_acl_header) + acl->a_count *
94+
sizeof(ext3_acl_entry), GFP_KERNEL);
9595
if (!ext_acl)
9696
return ERR_PTR(-ENOMEM);
9797
ext_acl->a_version = cpu_to_le32(EXT3_ACL_VERSION);

‎fs/ext3/resize.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
439439
if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
440440
goto exit_dindj;
441441

442-
n_group_desc = (struct buffer_head **)kmalloc((gdb_num + 1) *
443-
sizeof(struct buffer_head *), GFP_KERNEL);
442+
n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *),
443+
GFP_KERNEL);
444444
if (!n_group_desc) {
445445
err = -ENOMEM;
446446
ext3_warning (sb, __FUNCTION__,

‎fs/hpfs/buffer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffe
7676
return NULL;
7777
}
7878

79-
qbh->data = data = (char *)kmalloc(2048, GFP_NOFS);
79+
qbh->data = data = kmalloc(2048, GFP_NOFS);
8080
if (!data) {
8181
printk("HPFS: hpfs_map_4sectors: out of memory\n");
8282
goto bail;

‎fs/jffs/inode-v23.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
652652
lock_kernel();
653653

654654
D3({
655-
char *s = (char *)kmalloc(len + 1, GFP_KERNEL);
655+
char *s = kmalloc(len + 1, GFP_KERNEL);
656656
memcpy(s, name, len);
657657
s[len] = '\0';
658658
printk("jffs_lookup(): dir: 0x%p, name: \"%s\"\n", dir, s);
@@ -1173,8 +1173,8 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
11731173
lock_kernel();
11741174
D1({
11751175
int len = dentry->d_name.len;
1176-
char *_name = (char *)kmalloc(len + 1, GFP_KERNEL);
1177-
char *_symname = (char *)kmalloc(symname_len + 1, GFP_KERNEL);
1176+
char *_name = kmalloc(len + 1, GFP_KERNEL);
1177+
char *_symname = kmalloc(symname_len + 1, GFP_KERNEL);
11781178
memcpy(_name, dentry->d_name.name, len);
11791179
_name[len] = '\0';
11801180
memcpy(_symname, symname, symname_len);
@@ -1282,7 +1282,7 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
12821282
lock_kernel();
12831283
D1({
12841284
int len = dentry->d_name.len;
1285-
char *s = (char *)kmalloc(len + 1, GFP_KERNEL);
1285+
char *s = kmalloc(len + 1, GFP_KERNEL);
12861286
memcpy(s, dentry->d_name.name, len);
12871287
s[len] = '\0';
12881288
printk("jffs_create(): dir: 0x%p, name: \"%s\"\n", dir, s);

‎fs/jffs/intrep.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,11 @@ jffs_create_file(struct jffs_control *c,
488488
{
489489
struct jffs_file *f;
490490

491-
if (!(f = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
492-
GFP_KERNEL))) {
491+
if (!(f = kzalloc(sizeof(*f), GFP_KERNEL))) {
493492
D(printk("jffs_create_file(): Failed!\n"));
494493
return NULL;
495494
}
496495
no_jffs_file++;
497-
memset(f, 0, sizeof(struct jffs_file));
498496
f->ino = raw_inode->ino;
499497
f->pino = raw_inode->pino;
500498
f->nlink = raw_inode->nlink;
@@ -516,15 +514,15 @@ jffs_create_control(struct super_block *sb)
516514

517515
D2(printk("jffs_create_control()\n"));
518516

519-
if (!(c = (struct jffs_control *)kmalloc(s, GFP_KERNEL))) {
517+
if (!(c = kmalloc(s, GFP_KERNEL))) {
520518
goto fail_control;
521519
}
522520
DJM(no_jffs_control++);
523521
c->root = NULL;
524522
c->gc_task = NULL;
525523
c->hash_len = JFFS_HASH_SIZE;
526524
s = sizeof(struct list_head) * c->hash_len;
527-
if (!(c->hash = (struct list_head *)kmalloc(s, GFP_KERNEL))) {
525+
if (!(c->hash = kmalloc(s, GFP_KERNEL))) {
528526
goto fail_hash;
529527
}
530528
DJM(no_hash++);
@@ -593,8 +591,7 @@ jffs_add_virtual_root(struct jffs_control *c)
593591
D2(printk("jffs_add_virtual_root(): "
594592
"Creating a virtual root directory.\n"));
595593

596-
if (!(root = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
597-
GFP_KERNEL))) {
594+
if (!(root = kmalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
598595
return -ENOMEM;
599596
}
600597
no_jffs_file++;

‎fs/jffs/jffs_fm.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ jffs_build_begin(struct jffs_control *c, int unit)
9494
struct mtd_info *mtd;
9595

9696
D3(printk("jffs_build_begin()\n"));
97-
fmc = (struct jffs_fmcontrol *)kmalloc(sizeof(struct jffs_fmcontrol),
98-
GFP_KERNEL);
97+
fmc = kmalloc(sizeof(*fmc), GFP_KERNEL);
9998
if (!fmc) {
10099
D(printk("jffs_build_begin(): Allocation of "
101100
"struct jffs_fmcontrol failed!\n"));
@@ -486,8 +485,7 @@ jffs_add_node(struct jffs_node *node)
486485

487486
D3(printk("jffs_add_node(): ino = %u\n", node->ino));
488487

489-
ref = (struct jffs_node_ref *)kmalloc(sizeof(struct jffs_node_ref),
490-
GFP_KERNEL);
488+
ref = kmalloc(sizeof(*ref), GFP_KERNEL);
491489
if (!ref)
492490
return -ENOMEM;
493491

‎fs/jfs/jfs_txnmgr.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ int txInit(void)
282282
TxLockVHWM = (nTxLock * 8) / 10;
283283

284284
size = sizeof(struct tblock) * nTxBlock;
285-
TxBlock = (struct tblock *) vmalloc(size);
285+
TxBlock = vmalloc(size);
286286
if (TxBlock == NULL)
287287
return -ENOMEM;
288288

@@ -307,7 +307,7 @@ int txInit(void)
307307
* tlock id = 0 is reserved.
308308
*/
309309
size = sizeof(struct tlock) * nTxLock;
310-
TxLock = (struct tlock *) vmalloc(size);
310+
TxLock = vmalloc(size);
311311
if (TxLock == NULL) {
312312
vfree(TxBlock);
313313
return -ENOMEM;

‎fs/lockd/clntproc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static struct nlm_lockowner *nlm_find_lockowner(struct nlm_host *host, fl_owner_
100100
res = __nlm_find_lockowner(host, owner);
101101
if (res == NULL) {
102102
spin_unlock(&host->h_lock);
103-
new = (struct nlm_lockowner *)kmalloc(sizeof(*new), GFP_KERNEL);
103+
new = kmalloc(sizeof(*new), GFP_KERNEL);
104104
spin_lock(&host->h_lock);
105105
res = __nlm_find_lockowner(host, owner);
106106
if (res == NULL && new != NULL) {

0 commit comments

Comments
 (0)