nfs: Remove unnecessary NULL check before kfree()
Subsystems (2)
PATCH RESEND 1/1 nfs: Remove unnecessary NULL check before kfree()
Since kfree() already checks if its argument is NULL, an additional check before calling kfree() is unnecessary and can be removed.
Remove it and thus also the following Coccinelle/coccicheck warning reported by ifnullfree.cocci:
WARNING: NULL check before some freeing functions is not needed
Reviewed-by Benjamin Coddington <[email protected]>
Signed-off-by Thorsten Blum <[email protected]>
--- fs/nfs/read.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfs/read.c +1 -2
@@ -48,8 +48,7 @@ static struct nfs_pgio_header *nfs_readhdr_alloc(void)static void nfs_readhdr_free (struct nfs_pgio_header *rhdr) { -if (rhdr->res.scratch !=NULL ) -kfree (rhdr->res.scratch); +kfree (rhdr->res.scratch);kmem_cache_free (nfs_rdata_cachep, rhdr); }
Signature · 1 line
2.46.0
Quoted 19 lines · Thorsten Blum
Since
kfree()already checks if its argument is NULL, an additional check before callingkfree()is unnecessary and can be removed.Remove it and thus also the following Coccinelle/coccicheck warning reported by
ifnullfree.cocci:WARNING: NULL check before some freeing functions is not needed
Reviewed-by Benjamin Coddington <[email protected]>Signed-off-by Thorsten Blum <[email protected]>--- fs/nfs/read.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/nfs/read.c +0
-0
fs/nfs/read.c static struct nfs_pgio_header *nfs_readhdr_alloc(void) · line 54
Quoted 9 lines
fs/nfs/read.c +1
-2@@ -48,8 +48,7 @@ static struct nfs_pgio_header *nfs_readhdr_alloc(void)static void nfs_readhdr_free (struct nfs_pgio_header *rhdr) { -if (rhdr->res.scratch !=NULL ) -kfree (rhdr->res.scratch); +kfree (rhdr->res.scratch);kmem_cache_free (nfs_rdata_cachep, rhdr); }
Reviewed-by Jeff Layton <[email protected]>