Re: [PATCH 1/1] fs/ufs/super.c: remove unnecessary casting

From: Joe Perches
Date: Sun Dec 28 2014 - 11:54:40 EST


On Sun, 2014-12-28 at 16:28 +0100, Fabian Frederick wrote:
> Fix the following coccinelle warning:
> fs/ufs/super.c:1418:7-28: WARNING: casting value returned by memory
> allocation function to (struct ufs_inode_info *) is useless.
[]
> diff --git a/fs/ufs/super.c b/fs/ufs/super.c
[]
> @@ -1414,8 +1414,8 @@ static struct kmem_cache * ufs_inode_cachep;
>
> static struct inode *ufs_alloc_inode(struct super_block *sb)
> {
> - struct ufs_inode_info *ei;
> - ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_NOFS);
> + struct ufs_inode_info *ei = kmem_cache_alloc(ufs_inode_cachep,
> + GFP_NOFS);

If you insist on the blank line after declaration style,
perhaps it's better to separate the declaration from
the alloc so the alloc is on a single line like:

static struct inode *ufs_alloc_inode(struct super_block *sb)
{
struct ufs_inode_info *ei;

ei = kmem_cache_alloc(ufs_inode_cachep, GFP_NOFS);
if (!ei)
return NULL;

ei->vfs_inode.i_version = 1;
etc...


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/