public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Mateusz Guzik <mguzik@redhat.com>
To: xfs@oss.sgi.com
Cc: Christoph Hellwig <hch@infradead.org>
Subject: [PATCH] xfs: tidy up xfs_attr_shortform_list
Date: Wed,  2 Mar 2016 16:28:31 +0100	[thread overview]
Message-ID: <1456932511-19305-1-git-send-email-mguzik@redhat.com> (raw)

Remove an unnecessary i == nsbuf test and replace a common label for error
handling after sbuf is allocated.

Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
---
 fs/xfs/xfs_attr_list.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
index 4fa1482..7129fbc 100644
--- a/fs/xfs/xfs_attr_list.c
+++ b/fs/xfs/xfs_attr_list.c
@@ -74,7 +74,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 	xfs_attr_sf_entry_t *sfe;
 	xfs_inode_t *dp;
 	int sbsize, nsbuf, count, i;
-	int error;
+	int error = 0;
 
 	ASSERT(context != NULL);
 	dp = context->dp;
@@ -146,8 +146,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 			XFS_CORRUPTION_ERROR("xfs_attr_shortform_list",
 					     XFS_ERRLEVEL_LOW,
 					     context->dp->i_mount, sfe);
-			kmem_free(sbuf);
-			return -EFSCORRUPTED;
+			error = -EFSCORRUPTED;
+			goto out;
 		}
 
 		sbp->entno = i;
@@ -183,10 +183,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 			break;
 		}
 	}
-	if (i == nsbuf) {
-		kmem_free(sbuf);
-		return 0;
-	}
 
 	/*
 	 * Loop putting entries into the user buffer.
@@ -202,17 +198,16 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 					sbp->namelen,
 					sbp->valuelen,
 					&sbp->name[sbp->namelen]);
-		if (error) {
-			kmem_free(sbuf);
-			return error;
-		}
+		if (error)
+			break;
 		if (context->seen_enough)
 			break;
 		cursor->offset++;
 	}
 
+out:
 	kmem_free(sbuf);
-	return 0;
+	return error;
 }
 
 STATIC int
-- 
1.8.3.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2016-03-02 15:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 15:28 Mateusz Guzik [this message]
2016-03-02 15:47 ` [PATCH] xfs: tidy up xfs_attr_shortform_list Christoph Hellwig

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=1456932511-19305-1-git-send-email-mguzik@redhat.com \
    --to=mguzik@redhat.com \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.com \
    /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