mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Almaz Alexandrovich <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 1/3] fs/ntfs3: Refactoring of indx_find function
Date: Fri, 27 May 2022 17:21:03 +0300	[thread overview]
Message-ID: <0f9648cc-66af-077c-88e6-8650fd78f44c@paragon-software.com> (raw)
In-Reply-To: <75a1215a-eda2-d0dc-b962-0334356eef7c@paragon-software.com>

This commit makes function a bit more readable

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
  fs/ntfs3/index.c | 20 ++++++--------------
  1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 6f81e3a49abf..511f872b6650 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -1042,19 +1042,16 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,
  {
  	int err;
  	struct NTFS_DE *e;
-	const struct INDEX_HDR *hdr;
  	struct indx_node *node;
  
  	if (!root)
  		root = indx_get_root(&ni->dir, ni, NULL, NULL);
  
  	if (!root) {
-		err = -EINVAL;
-		goto out;
+		/* Should not happed. */
+		return -EINVAL;
  	}
  
-	hdr = &root->ihdr;
-
  	/* Check cache. */
  	e = fnd->level ? fnd->de[fnd->level - 1] : fnd->root_de;
  	if (e && !de_is_last(e) &&
@@ -1068,39 +1065,34 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,
  	fnd_clear(fnd);
  
  	/* Lookup entry that is <= to the search value. */
-	e = hdr_find_e(indx, hdr, key, key_len, ctx, diff);
+	e = hdr_find_e(indx, &root->ihdr, key, key_len, ctx, diff);
  	if (!e)
  		return -EINVAL;
  
  	fnd->root_de = e;
-	err = 0;
  
  	for (;;) {
  		node = NULL;
  		if (*diff >= 0 || !de_has_vcn_ex(e)) {
  			*entry = e;
-			goto out;
+			return 0;
  		}
  
  		/* Read next level. */
  		err = indx_read(indx, ni, de_get_vbn(e), &node);
  		if (err)
-			goto out;
+			return err;
  
  		/* Lookup entry that is <= to the search value. */
  		e = hdr_find_e(indx, &node->index->ihdr, key, key_len, ctx,
  			       diff);
  		if (!e) {
-			err = -EINVAL;
  			put_indx_node(node);
-			goto out;
+			return -EINVAL;
  		}
  
  		fnd_push(fnd, node, e);
  	}
-
-out:
-	return err;
  }
  
  int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
-- 
2.36.1


  reply	other threads:[~2022-05-27 14:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 14:15 [PATCH 0/3] fs/ntfs3: Refactoring and bugfix Almaz Alexandrovich
2022-05-27 14:21 ` Almaz Alexandrovich [this message]
2022-05-27 16:07   ` [PATCH 1/3] fs/ntfs3: Refactoring of indx_find function Joe Perches
2022-05-30 17:11     ` Konstantin Komarov
2022-05-28  0:06   ` Dave Chinner
2022-05-30 16:15     ` Konstantin Komarov
2022-05-27 14:22 ` [PATCH 2/3] fs/ntfs3: Fix double free on remount Almaz Alexandrovich
2022-05-27 14:22 ` [PATCH 3/3] fs/ntfs3: Refactor ni_try_remove_attr_list function Almaz Alexandrovich

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=0f9648cc-66af-077c-88e6-8650fd78f44c@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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

all inboxes | Powered by JetHome®