public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: cleanup d_obtain_alias useage
Date: Fri, 29 Aug 2008 01:00:06 +0200	[thread overview]
Message-ID: <20080828230006.GA19138@lst.de> (raw)

d_obtain_alias is intended as a tailcall that can pass in errors encoded
in the inode pointer if needed, so use it that way instead of
duplicating the error handling.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: btrfs-unstable/export.c
===================================================================
--- btrfs-unstable.orig/export.c	2008-08-28 19:56:13.000000000 -0300
+++ btrfs-unstable/export.c	2008-08-28 19:57:04.000000000 -0300
@@ -68,7 +68,6 @@ static struct dentry *btrfs_get_dentry(s
 {
 	struct btrfs_root *root;
 	struct inode *inode;
-	struct dentry *result;
 	struct btrfs_key key;
 
 	key.objectid = root_objectid;
@@ -92,11 +91,7 @@ static struct dentry *btrfs_get_dentry(s
 		return ERR_PTR(-ESTALE);
 	}
 
-	result = d_obtain_alias(inode);
-	if (!result)
-		return ERR_PTR(-ENOMEM);
-
-	return result;
+	return d_obtain_alias(inode);
 }
 
 static struct dentry *btrfs_fh_to_parent(struct super_block *sb, struct fid *fh,
@@ -148,8 +143,6 @@ static struct dentry *btrfs_fh_to_dentry
 static struct dentry *btrfs_get_parent(struct dentry *child)
 {
 	struct inode *dir = child->d_inode;
-	struct inode *inode;
-	struct dentry *parent;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct btrfs_key key;
 	struct btrfs_path *path;
@@ -203,13 +196,7 @@ static struct dentry *btrfs_get_parent(s
 	btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
 	key.offset = 0;
 
-	inode = btrfs_iget(root->fs_info->sb, &key, root, NULL);
-
-	parent = d_obtain_alias(inode);
-	if (!parent)
-		parent = ERR_PTR(-ENOMEM);
-
-	return parent;
+	return d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root, NULL));
 }
 
 const struct export_operations btrfs_export_ops = {

                 reply	other threads:[~2008-08-28 23:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080828230006.GA19138@lst.de \
    --to=hch@lst.de \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox