Skip to content

Commit 9144b43

Browse files
fs/ntfs3: Fix sparse problems
Fixing various problems, detected by sparse. Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 08811ba commit 9144b43

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

fs/ntfs3/attrib.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,8 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
23082308

23092309
if (!attr_b->non_res) {
23102310
/* Still resident. */
2311-
char *data = Add2Ptr(attr_b, attr_b->res.data_off);
2311+
char *data = Add2Ptr(attr_b,
2312+
le16_to_cpu(attr_b->res.data_off));
23122313

23132314
memmove(data + bytes, data, bytes);
23142315
memset(data, 0, bytes);
@@ -2400,8 +2401,8 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
24002401
if (vbo <= ni->i_valid)
24012402
ni->i_valid += bytes;
24022403

2403-
attr_b->nres.data_size = le64_to_cpu(data_size + bytes);
2404-
attr_b->nres.alloc_size = le64_to_cpu(alloc_size + bytes);
2404+
attr_b->nres.data_size = cpu_to_le64(data_size + bytes);
2405+
attr_b->nres.alloc_size = cpu_to_le64(alloc_size + bytes);
24052406

24062407
/* ni->valid may be not equal valid_size (temporary). */
24072408
if (ni->i_valid > data_size + bytes)

fs/ntfs3/dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
2626

2727
if (!nls) {
2828
/* UTF-16 -> UTF-8 */
29-
ret = utf16s_to_utf8s(name, len, UTF16_LITTLE_ENDIAN, buf,
30-
buf_len);
29+
ret = utf16s_to_utf8s((wchar_t *)name, len, UTF16_LITTLE_ENDIAN,
30+
buf, buf_len);
3131
buf[ret] = '\0';
3232
return ret;
3333
}

fs/ntfs3/frecord.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,8 +1670,7 @@ struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
16701670
goto next;
16711671

16721672
fns = (struct le_str *)&fname->name_len;
1673-
if (ntfs_cmp_names(uni->name, uni->len, fns->name, fns->len, NULL,
1674-
false))
1673+
if (ntfs_cmp_names_cpu(uni, fns, NULL, false))
16751674
goto next;
16761675

16771676
return fname;

fs/ntfs3/namei.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
427427
unsigned int len2 = name->len;
428428
unsigned int lm = min(len1, len2);
429429
unsigned char c1, c2;
430-
struct cpu_str *uni1, *uni2;
430+
struct cpu_str *uni1;
431+
struct le_str *uni2;
431432

432433
/* First try fast implementation. */
433434
for (;;) {
@@ -464,8 +465,9 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
464465

465466
uni2 = Add2Ptr(uni1, 2048);
466467

467-
ret = ntfs_nls_to_utf16(sbi, name->name, name->len, uni2, NTFS_NAME_LEN,
468-
UTF16_HOST_ENDIAN);
468+
ret = ntfs_nls_to_utf16(sbi, name->name, name->len,
469+
(struct cpu_str *)uni2, NTFS_NAME_LEN,
470+
UTF16_LITTLE_ENDIAN);
469471
if (ret < 0)
470472
goto out;
471473

@@ -474,10 +476,7 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
474476
goto out;
475477
}
476478

477-
ret = !ntfs_cmp_names(uni1->name, uni1->len, uni2->name, uni2->len,
478-
sbi->upcase, false)
479-
? 0
480-
: 1;
479+
ret = !ntfs_cmp_names_cpu(uni1, uni2, sbi->upcase, false) ? 0 : 1;
481480

482481
out:
483482
__putname(uni1);

0 commit comments

Comments
 (0)