From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
<mark@harmstone.com>
Subject: [PATCH] fs/ntfs3: Remove bothcase variable
Date: Thu, 7 Oct 2021 18:37:55 +0300 [thread overview]
Message-ID: <45f2af05-9f5c-bf56-aa91-47d8b0055f5b@paragon-software.com> (raw)
bothcase == true when upcase != NULL
bothcase == false when upcase == NULL
We don't need to have second variable, that is a copy of upcase.
Suggested-by: Mark Harmstone <mark@harmstone.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
fs/ntfs3/attrlist.c | 8 +++-----
fs/ntfs3/frecord.c | 3 +--
fs/ntfs3/index.c | 6 ++----
fs/ntfs3/inode.c | 2 +-
fs/ntfs3/ntfs_fs.h | 4 ++--
fs/ntfs3/record.c | 2 +-
fs/ntfs3/upcase.c | 18 ++++++------------
7 files changed, 16 insertions(+), 27 deletions(-)
diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c
index bad6d8a849a2..1a31ef4ed92b 100644
--- a/fs/ntfs3/attrlist.c
+++ b/fs/ntfs3/attrlist.c
@@ -194,8 +194,7 @@ struct ATTR_LIST_ENTRY *al_find_ex(struct ntfs_inode *ni,
* Compare entry names only for entry with vcn == 0.
*/
diff = ntfs_cmp_names(le_name(le), name_len, name,
- name_len, ni->mi.sbi->upcase,
- true);
+ name_len, ni->mi.sbi->upcase);
if (diff < 0)
continue;
@@ -246,8 +245,7 @@ static struct ATTR_LIST_ENTRY *al_find_le_to_insert(struct ntfs_inode *ni,
* Compare entry names only for entry with vcn == 0.
*/
diff = ntfs_cmp_names(le_name(le), le->name_len, name,
- name_len, ni->mi.sbi->upcase,
- true);
+ name_len, ni->mi.sbi->upcase);
if (diff < 0)
continue;
@@ -393,7 +391,7 @@ bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
if (le->name_len != name_len)
return false;
if (name_len && ntfs_cmp_names(le_name(le), name_len, name, name_len,
- ni->mi.sbi->upcase, true))
+ ni->mi.sbi->upcase))
return false;
if (le64_to_cpu(le->vcn) != vcn)
return false;
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 007602badd90..ecf982aca437 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -1589,8 +1589,7 @@ struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
if (uni->len != fname->name_len)
goto next;
- if (ntfs_cmp_names_cpu(uni, (struct le_str *)&fname->name_len, NULL,
- false))
+ if (ntfs_cmp_names_cpu(uni, (struct le_str *)&fname->name_len, NULL))
goto next;
return fname;
diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 6f81e3a49abf..a12f6fa0537e 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -38,7 +38,6 @@ static int cmp_fnames(const void *key1, size_t l1, const void *key2, size_t l2,
const struct ntfs_sb_info *sbi = data;
const struct ATTR_FILE_NAME *f1;
u16 fsize2;
- bool both_case;
if (l2 <= offsetof(struct ATTR_FILE_NAME, name))
return -1;
@@ -47,7 +46,6 @@ static int cmp_fnames(const void *key1, size_t l1, const void *key2, size_t l2,
if (l2 < fsize2)
return -1;
- both_case = f2->type != FILE_NAME_DOS /*&& !sbi->options.nocase*/;
if (!l1) {
const struct le_str *s2 = (struct le_str *)&f2->name_len;
@@ -55,12 +53,12 @@ static int cmp_fnames(const void *key1, size_t l1, const void *key2, size_t l2,
* If names are equal (case insensitive)
* try to compare it case sensitive.
*/
- return ntfs_cmp_names_cpu(key1, s2, sbi->upcase, both_case);
+ return ntfs_cmp_names_cpu(key1, s2, sbi->upcase);
}
f1 = key1;
return ntfs_cmp_names(f1->name, f1->name_len, f2->name, f2->name_len,
- sbi->upcase, both_case);
+ sbi->upcase);
}
/*
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 7dd162f6a7e2..c7014e5f941c 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -179,7 +179,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
names += 1;
if (name && name->len == fname->name_len &&
!ntfs_cmp_names_cpu(name, (struct le_str *)&fname->name_len,
- NULL, false))
+ NULL))
is_match = true;
goto next_attr;
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 38b7c1a9dc52..859624d0dccb 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -830,9 +830,9 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range);
/* Globals from upcase.c */
int ntfs_cmp_names(const __le16 *s1, size_t l1, const __le16 *s2, size_t l2,
- const u16 *upcase, bool bothcase);
+ const u16 *upcase);
int ntfs_cmp_names_cpu(const struct cpu_str *uni1, const struct le_str *uni2,
- const u16 *upcase, bool bothcase);
+ const u16 *upcase);
/* globals from xattr.c */
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c
index 861e35791506..6afd3c20b0d3 100644
--- a/fs/ntfs3/record.c
+++ b/fs/ntfs3/record.c
@@ -23,7 +23,7 @@ static inline int compare_attr(const struct ATTRIB *left, enum ATTR_TYPE type,
/* They have the same type code, so we have to compare the names. */
return ntfs_cmp_names(attr_name(left), left->name_len, name, name_len,
- upcase, true);
+ upcase);
}
/*
diff --git a/fs/ntfs3/upcase.c b/fs/ntfs3/upcase.c
index b5e8256fd710..c15ae0993839 100644
--- a/fs/ntfs3/upcase.c
+++ b/fs/ntfs3/upcase.c
@@ -24,29 +24,26 @@ static inline u16 upcase_unicode_char(const u16 *upcase, u16 chr)
/*
* ntfs_cmp_names
*
- * Thanks Kari Argillander <kari.argillander@gmail.com> for idea and implementation 'bothcase'
+ * Thanks Kari Argillander <kari.argillander@gmail.com> for idea and implementation
*
* Straight way to compare names:
* - Case insensitive
- * - If name equals and 'bothcases' then
+ * - If name equals and 'upcase' then
* - Case sensitive
* 'Straight way' code scans input names twice in worst case.
* Optimized code scans input names only once.
*/
int ntfs_cmp_names(const __le16 *s1, size_t l1, const __le16 *s2, size_t l2,
- const u16 *upcase, bool bothcase)
+ const u16 *upcase)
{
int diff1 = 0;
int diff2;
size_t len = min(l1, l2);
- if (!bothcase && upcase)
- goto case_insentive;
-
for (; len; s1++, s2++, len--) {
diff1 = le16_to_cpu(*s1) - le16_to_cpu(*s2);
if (diff1) {
- if (bothcase && upcase)
+ if (upcase)
goto case_insentive;
return diff1;
@@ -67,7 +64,7 @@ int ntfs_cmp_names(const __le16 *s1, size_t l1, const __le16 *s2, size_t l2,
}
int ntfs_cmp_names_cpu(const struct cpu_str *uni1, const struct le_str *uni2,
- const u16 *upcase, bool bothcase)
+ const u16 *upcase)
{
const u16 *s1 = uni1->name;
const __le16 *s2 = uni2->name;
@@ -77,13 +74,10 @@ int ntfs_cmp_names_cpu(const struct cpu_str *uni1, const struct le_str *uni2,
int diff1 = 0;
int diff2;
- if (!bothcase && upcase)
- goto case_insentive;
-
for (; len; s1++, s2++, len--) {
diff1 = *s1 - le16_to_cpu(*s2);
if (diff1) {
- if (bothcase && upcase)
+ if (upcase)
goto case_insentive;
return diff1;
--
2.33.0
next reply other threads:[~2021-10-07 15:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 15:37 Konstantin Komarov [this message]
2021-10-07 20:05 ` Kari Argillander
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=45f2af05-9f5c-bf56-aa91-47d8b0055f5b@paragon-software.com \
--to=almaz.alexandrovich@paragon-software.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@harmstone.com \
--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®