All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Remove unnecessary branching in free-space-tree.c
@ 2017-05-17 10:33 Sahil Kang
  2017-05-17 10:33 ` [PATCH 1/1] " Sahil Kang
  0 siblings, 1 reply; 3+ messages in thread
From: Sahil Kang @ 2017-05-17 10:33 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, sahil.kang

Hi David,

Will you merge this patch?
It's a small change that removes an unneeded if statement.

Sahil Kang (1):
  Remove unnecessary branching in free-space-tree.c

 fs/btrfs/free-space-tree.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

-- 
2.1.4


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

* [PATCH 1/1] Remove unnecessary branching in free-space-tree.c
  2017-05-17 10:33 [PATCH 0/1] Remove unnecessary branching in free-space-tree.c Sahil Kang
@ 2017-05-17 10:33 ` Sahil Kang
  2017-05-17 18:41   ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Sahil Kang @ 2017-05-17 10:33 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, sahil.kang

Both btrfs_create_free_space_tree and btrfs_clear_free_space_tree
contain:

  if (ret)
          return ret;

  return 0;

The if statement is only false when ret equals zero, and since we return
zero in such cases, we can safely remove the branching.

Signed-off-by: Sahil Kang <sahil.kang@asilaycomputing.com>
---
 fs/btrfs/free-space-tree.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 53dbeaf..ac7dcaf 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -1185,11 +1185,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
 	btrfs_set_fs_compat_ro(fs_info, FREE_SPACE_TREE);
 	fs_info->creating_free_space_tree = 0;
 
-	ret = btrfs_commit_transaction(trans, tree_root);
-	if (ret)
-		return ret;
-
-	return 0;
+	return btrfs_commit_transaction(trans, tree_root);
 
 abort:
 	fs_info->creating_free_space_tree = 0;
@@ -1273,11 +1269,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
 	free_extent_buffer(free_space_root->commit_root);
 	kfree(free_space_root);
 
-	ret = btrfs_commit_transaction(trans, tree_root);
-	if (ret)
-		return ret;
-
-	return 0;
+	return btrfs_commit_transaction(trans, tree_root);
 
 abort:
 	btrfs_abort_transaction(trans, tree_root, ret);
-- 
2.1.4


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

* Re: [PATCH 1/1] Remove unnecessary branching in free-space-tree.c
  2017-05-17 10:33 ` [PATCH 1/1] " Sahil Kang
@ 2017-05-17 18:41   ` David Sterba
  0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2017-05-17 18:41 UTC (permalink / raw)
  To: Sahil Kang; +Cc: dsterba, linux-btrfs

On Wed, May 17, 2017 at 03:33:45AM -0700, Sahil Kang wrote:
> Both btrfs_create_free_space_tree and btrfs_clear_free_space_tree
> contain:
> 
>   if (ret)
>           return ret;
> 
>   return 0;
> 
> The if statement is only false when ret equals zero, and since we return
> zero in such cases, we can safely remove the branching.

Yeah the code looks better that way. Please don't forget to add the
'btrfs: ' prefix to the subject, I've fixed that now.

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

end of thread, other threads:[~2017-05-17 18:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 10:33 [PATCH 0/1] Remove unnecessary branching in free-space-tree.c Sahil Kang
2017-05-17 10:33 ` [PATCH 1/1] " Sahil Kang
2017-05-17 18:41   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.