From: Chengguang Xu <cgxu519@zoho.com.cn>
To: jack@suse.com
Cc: linux-ext4@vger.kernel.org, Chengguang Xu <cgxu519@zoho.com.cn>
Subject: [PATCH v2 2/3] ext2: introduce new helper for xattr entry comparison
Date: Tue, 28 May 2019 10:59:46 +0800 [thread overview]
Message-ID: <20190528025947.18373-2-cgxu519@zoho.com.cn> (raw)
In-Reply-To: <20190528025947.18373-1-cgxu519@zoho.com.cn>
Introduce new helper ext2_xattr_cmp_entry() for xattr
entry comparison.
Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
---
fs/ext2/xattr.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 28503979696d..59356cd2a842 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -166,6 +166,21 @@ ext2_xattr_entry_valid(struct ext2_xattr_entry *entry,
return true;
}
+static int
+ext2_xattr_cmp_entry(int name_index, size_t name_len, const char *name,
+ struct ext2_xattr_entry *entry)
+{
+ int cmp;
+
+ cmp = name_index - entry->e_name_index;
+ if (!cmp)
+ cmp = name_len - entry->e_name_len;
+ if (!cmp)
+ cmp = memcmp(name, entry->e_name, name_len);
+
+ return cmp;
+}
+
/*
* ext2_xattr_get()
*
@@ -452,13 +467,9 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name,
min_offs = offs;
}
if (not_found > 0) {
- not_found = name_index - last->e_name_index;
- if (!not_found)
- not_found = name_len - last->e_name_len;
- if (!not_found) {
- not_found = memcmp(name, last->e_name,
- name_len);
- }
+ not_found = ext2_xattr_cmp_entry(name_index,
+ name_len,
+ name, last);
if (not_found <= 0)
here = last;
}
--
2.20.1
next prev parent reply other threads:[~2019-05-28 3:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 2:59 [PATCH v2 1/3] ext2: merge xattr next entry check to ext2_xattr_entry_valid() Chengguang Xu
2019-05-28 2:59 ` Chengguang Xu [this message]
2019-05-28 2:59 ` [PATCH v2 3/3] ext2: optimize ext2_xattr_get() Chengguang Xu
2019-05-28 8:30 ` [PATCH v2 1/3] ext2: merge xattr next entry check to ext2_xattr_entry_valid() Jan Kara
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=20190528025947.18373-2-cgxu519@zoho.com.cn \
--to=cgxu519@zoho.com.cn \
--cc=jack@suse.com \
--cc=linux-ext4@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;
as well as URLs for NNTP newsgroup(s).