linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: make tree_mod_alloc return the struct its allocating
@ 2013-07-01 13:30 Josef Bacik
  2013-07-01 13:40 ` Josef Bacik
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2013-07-01 13:30 UTC (permalink / raw)
  To: linux-btrfs

Lets try and be consistent with every other alloc() type function.

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
 fs/btrfs/ctree.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 7921e1d..32e30ad 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -544,8 +544,8 @@ static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info,
  * Returns <0 on error.
  * Returns >0 (the added sequence number) on success.
  */
-static inline int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags,
-				 struct tree_mod_elem **tm_ret)
+static inline struct tree_mod_elem *
+tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags)
 {
 	struct tree_mod_elem *tm;
 
@@ -555,13 +555,13 @@ static inline int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags,
 	 */
 	tm = *tm_ret = kzalloc(sizeof(*tm), GFP_ATOMIC);
 	if (!tm)
-		return -ENOMEM;
+		return NULL;
 
 	spin_lock(&fs_info->tree_mod_seq_lock);
 	tm->seq = btrfs_inc_tree_mod_seq_minor(fs_info);
 	spin_unlock(&fs_info->tree_mod_seq_lock);
 
-	return tm->seq;
+	return tm;
 }
 
 static inline int
@@ -572,9 +572,9 @@ __tree_mod_log_insert_key(struct btrfs_fs_info *fs_info,
 	int ret;
 	struct tree_mod_elem *tm;
 
-	ret = tree_mod_alloc(fs_info, flags, &tm);
-	if (ret < 0)
-		return ret;
+	tm = tree_mod_alloc(fs_info, flags);
+	if (!tm)
+		return -ENOMEM;
 
 	tm->index = eb->start >> PAGE_CACHE_SHIFT;
 	if (op != MOD_LOG_KEY_ADD) {
@@ -642,9 +642,11 @@ tree_mod_log_insert_move(struct btrfs_fs_info *fs_info,
 		BUG_ON(ret < 0);
 	}
 
-	ret = tree_mod_alloc(fs_info, flags, &tm);
-	if (ret < 0)
+	tm = tree_mod_alloc(fs_info, flags);
+	if (!tm) {
+		ret = -ENOMEM;
 		goto out;
+	}
 
 	tm->index = eb->start >> PAGE_CACHE_SHIFT;
 	tm->slot = src_slot;
@@ -691,9 +693,11 @@ tree_mod_log_insert_root(struct btrfs_fs_info *fs_info,
 	if (log_removal)
 		__tree_mod_log_free_eb(fs_info, old_root);
 
-	ret = tree_mod_alloc(fs_info, flags, &tm);
-	if (ret < 0)
+	tm = tree_mod_alloc(fs_info, flags);
+	if (!tm) {
+		ret = -ENOMEM;
 		goto out;
+	}
 
 	tm->index = new_root->start >> PAGE_CACHE_SHIFT;
 	tm->old_root.logical = old_root->start;
-- 
1.7.7.6


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

* Re: [PATCH] Btrfs: make tree_mod_alloc return the struct its allocating
  2013-07-01 13:30 [PATCH] Btrfs: make tree_mod_alloc return the struct its allocating Josef Bacik
@ 2013-07-01 13:40 ` Josef Bacik
  0 siblings, 0 replies; 2+ messages in thread
From: Josef Bacik @ 2013-07-01 13:40 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs

On Mon, Jul 01, 2013 at 09:30:43AM -0400, Josef Bacik wrote:
> Lets try and be consistent with every other alloc() type function.
> 
> Signed-off-by: Josef Bacik <jbacik@fusionio.com>

Ignore this, I didn't compile it and I should have, and I'm just going to delete
this function anyway.  Thanks,

Josef

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

end of thread, other threads:[~2013-07-01 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-01 13:30 [PATCH] Btrfs: make tree_mod_alloc return the struct its allocating Josef Bacik
2013-07-01 13:40 ` Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).