]> err.no Git - linux-2.6/commitdiff
[PATCH] fs: Removing useless casts
authorPanagiotis Issaris <takis@issaris.org>
Wed, 27 Sep 2006 08:49:39 +0000 (01:49 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 27 Sep 2006 15:26:10 +0000 (08:26 -0700)
* 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>
21 files changed:
fs/coda/dir.c
fs/ext2/acl.c
fs/ext3/acl.c
fs/ext3/resize.c
fs/hpfs/buffer.c
fs/jffs/inode-v23.c
fs/jffs/intrep.c
fs/jffs/jffs_fm.c
fs/jfs/jfs_txnmgr.c
fs/lockd/clntproc.c
fs/ncpfs/symlink.c
fs/nfs/delegation.c
fs/nfs/inode.c
fs/nfs/nfs3proc.c
fs/nfs/proc.c
fs/ntfs/dir.c
fs/ntfs/inode.c
fs/ntfs/mft.c
fs/ntfs/unistr.c
fs/xfs/linux-2.6/xfs_file.c
fs/xfs/linux-2.6/xfs_iops.c

index 71f2ea632e5376168d5b8aa4f194604941021104..8651ea6a23b727c1c27b24b0d9a3b9d03c062fa0 100644 (file)
@@ -513,7 +513,7 @@ static int coda_venus_readdir(struct file *filp, filldir_t filldir,
        ino_t ino;
        int ret, i;
 
-       vdir = (struct venus_dirent *)kmalloc(sizeof(*vdir), GFP_KERNEL);
+       vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
        if (!vdir) return -ENOMEM;
 
        i = filp->f_pos;
index da52b4a5db64005173124575e63161ed1d6c3d35..7c420b800c3438fd02ab669368f48fb9a6f01c5a 100644 (file)
@@ -89,8 +89,8 @@ ext2_acl_to_disk(const struct posix_acl *acl, size_t *size)
        size_t n;
 
        *size = ext2_acl_size(acl->a_count);
-       ext_acl = (ext2_acl_header *)kmalloc(sizeof(ext2_acl_header) +
-               acl->a_count * sizeof(ext2_acl_entry), GFP_KERNEL);
+       ext_acl = kmalloc(sizeof(ext2_acl_header) + acl->a_count *
+                       sizeof(ext2_acl_entry), GFP_KERNEL);
        if (!ext_acl)
                return ERR_PTR(-ENOMEM);
        ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION);
index 92bf78221429365bce894157170f57b1636e996e..1e5038d9a01b9f469015b83f8ee7eb07a9abf8f8 100644 (file)
@@ -90,8 +90,8 @@ ext3_acl_to_disk(const struct posix_acl *acl, size_t *size)
        size_t n;
 
        *size = ext3_acl_size(acl->a_count);
-       ext_acl = (ext3_acl_header *)kmalloc(sizeof(ext3_acl_header) +
-               acl->a_count * sizeof(ext3_acl_entry), GFP_KERNEL);
+       ext_acl = kmalloc(sizeof(ext3_acl_header) + acl->a_count *
+                       sizeof(ext3_acl_entry), GFP_KERNEL);
        if (!ext_acl)
                return ERR_PTR(-ENOMEM);
        ext_acl->a_version = cpu_to_le32(EXT3_ACL_VERSION);
index 9e318a5cfc879a5bc428980fec1c4d94dad75190..b73cba12f79c0512cb62362a3d5181217b184e22 100644 (file)
@@ -439,8 +439,8 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
        if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
                goto exit_dindj;
 
-       n_group_desc = (struct buffer_head **)kmalloc((gdb_num + 1) *
-                               sizeof(struct buffer_head *), GFP_KERNEL);
+       n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *),
+                       GFP_KERNEL);
        if (!n_group_desc) {
                err = -ENOMEM;
                ext3_warning (sb, __FUNCTION__,
index 2807aa833e62011a42ddeea45e8bc46867907229..b52b7381d10f45710f980b885731654fa5e0442d 100644 (file)
@@ -76,7 +76,7 @@ void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffe
                return NULL;
        }
 
-       qbh->data = data = (char *)kmalloc(2048, GFP_NOFS);
+       qbh->data = data = kmalloc(2048, GFP_NOFS);
        if (!data) {
                printk("HPFS: hpfs_map_4sectors: out of memory\n");
                goto bail;
index 93068697a9bf2cf5b8a438ea96cf72da2d59be1a..b59553d28d139d131c6bbcdaf982dade33d2cb6c 100644 (file)
@@ -652,7 +652,7 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        lock_kernel();
 
        D3({
-               char *s = (char *)kmalloc(len + 1, GFP_KERNEL);
+               char *s = kmalloc(len + 1, GFP_KERNEL);
                memcpy(s, name, len);
                s[len] = '\0';
                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)
        lock_kernel();
        D1({
                int len = dentry->d_name.len; 
-               char *_name = (char *)kmalloc(len + 1, GFP_KERNEL);
-               char *_symname = (char *)kmalloc(symname_len + 1, GFP_KERNEL);
+               char *_name = kmalloc(len + 1, GFP_KERNEL);
+               char *_symname = kmalloc(symname_len + 1, GFP_KERNEL);
                memcpy(_name, dentry->d_name.name, len);
                _name[len] = '\0';
                memcpy(_symname, symname, symname_len);
@@ -1282,7 +1282,7 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
        lock_kernel();
        D1({
                int len = dentry->d_name.len;
-               char *s = (char *)kmalloc(len + 1, GFP_KERNEL);
+               char *s = kmalloc(len + 1, GFP_KERNEL);
                memcpy(s, dentry->d_name.name, len);
                s[len] = '\0';
                printk("jffs_create(): dir: 0x%p, name: \"%s\"\n", dir, s);
index 9000f1effedf9523991c5692f0c61238e1645809..4a543e1149700b08141d6769814848ea9295e2c9 100644 (file)
@@ -488,13 +488,11 @@ jffs_create_file(struct jffs_control *c,
 {
        struct jffs_file *f;
 
-       if (!(f = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
-                                             GFP_KERNEL))) {
+       if (!(f = kzalloc(sizeof(*f), GFP_KERNEL))) {
                D(printk("jffs_create_file(): Failed!\n"));
                return NULL;
        }
        no_jffs_file++;
-       memset(f, 0, sizeof(struct jffs_file));
        f->ino = raw_inode->ino;
        f->pino = raw_inode->pino;
        f->nlink = raw_inode->nlink;
@@ -516,7 +514,7 @@ jffs_create_control(struct super_block *sb)
 
        D2(printk("jffs_create_control()\n"));
 
-       if (!(c = (struct jffs_control *)kmalloc(s, GFP_KERNEL))) {
+       if (!(c = kmalloc(s, GFP_KERNEL))) {
                goto fail_control;
        }
        DJM(no_jffs_control++);
@@ -524,7 +522,7 @@ jffs_create_control(struct super_block *sb)
        c->gc_task = NULL;
        c->hash_len = JFFS_HASH_SIZE;
        s = sizeof(struct list_head) * c->hash_len;
-       if (!(c->hash = (struct list_head *)kmalloc(s, GFP_KERNEL))) {
+       if (!(c->hash = kmalloc(s, GFP_KERNEL))) {
                goto fail_hash;
        }
        DJM(no_hash++);
@@ -593,8 +591,7 @@ jffs_add_virtual_root(struct jffs_control *c)
        D2(printk("jffs_add_virtual_root(): "
                  "Creating a virtual root directory.\n"));
 
-       if (!(root = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
-                                                GFP_KERNEL))) {
+       if (!(root = kmalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
                return -ENOMEM;
        }
        no_jffs_file++;
index 7d8ca1aeace2f85937384dba8b906fe4020d6de4..29b68d939bd9e9f6f9c8bd0572d1b157f2476dcd 100644 (file)
@@ -94,8 +94,7 @@ jffs_build_begin(struct jffs_control *c, int unit)
        struct mtd_info *mtd;
        
        D3(printk("jffs_build_begin()\n"));
-       fmc = (struct jffs_fmcontrol *)kmalloc(sizeof(struct jffs_fmcontrol),
-                                              GFP_KERNEL);
+       fmc = kmalloc(sizeof(*fmc), GFP_KERNEL);
        if (!fmc) {
                D(printk("jffs_build_begin(): Allocation of "
                         "struct jffs_fmcontrol failed!\n"));
@@ -486,8 +485,7 @@ jffs_add_node(struct jffs_node *node)
 
        D3(printk("jffs_add_node(): ino = %u\n", node->ino));
 
-       ref = (struct jffs_node_ref *)kmalloc(sizeof(struct jffs_node_ref),
-                                             GFP_KERNEL);
+       ref = kmalloc(sizeof(*ref), GFP_KERNEL);
        if (!ref)
                return -ENOMEM;
 
index efbb586bed4bcc25db3e8b270bae3720fe7d5ab1..3856efc399c11d7f28a58e24b21f7e9db05a0909 100644 (file)
@@ -282,7 +282,7 @@ int txInit(void)
        TxLockVHWM = (nTxLock * 8) / 10;
 
        size = sizeof(struct tblock) * nTxBlock;
-       TxBlock = (struct tblock *) vmalloc(size);
+       TxBlock = vmalloc(size);
        if (TxBlock == NULL)
                return -ENOMEM;
 
@@ -307,7 +307,7 @@ int txInit(void)
         * tlock id = 0 is reserved.
         */
        size = sizeof(struct tlock) * nTxLock;
-       TxLock = (struct tlock *) vmalloc(size);
+       TxLock = vmalloc(size);
        if (TxLock == NULL) {
                vfree(TxBlock);
                return -ENOMEM;
index 50dbb67ae0c4bb271d60784135dfc0bf7cd8e6e2..271e2165fff6ebf8577f4f5ab590a911ec9bedfe 100644 (file)
@@ -100,7 +100,7 @@ static struct nlm_lockowner *nlm_find_lockowner(struct nlm_host *host, fl_owner_
        res = __nlm_find_lockowner(host, owner);
        if (res == NULL) {
                spin_unlock(&host->h_lock);
-               new = (struct nlm_lockowner *)kmalloc(sizeof(*new), GFP_KERNEL);
+               new = kmalloc(sizeof(*new), GFP_KERNEL);
                spin_lock(&host->h_lock);
                res = __nlm_find_lockowner(host, owner);
                if (res == NULL && new != NULL) {
index ca92c240663564c319627de827c58deed0a635ea..e3d26c1bd105a388cf032c3586b192e6b5e56907 100644 (file)
@@ -48,7 +48,7 @@ static int ncp_symlink_readpage(struct file *file, struct page *page)
        char *buf = kmap(page);
 
        error = -ENOMEM;
-       rawlink=(char *)kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
+       rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
        if (!rawlink)
                goto fail;
 
@@ -126,7 +126,7 @@ int ncp_symlink(struct inode *dir, struct dentry *dentry, const char *symname) {
        /* EPERM is returned by VFS if symlink procedure does not exist */
                return -EPERM;
   
-       rawlink=(char *)kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
+       rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
        if (!rawlink)
                return -ENOMEM;
 
index 57133678db1660a9599d5b724929a8886bcf97e0..841c99a9b11c84203cb5afbcb9d69f38f3682319 100644 (file)
 #include "delegation.h"
 #include "internal.h"
 
-static struct nfs_delegation *nfs_alloc_delegation(void)
-{
-       return (struct nfs_delegation *)kmalloc(sizeof(struct nfs_delegation), GFP_KERNEL);
-}
-
 static void nfs_free_delegation(struct nfs_delegation *delegation)
 {
        if (delegation->cred)
@@ -124,7 +119,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
        if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR)))
                __nfs_revalidate_inode(NFS_SERVER(inode), inode);
 
-       delegation = nfs_alloc_delegation();
+       delegation = kmalloc(sizeof(*delegation), GFP_KERNEL);
        if (delegation == NULL)
                return -ENOMEM;
        memcpy(delegation->stateid.data, res->delegation.data,
index e8c143d182c4db83a8a352a05a0f58f777b947c8..a9d0f71eb5f791bea3af8e279d6796eaa051e92b 100644 (file)
@@ -443,7 +443,7 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str
 {
        struct nfs_open_context *ctx;
 
-       ctx = (struct nfs_open_context *)kmalloc(sizeof(*ctx), GFP_KERNEL);
+       ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
        if (ctx != NULL) {
                atomic_set(&ctx->count, 1);
                ctx->dentry = dget(dentry);
index f8688eaa0001f2f9b376ac916e6ad0683402b3f9..3b234d4601e71ac51f45e71e409526aa96fcf14d 100644 (file)
@@ -449,7 +449,7 @@ nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr
                struct nfs_fattr res;
        } *ptr;
 
-       ptr = (struct unlinkxdr *)kmalloc(sizeof(*ptr), GFP_KERNEL);
+       ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
        if (!ptr)
                return -ENOMEM;
        ptr->arg.fh = NFS_FH(dir->d_inode);
index 630e50647bbbf02c90611f4ba7d63da613ebaccc..4529cc4f3f8fe427bb6b262718213f933b7ac6a1 100644 (file)
@@ -352,7 +352,7 @@ nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *
 {
        struct nfs_diropargs    *arg;
 
-       arg = (struct nfs_diropargs *)kmalloc(sizeof(*arg), GFP_KERNEL);
+       arg = kmalloc(sizeof(*arg), GFP_KERNEL);
        if (!arg)
                return -ENOMEM;
        arg->fh = NFS_FH(dir->d_inode);
index d1e2c6f9f05eed155e257b0524da8cc2ff5e4566..85c36b8ca452e828493fac9a2170f474e1b7e552 100644 (file)
@@ -1149,8 +1149,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
         * Allocate a buffer to store the current name being processed
         * converted to format determined by current NLS.
         */
-       name = (u8*)kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1,
-                       GFP_NOFS);
+       name = kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1, GFP_NOFS);
        if (unlikely(!name)) {
                err = -ENOMEM;
                goto err_out;
@@ -1191,7 +1190,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
         * map the mft record without deadlocking.
         */
        rc = le32_to_cpu(ctx->attr->data.resident.value_length);
-       ir = (INDEX_ROOT*)kmalloc(rc, GFP_NOFS);
+       ir = kmalloc(rc, GFP_NOFS);
        if (unlikely(!ir)) {
                err = -ENOMEM;
                goto err_out;
index d313f356e66a9b8925ae75161cf182da08e79133..31852121b3f5af6ddd88c0a9351f8d7b39c510d5 100644 (file)
@@ -137,7 +137,7 @@ static int ntfs_init_locked_inode(struct inode *vi, ntfs_attr *na)
 
                BUG_ON(!na->name);
                i = na->name_len * sizeof(ntfschar);
-               ni->name = (ntfschar*)kmalloc(i + sizeof(ntfschar), GFP_ATOMIC);
+               ni->name = kmalloc(i + sizeof(ntfschar), GFP_ATOMIC);
                if (!ni->name)
                        return -ENOMEM;
                memcpy(ni->name, na->name, i);
index 2438c00ec0cee309a7f52f23a584fbb2e1769bf1..578fb3d5e80325ae1b96a0882510219276231ce1 100644 (file)
@@ -331,7 +331,7 @@ map_err_out:
                ntfs_inode **tmp;
                int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *);
 
-               tmp = (ntfs_inode **)kmalloc(new_size, GFP_NOFS);
+               tmp = kmalloc(new_size, GFP_NOFS);
                if (unlikely(!tmp)) {
                        ntfs_error(base_ni->vol->sb, "Failed to allocate "
                                        "internal buffer.");
@@ -2893,7 +2893,7 @@ rollback:
        if (!(base_ni->nr_extents & 3)) {
                int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*);
 
-               extent_nis = (ntfs_inode**)kmalloc(new_size, GFP_NOFS);
+               extent_nis = kmalloc(new_size, GFP_NOFS);
                if (unlikely(!extent_nis)) {
                        ntfs_error(vol->sb, "Failed to allocate internal "
                                        "buffer during rollback.%s", es);
index b123c0fa6bf6a4d7b10ad1c7cda1dcd1ec0ddf9c..a1b572196fe4a14f86aaaeb6f0656b79d386ebf1 100644 (file)
@@ -350,7 +350,7 @@ int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins,
                }
                if (!ns) {
                        ns_len = ins_len * NLS_MAX_CHARSET_SIZE;
-                       ns = (unsigned char*)kmalloc(ns_len + 1, GFP_NOFS);
+                       ns = kmalloc(ns_len + 1, GFP_NOFS);
                        if (!ns)
                                goto mem_err_out;
                }
@@ -365,7 +365,7 @@ retry:                      wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o,
                        else if (wc == -ENAMETOOLONG && ns != *outs) {
                                unsigned char *tc;
                                /* Grow in multiples of 64 bytes. */
-                               tc = (unsigned char*)kmalloc((ns_len + 64) &
+                               tc = kmalloc((ns_len + 64) &
                                                ~63, GFP_NOFS);
                                if (tc) {
                                        memcpy(tc, ns, ns_len);
index 3d4f6dff21134a26b622d4450b0e763906ccba1e..41cfcba7ce49bed9c85e94785c163922e44a57c8 100644 (file)
@@ -370,7 +370,7 @@ xfs_file_readdir(
 
        /* Try fairly hard to get memory */
        do {
-               if ((read_buf = (caddr_t)kmalloc(rlen, GFP_KERNEL)))
+               if ((read_buf = kmalloc(rlen, GFP_KERNEL)))
                        break;
                rlen >>= 1;
        } while (rlen >= 1024);
index d9180020de6328fa8dbbeb17f68027805d368fae..22e3b714f62973a62817f1ee7262c72c387a152a 100644 (file)
@@ -553,13 +553,13 @@ xfs_vn_follow_link(
        ASSERT(dentry);
        ASSERT(nd);
 
-       link = (char *)kmalloc(MAXPATHLEN+1, GFP_KERNEL);
+       link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
        if (!link) {
                nd_set_link(nd, ERR_PTR(-ENOMEM));
                return NULL;
        }
 
-       uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL);
+       uio = kmalloc(sizeof(uio_t), GFP_KERNEL);
        if (!uio) {
                kfree(link);
                nd_set_link(nd, ERR_PTR(-ENOMEM));