All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, hch@infradead.org,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH 4/7] xfs: clean up xfs_buf_item_get_format return value
Date: Wed, 15 Jan 2020 09:03:18 -0800	[thread overview]
Message-ID: <157910779863.2028015.13882323129750373731.stgit@magnolia> (raw)
In-Reply-To: <157910777330.2028015.5017943601641757827.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

The only thing that can cause a nonzero return from
xfs_buf_item_get_format is if the kmem_alloc fails, which it can't.
Get rid of all the unnecessary error handling.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_buf_item.c |   16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)


diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 3984779e5911..9737f177a49b 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -688,7 +688,7 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
 	.iop_push	= xfs_buf_item_push,
 };
 
-STATIC int
+STATIC void
 xfs_buf_item_get_format(
 	struct xfs_buf_log_item	*bip,
 	int			count)
@@ -698,14 +698,11 @@ xfs_buf_item_get_format(
 
 	if (count == 1) {
 		bip->bli_formats = &bip->__bli_format;
-		return 0;
+		return;
 	}
 
 	bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format),
 				0);
-	if (!bip->bli_formats)
-		return -ENOMEM;
-	return 0;
 }
 
 STATIC void
@@ -731,7 +728,6 @@ xfs_buf_item_init(
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	int			chunks;
 	int			map_size;
-	int			error;
 	int			i;
 
 	/*
@@ -760,13 +756,7 @@ xfs_buf_item_init(
 	 * Discontiguous buffer support follows the layout of the underlying
 	 * buffer. This makes the implementation as simple as possible.
 	 */
-	error = xfs_buf_item_get_format(bip, bp->b_map_count);
-	ASSERT(error == 0);
-	if (error) {	/* to stop gcc throwing set-but-unused warnings */
-		kmem_cache_free(xfs_buf_item_zone, bip);
-		return error;
-	}
-
+	xfs_buf_item_get_format(bip, bp->b_map_count);
 
 	for (i = 0; i < bip->bli_format_count; i++) {
 		chunks = DIV_ROUND_UP(BBTOB(bp->b_maps[i].bm_len),


  parent reply	other threads:[~2020-01-15 17:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 17:02 [PATCH v4 0/7] xfs: fix buf log item memory corruption on non-amd64 Darrick J. Wong
2020-01-15 17:02 ` [PATCH 1/7] xfs: refactor remote attr value buffer invalidation Darrick J. Wong
2020-01-15 17:03 ` [PATCH 2/7] xfs: fix memory corruption during " Darrick J. Wong
2020-01-15 19:10   ` Christoph Hellwig
2020-01-15 17:03 ` [PATCH 3/7] xfs: streamline xfs_attr3_leaf_inactive Darrick J. Wong
2020-01-15 19:14   ` Christoph Hellwig
2020-01-16  1:47   ` [PATCH v2 " Darrick J. Wong
2020-01-16  7:48     ` Christoph Hellwig
2020-01-15 17:03 ` Darrick J. Wong [this message]
2020-01-15 17:03 ` [PATCH 5/7] xfs: complain if anyone tries to create a too-large buffer log item Darrick J. Wong
2020-01-15 17:03 ` [PATCH 6/7] xfs: make struct xfs_buf_log_format have a consistent size Darrick J. Wong
2020-01-15 17:03 ` [PATCH 7/7] xfs: check log iovec size to make sure it's plausibly a buffer log format Darrick J. Wong

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=157910779863.2028015.13882323129750373731.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@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 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.