Commit f52720ca5f48574e347dff35ffe6b389ace61537

Authored by Panagiotis Issaris
Committed by Linus Torvalds
1 parent f8314dc60c

[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>

Showing 21 changed files with 37 additions and 48 deletions Side-by-side Diff

... ... @@ -513,7 +513,7 @@
513 513 ino_t ino;
514 514 int ret, i;
515 515  
516   - vdir = (struct venus_dirent *)kmalloc(sizeof(*vdir), GFP_KERNEL);
  516 + vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
517 517 if (!vdir) return -ENOMEM;
518 518  
519 519 i = filp->f_pos;
... ... @@ -89,8 +89,8 @@
89 89 size_t n;
90 90  
91 91 *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);
94 94 if (!ext_acl)
95 95 return ERR_PTR(-ENOMEM);
96 96 ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION);
... ... @@ -90,8 +90,8 @@
90 90 size_t n;
91 91  
92 92 *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);
95 95 if (!ext_acl)
96 96 return ERR_PTR(-ENOMEM);
97 97 ext_acl->a_version = cpu_to_le32(EXT3_ACL_VERSION);
... ... @@ -439,8 +439,8 @@
439 439 if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
440 440 goto exit_dindj;
441 441  
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);
444 444 if (!n_group_desc) {
445 445 err = -ENOMEM;
446 446 ext3_warning (sb, __FUNCTION__,
... ... @@ -76,7 +76,7 @@
76 76 return NULL;
77 77 }
78 78  
79   - qbh->data = data = (char *)kmalloc(2048, GFP_NOFS);
  79 + qbh->data = data = kmalloc(2048, GFP_NOFS);
80 80 if (!data) {
81 81 printk("HPFS: hpfs_map_4sectors: out of memory\n");
82 82 goto bail;
... ... @@ -652,7 +652,7 @@
652 652 lock_kernel();
653 653  
654 654 D3({
655   - char *s = (char *)kmalloc(len + 1, GFP_KERNEL);
  655 + char *s = kmalloc(len + 1, GFP_KERNEL);
656 656 memcpy(s, name, len);
657 657 s[len] = '\0';
658 658 printk("jffs_lookup(): dir: 0x%p, name: \"%s\"\n", dir, s);
... ... @@ -1173,8 +1173,8 @@
1173 1173 lock_kernel();
1174 1174 D1({
1175 1175 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);
1178 1178 memcpy(_name, dentry->d_name.name, len);
1179 1179 _name[len] = '\0';
1180 1180 memcpy(_symname, symname, symname_len);
... ... @@ -1282,7 +1282,7 @@
1282 1282 lock_kernel();
1283 1283 D1({
1284 1284 int len = dentry->d_name.len;
1285   - char *s = (char *)kmalloc(len + 1, GFP_KERNEL);
  1285 + char *s = kmalloc(len + 1, GFP_KERNEL);
1286 1286 memcpy(s, dentry->d_name.name, len);
1287 1287 s[len] = '\0';
1288 1288 printk("jffs_create(): dir: 0x%p, name: \"%s\"\n", dir, s);
... ... @@ -488,13 +488,11 @@
488 488 {
489 489 struct jffs_file *f;
490 490  
491   - if (!(f = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
492   - GFP_KERNEL))) {
  491 + if (!(f = kzalloc(sizeof(*f), GFP_KERNEL))) {
493 492 D(printk("jffs_create_file(): Failed!\n"));
494 493 return NULL;
495 494 }
496 495 no_jffs_file++;
497   - memset(f, 0, sizeof(struct jffs_file));
498 496 f->ino = raw_inode->ino;
499 497 f->pino = raw_inode->pino;
500 498 f->nlink = raw_inode->nlink;
... ... @@ -516,7 +514,7 @@
516 514  
517 515 D2(printk("jffs_create_control()\n"));
518 516  
519   - if (!(c = (struct jffs_control *)kmalloc(s, GFP_KERNEL))) {
  517 + if (!(c = kmalloc(s, GFP_KERNEL))) {
520 518 goto fail_control;
521 519 }
522 520 DJM(no_jffs_control++);
... ... @@ -524,7 +522,7 @@
524 522 c->gc_task = NULL;
525 523 c->hash_len = JFFS_HASH_SIZE;
526 524 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))) {
528 526 goto fail_hash;
529 527 }
530 528 DJM(no_hash++);
... ... @@ -593,8 +591,7 @@
593 591 D2(printk("jffs_add_virtual_root(): "
594 592 "Creating a virtual root directory.\n"));
595 593  
596   - if (!(root = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
597   - GFP_KERNEL))) {
  594 + if (!(root = kmalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
598 595 return -ENOMEM;
599 596 }
600 597 no_jffs_file++;
... ... @@ -94,8 +94,7 @@
94 94 struct mtd_info *mtd;
95 95  
96 96 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);
99 98 if (!fmc) {
100 99 D(printk("jffs_build_begin(): Allocation of "
101 100 "struct jffs_fmcontrol failed!\n"));
... ... @@ -486,8 +485,7 @@
486 485  
487 486 D3(printk("jffs_add_node(): ino = %u\n", node->ino));
488 487  
489   - ref = (struct jffs_node_ref *)kmalloc(sizeof(struct jffs_node_ref),
490   - GFP_KERNEL);
  488 + ref = kmalloc(sizeof(*ref), GFP_KERNEL);
491 489 if (!ref)
492 490 return -ENOMEM;
493 491  
... ... @@ -282,7 +282,7 @@
282 282 TxLockVHWM = (nTxLock * 8) / 10;
283 283  
284 284 size = sizeof(struct tblock) * nTxBlock;
285   - TxBlock = (struct tblock *) vmalloc(size);
  285 + TxBlock = vmalloc(size);
286 286 if (TxBlock == NULL)
287 287 return -ENOMEM;
288 288  
... ... @@ -307,7 +307,7 @@
307 307 * tlock id = 0 is reserved.
308 308 */
309 309 size = sizeof(struct tlock) * nTxLock;
310   - TxLock = (struct tlock *) vmalloc(size);
  310 + TxLock = vmalloc(size);
311 311 if (TxLock == NULL) {
312 312 vfree(TxBlock);
313 313 return -ENOMEM;
... ... @@ -100,7 +100,7 @@
100 100 res = __nlm_find_lockowner(host, owner);
101 101 if (res == NULL) {
102 102 spin_unlock(&host->h_lock);
103   - new = (struct nlm_lockowner *)kmalloc(sizeof(*new), GFP_KERNEL);
  103 + new = kmalloc(sizeof(*new), GFP_KERNEL);
104 104 spin_lock(&host->h_lock);
105 105 res = __nlm_find_lockowner(host, owner);
106 106 if (res == NULL && new != NULL) {
... ... @@ -48,7 +48,7 @@
48 48 char *buf = kmap(page);
49 49  
50 50 error = -ENOMEM;
51   - rawlink=(char *)kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
  51 + rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
52 52 if (!rawlink)
53 53 goto fail;
54 54  
... ... @@ -126,7 +126,7 @@
126 126 /* EPERM is returned by VFS if symlink procedure does not exist */
127 127 return -EPERM;
128 128  
129   - rawlink=(char *)kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
  129 + rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
130 130 if (!rawlink)
131 131 return -ENOMEM;
132 132  
... ... @@ -20,11 +20,6 @@
20 20 #include "delegation.h"
21 21 #include "internal.h"
22 22  
23   -static struct nfs_delegation *nfs_alloc_delegation(void)
24   -{
25   - return (struct nfs_delegation *)kmalloc(sizeof(struct nfs_delegation), GFP_KERNEL);
26   -}
27   -
28 23 static void nfs_free_delegation(struct nfs_delegation *delegation)
29 24 {
30 25 if (delegation->cred)
... ... @@ -124,7 +119,7 @@
124 119 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR)))
125 120 __nfs_revalidate_inode(NFS_SERVER(inode), inode);
126 121  
127   - delegation = nfs_alloc_delegation();
  122 + delegation = kmalloc(sizeof(*delegation), GFP_KERNEL);
128 123 if (delegation == NULL)
129 124 return -ENOMEM;
130 125 memcpy(delegation->stateid.data, res->delegation.data,
... ... @@ -443,7 +443,7 @@
443 443 {
444 444 struct nfs_open_context *ctx;
445 445  
446   - ctx = (struct nfs_open_context *)kmalloc(sizeof(*ctx), GFP_KERNEL);
  446 + ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
447 447 if (ctx != NULL) {
448 448 atomic_set(&ctx->count, 1);
449 449 ctx->dentry = dget(dentry);
... ... @@ -449,7 +449,7 @@
449 449 struct nfs_fattr res;
450 450 } *ptr;
451 451  
452   - ptr = (struct unlinkxdr *)kmalloc(sizeof(*ptr), GFP_KERNEL);
  452 + ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
453 453 if (!ptr)
454 454 return -ENOMEM;
455 455 ptr->arg.fh = NFS_FH(dir->d_inode);
... ... @@ -352,7 +352,7 @@
352 352 {
353 353 struct nfs_diropargs *arg;
354 354  
355   - arg = (struct nfs_diropargs *)kmalloc(sizeof(*arg), GFP_KERNEL);
  355 + arg = kmalloc(sizeof(*arg), GFP_KERNEL);
356 356 if (!arg)
357 357 return -ENOMEM;
358 358 arg->fh = NFS_FH(dir->d_inode);
... ... @@ -1149,8 +1149,7 @@
1149 1149 * Allocate a buffer to store the current name being processed
1150 1150 * converted to format determined by current NLS.
1151 1151 */
1152   - name = (u8*)kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1,
1153   - GFP_NOFS);
  1152 + name = kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1, GFP_NOFS);
1154 1153 if (unlikely(!name)) {
1155 1154 err = -ENOMEM;
1156 1155 goto err_out;
... ... @@ -1191,7 +1190,7 @@
1191 1190 * map the mft record without deadlocking.
1192 1191 */
1193 1192 rc = le32_to_cpu(ctx->attr->data.resident.value_length);
1194   - ir = (INDEX_ROOT*)kmalloc(rc, GFP_NOFS);
  1193 + ir = kmalloc(rc, GFP_NOFS);
1195 1194 if (unlikely(!ir)) {
1196 1195 err = -ENOMEM;
1197 1196 goto err_out;
... ... @@ -137,7 +137,7 @@
137 137  
138 138 BUG_ON(!na->name);
139 139 i = na->name_len * sizeof(ntfschar);
140   - ni->name = (ntfschar*)kmalloc(i + sizeof(ntfschar), GFP_ATOMIC);
  140 + ni->name = kmalloc(i + sizeof(ntfschar), GFP_ATOMIC);
141 141 if (!ni->name)
142 142 return -ENOMEM;
143 143 memcpy(ni->name, na->name, i);
... ... @@ -331,7 +331,7 @@
331 331 ntfs_inode **tmp;
332 332 int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *);
333 333  
334   - tmp = (ntfs_inode **)kmalloc(new_size, GFP_NOFS);
  334 + tmp = kmalloc(new_size, GFP_NOFS);
335 335 if (unlikely(!tmp)) {
336 336 ntfs_error(base_ni->vol->sb, "Failed to allocate "
337 337 "internal buffer.");
... ... @@ -2893,7 +2893,7 @@
2893 2893 if (!(base_ni->nr_extents & 3)) {
2894 2894 int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*);
2895 2895  
2896   - extent_nis = (ntfs_inode**)kmalloc(new_size, GFP_NOFS);
  2896 + extent_nis = kmalloc(new_size, GFP_NOFS);
2897 2897 if (unlikely(!extent_nis)) {
2898 2898 ntfs_error(vol->sb, "Failed to allocate internal "
2899 2899 "buffer during rollback.%s", es);
... ... @@ -350,7 +350,7 @@
350 350 }
351 351 if (!ns) {
352 352 ns_len = ins_len * NLS_MAX_CHARSET_SIZE;
353   - ns = (unsigned char*)kmalloc(ns_len + 1, GFP_NOFS);
  353 + ns = kmalloc(ns_len + 1, GFP_NOFS);
354 354 if (!ns)
355 355 goto mem_err_out;
356 356 }
... ... @@ -365,7 +365,7 @@
365 365 else if (wc == -ENAMETOOLONG && ns != *outs) {
366 366 unsigned char *tc;
367 367 /* Grow in multiples of 64 bytes. */
368   - tc = (unsigned char*)kmalloc((ns_len + 64) &
  368 + tc = kmalloc((ns_len + 64) &
369 369 ~63, GFP_NOFS);
370 370 if (tc) {
371 371 memcpy(tc, ns, ns_len);
fs/xfs/linux-2.6/xfs_file.c
... ... @@ -370,7 +370,7 @@
370 370  
371 371 /* Try fairly hard to get memory */
372 372 do {
373   - if ((read_buf = (caddr_t)kmalloc(rlen, GFP_KERNEL)))
  373 + if ((read_buf = kmalloc(rlen, GFP_KERNEL)))
374 374 break;
375 375 rlen >>= 1;
376 376 } while (rlen >= 1024);
fs/xfs/linux-2.6/xfs_iops.c
... ... @@ -553,13 +553,13 @@
553 553 ASSERT(dentry);
554 554 ASSERT(nd);
555 555  
556   - link = (char *)kmalloc(MAXPATHLEN+1, GFP_KERNEL);
  556 + link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
557 557 if (!link) {
558 558 nd_set_link(nd, ERR_PTR(-ENOMEM));
559 559 return NULL;
560 560 }
561 561  
562   - uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL);
  562 + uio = kmalloc(sizeof(uio_t), GFP_KERNEL);
563 563 if (!uio) {
564 564 kfree(link);
565 565 nd_set_link(nd, ERR_PTR(-ENOMEM));