Skip to contentSkip to conversation

procfs: Remove unnecessary cast in alloc codes

PATCH In review Firo Yang 2 participants 2 messages Apr 23, 2015

Subsystems (2)
lore
Share & tools
lore

Firo Yang

author
#0 lore raw

PATCH 1/1 procfs: Remove unnecessary cast in alloc codes

Remove unnecessary cast of allocation return value in fs/proc/inode.c::proc_alloc_inode().

---
 fs/proc/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/inode.c +1 -1
index 7697b66..08a7235 100644
@@ -58,7 +58,7 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
 	struct proc_inode *ei;
 	struct inode *inode;
 
-	ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);
+	ei = kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);
 	if (!ei)
 		return NULL;
 	ei->pid = NULL;
Signature · 1 line
2.1.0
#1 lore raw
Quoted 13 lines · Firo Yang

Remove unnecessary cast of allocation return value in fs/proc/inode.c::proc_alloc_inode().

---
 fs/proc/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/inode.c +0 -0
index 7697b66..08a7235 100644

fs/proc/inode.c static struct inode *proc_alloc_inode(struct super_block *sb) · line 61

Quoted 5 lines
fs/proc/inode.c +1 -1
@@ -58,7 +58,7 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
        struct proc_inode *ei;
        struct inode *inode;
 
-       ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);
+       ei = kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);

It is not really unnecessary for at lest two reasons.
- If the type of "ei" changes gcc will emit a warning
- It is grep friendly

At the end of the day it is a matter of taste. :-)

Signature · 2 lines
Thanks,
//richard