Skip to contentSkip to conversation

proc: Remove cast from memory allocation

PATCH Applied Tobin C. Harding 2 participants 2 messages Feb 22, 2017 – Jul 25, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: Remove cast from memory allocation

Coccinelle emits WARNING: casting value returned by memory allocation function to (struct proc_inode *) is useless.

Remove unnecessary cast.

---
 fs/proc/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/inode.c +1 -1
index 842a5ff..1eb2326 100644
@@ -57,7 +57,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.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Tobin C. Harding

Coccinelle emits WARNING: casting value returned by memory allocation function to (struct proc_inode *) is useless.

Remove unnecessary cast.

-Kees

Quoted 20 lines
---
 fs/proc/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/inode.c +1 -2
index 842a5ff..1eb2326 100644
@@ -57,7 +57,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;
--

2.7.4

Signature · 2 lines
Kees Cook
Pixel Security