public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree()
@ 2015-02-11  9:17 Bas Peters
  2015-02-11  9:34 ` Julia Lawall
  2015-02-11 11:30 ` SF Markus Elfring
  0 siblings, 2 replies; 6+ messages in thread
From: Bas Peters @ 2015-02-11  9:17 UTC (permalink / raw)
  To: clm, jbacik, dsterba
  Cc: Bas Peters, linux-btrfs, linux-kernel, kernel-janitors

kfree checks whether the pointer it is passed is NULL. The two foregoing
checks are therefore unnecessary.

This issue was detected using Coccinelle.

Signed-off-by: Bas Peters <baspeters93@gmail.com>
---
 fs/btrfs/free-space-cache.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index d6c03f7..7d2d817 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1976,8 +1976,7 @@ new_bitmap:
 
 out:
 	if (info) {
-		if (info->bitmap)
-			kfree(info->bitmap);
+		kfree(info->bitmap);
 		kmem_cache_free(btrfs_free_space_cachep, info);
 	}
 
@@ -3427,8 +3426,7 @@ again:
 
 	if (info)
 		kmem_cache_free(btrfs_free_space_cachep, info);
-	if (map)
-		kfree(map);
+	kfree(map);
 	return 0;
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree()
  2015-02-11  9:17 [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree() Bas Peters
@ 2015-02-11  9:34 ` Julia Lawall
  2015-02-11 11:30 ` SF Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2015-02-11  9:34 UTC (permalink / raw)
  To: Bas Peters
  Cc: clm, jbacik, dsterba, linux-btrfs, linux-kernel, kernel-janitors



On Wed, 11 Feb 2015, Bas Peters wrote:

> kfree checks whether the pointer it is passed is NULL. The two foregoing
> checks are therefore unnecessary.
>
> This issue was detected using Coccinelle.
>
> Signed-off-by: Bas Peters <baspeters93@gmail.com>
> ---
>  fs/btrfs/free-space-cache.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index d6c03f7..7d2d817 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -1976,8 +1976,7 @@ new_bitmap:
>
>  out:
>  	if (info) {
> -		if (info->bitmap)
> -			kfree(info->bitmap);
> +		kfree(info->bitmap);
>  		kmem_cache_free(btrfs_free_space_cachep, info);
>  	}
>
> @@ -3427,8 +3426,7 @@ again:
>
>  	if (info)
>  		kmem_cache_free(btrfs_free_space_cachep, info);
> -	if (map)
> -		kfree(map);
> +	kfree(map);

A certain lack of parallelism arises in the latter case.

julia

>  	return 0;
>  }
>
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree()
  2015-02-11  9:17 [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree() Bas Peters
  2015-02-11  9:34 ` Julia Lawall
@ 2015-02-11 11:30 ` SF Markus Elfring
  2015-02-11 11:49   ` Bas Peters
  1 sibling, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2015-02-11 11:30 UTC (permalink / raw)
  To: Bas Peters, Chris Mason, David Sterba, Josef Bacik
  Cc: linux-btrfs, linux-kernel, kernel-janitors, Julia Lawall

> kfree checks whether the pointer it is passed is NULL. The two foregoing
> checks are therefore unnecessary.
> 
> This issue was detected using Coccinelle.

Would you like to integrate my update suggestion "btrfs: Deletion of
unnecessary checks before six function calls"?
https://lkml.org/lkml/2014/10/31/606
http://article.gmane.org/gmane.linux.kernel/1818924
https://systeme.lip6.fr/pipermail/cocci/2014-October/001321.html

Regards,
Markus


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree()
  2015-02-11 11:30 ` SF Markus Elfring
@ 2015-02-11 11:49   ` Bas Peters
  2015-02-11 12:18     ` SF Markus Elfring
  0 siblings, 1 reply; 6+ messages in thread
From: Bas Peters @ 2015-02-11 11:49 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Chris Mason, David Sterba, Josef Bacik, linux-btrfs, linux-kernel,
	kernel-janitors, Julia Lawall

2015-02-11 12:30 GMT+01:00 SF Markus Elfring <elfring@users.sourceforge.net>:
>> kfree checks whether the pointer it is passed is NULL. The two foregoing
>> checks are therefore unnecessary.
>>
>> This issue was detected using Coccinelle.
>
> Would you like to integrate my update suggestion "btrfs: Deletion of
> unnecessary checks before six function calls"?
> https://lkml.org/lkml/2014/10/31/606
> http://article.gmane.org/gmane.linux.kernel/1818924
> https://systeme.lip6.fr/pipermail/cocci/2014-October/001321.html

Oh, I see you already made the exact same change.
I'll just drop my patch in that case.

>
> Regards,
> Markus
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree()
  2015-02-11 11:49   ` Bas Peters
@ 2015-02-11 12:18     ` SF Markus Elfring
  2015-02-11 12:19       ` Bas Peters
  0 siblings, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2015-02-11 12:18 UTC (permalink / raw)
  To: Bas Peters
  Cc: Chris Mason, David Sterba, Josef Bacik, linux-btrfs, linux-kernel,
	kernel-janitors, Julia Lawall

>> https://lkml.org/lkml/2014/10/31/606
>> http://article.gmane.org/gmane.linux.kernel/1818924
>> https://systeme.lip6.fr/pipermail/cocci/2014-October/001321.html
> 
> Oh, I see you already made the exact same change.

Would you like to add any tags to my update suggestion?

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree()
  2015-02-11 12:18     ` SF Markus Elfring
@ 2015-02-11 12:19       ` Bas Peters
  0 siblings, 0 replies; 6+ messages in thread
From: Bas Peters @ 2015-02-11 12:19 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Chris Mason, David Sterba, Josef Bacik, linux-btrfs, linux-kernel,
	kernel-janitors, Julia Lawall

Markus,

2015-02-11 13:18 GMT+01:00 SF Markus Elfring <elfring@users.sourceforge.net>:
>>> https://lkml.org/lkml/2014/10/31/606
>>> http://article.gmane.org/gmane.linux.kernel/1818924
>>> https://systeme.lip6.fr/pipermail/cocci/2014-October/001321.html
>>
>> Oh, I see you already made the exact same change.
>
> Would you like to add any tags to my update suggestion?

No, it's fine, I should've checked before submitting the patch.

>
> Regards,
> Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-11 12:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-11  9:17 [PATCH] fs: btrfs: free-space-cache.c: remove two unnecessary checks before calling kfree() Bas Peters
2015-02-11  9:34 ` Julia Lawall
2015-02-11 11:30 ` SF Markus Elfring
2015-02-11 11:49   ` Bas Peters
2015-02-11 12:18     ` SF Markus Elfring
2015-02-11 12:19       ` Bas Peters

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox