All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 2/4] fs/ntfs3: Fix sparse problems
Date: Fri, 21 Oct 2022 19:52:01 +0300	[thread overview]
Message-ID: <21a9d399-f3bf-6e57-0f38-cdbf68fdad58@paragon-software.com> (raw)
In-Reply-To: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com>

Fixing various problems, detected by sparse.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
  fs/ntfs3/attrib.c  |  7 ++++---
  fs/ntfs3/dir.c     |  4 ++--
  fs/ntfs3/frecord.c |  3 +--
  fs/ntfs3/namei.c   | 13 ++++++-------
  4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 63169529b52c..b2f54fab4001 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -2308,7 +2308,8 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
  
  		if (!attr_b->non_res) {
  			/* Still resident. */
-			char *data = Add2Ptr(attr_b, attr_b->res.data_off);
+			char *data = Add2Ptr(attr_b,
+					     le16_to_cpu(attr_b->res.data_off));
  
  			memmove(data + bytes, data, bytes);
  			memset(data, 0, bytes);
@@ -2400,8 +2401,8 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
  	if (vbo <= ni->i_valid)
  		ni->i_valid += bytes;
  
-	attr_b->nres.data_size = le64_to_cpu(data_size + bytes);
-	attr_b->nres.alloc_size = le64_to_cpu(alloc_size + bytes);
+	attr_b->nres.data_size = cpu_to_le64(data_size + bytes);
+	attr_b->nres.alloc_size = cpu_to_le64(alloc_size + bytes);
  
  	/* ni->valid may be not equal valid_size (temporary). */
  	if (ni->i_valid > data_size + bytes)
diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c
index fb438d604040..063a6654199b 100644
--- a/fs/ntfs3/dir.c
+++ b/fs/ntfs3/dir.c
@@ -26,8 +26,8 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
  
  	if (!nls) {
  		/* UTF-16 -> UTF-8 */
-		ret = utf16s_to_utf8s(name, len, UTF16_LITTLE_ENDIAN, buf,
-				      buf_len);
+		ret = utf16s_to_utf8s((wchar_t *)name, len, UTF16_LITTLE_ENDIAN,
+				      buf, buf_len);
  		buf[ret] = '\0';
  		return ret;
  	}
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 8a741706c7a5..a7aed31e7c93 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -1670,8 +1670,7 @@ struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
  		goto next;
  
  	fns = (struct le_str *)&fname->name_len;
-	if (ntfs_cmp_names(uni->name, uni->len, fns->name, fns->len, NULL,
-			       false))
+	if (ntfs_cmp_names_cpu(uni, fns, NULL, false))
  		goto next;
  
  	return fname;
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index 315763eb05ff..ff76389475ad 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -427,7 +427,8 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
  	unsigned int len2 = name->len;
  	unsigned int lm = min(len1, len2);
  	unsigned char c1, c2;
-	struct cpu_str *uni1, *uni2;
+	struct cpu_str *uni1;
+	struct le_str *uni2;
  
  	/* First try fast implementation. */
  	for (;;) {
@@ -468,8 +469,9 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
  
  	uni2 = Add2Ptr(uni1, 2048);
  
-	ret = ntfs_nls_to_utf16(sbi, name->name, name->len, uni2, NTFS_NAME_LEN,
-				UTF16_HOST_ENDIAN);
+	ret = ntfs_nls_to_utf16(sbi, name->name, name->len,
+				(struct cpu_str *)uni2, NTFS_NAME_LEN,
+				UTF16_LITTLE_ENDIAN);
  	if (ret < 0)
  		goto out;
  
@@ -478,10 +480,7 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
  		goto out;
  	}
  
-	ret = !ntfs_cmp_names(uni1->name, uni1->len, uni2->name, uni2->len,
-			      sbi->upcase, false)
-		      ? 0
-		      : 1;
+	ret = !ntfs_cmp_names_cpu(uni1, uni2, sbi->upcase, false) ? 0 : 1;
  
  out:
  	__putname(uni1);
-- 
2.37.0



  parent reply	other threads:[~2022-10-21 16:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 16:50 [PATCH 0/4] fs/ntfs3: Bugfix and refactoring Konstantin Komarov
2022-10-21 16:51 ` [PATCH 1/4] fs/ntfs3: Add ntfs_bitmap_weight_le function " Konstantin Komarov
2022-10-21 16:52 ` Konstantin Komarov [this message]
2022-10-21 16:52 ` [PATCH 3/4] fs/ntfs3: Remove unused functions Konstantin Komarov
2022-10-21 16:53 ` [PATCH 4/4] fs/ntfs3: Simplify ntfs_update_mftmirr function Konstantin Komarov

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=21a9d399-f3bf-6e57-0f38-cdbf68fdad58@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 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.