mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
fs/ntfs3: Fix sparse problems
Fixing various problems, detected by sparse. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
@@ -2308,7 +2308,8 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
|
|||||||
|
|
||||||
if (!attr_b->non_res) {
|
if (!attr_b->non_res) {
|
||||||
/* Still resident. */
|
/* 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);
|
memmove(data + bytes, data, bytes);
|
||||||
memset(data, 0, 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)
|
if (vbo <= ni->i_valid)
|
||||||
ni->i_valid += bytes;
|
ni->i_valid += bytes;
|
||||||
|
|
||||||
attr_b->nres.data_size = le64_to_cpu(data_size + bytes);
|
attr_b->nres.data_size = cpu_to_le64(data_size + bytes);
|
||||||
attr_b->nres.alloc_size = le64_to_cpu(alloc_size + bytes);
|
attr_b->nres.alloc_size = cpu_to_le64(alloc_size + bytes);
|
||||||
|
|
||||||
/* ni->valid may be not equal valid_size (temporary). */
|
/* ni->valid may be not equal valid_size (temporary). */
|
||||||
if (ni->i_valid > data_size + bytes)
|
if (ni->i_valid > data_size + bytes)
|
||||||
|
@@ -26,8 +26,8 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
|
|||||||
|
|
||||||
if (!nls) {
|
if (!nls) {
|
||||||
/* UTF-16 -> UTF-8 */
|
/* UTF-16 -> UTF-8 */
|
||||||
ret = utf16s_to_utf8s(name, len, UTF16_LITTLE_ENDIAN, buf,
|
ret = utf16s_to_utf8s((wchar_t *)name, len, UTF16_LITTLE_ENDIAN,
|
||||||
buf_len);
|
buf, buf_len);
|
||||||
buf[ret] = '\0';
|
buf[ret] = '\0';
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -1670,8 +1670,7 @@ next:
|
|||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
fns = (struct le_str *)&fname->name_len;
|
fns = (struct le_str *)&fname->name_len;
|
||||||
if (ntfs_cmp_names(uni->name, uni->len, fns->name, fns->len, NULL,
|
if (ntfs_cmp_names_cpu(uni, fns, NULL, false))
|
||||||
false))
|
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
return fname;
|
return fname;
|
||||||
|
@@ -427,7 +427,8 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
|
|||||||
unsigned int len2 = name->len;
|
unsigned int len2 = name->len;
|
||||||
unsigned int lm = min(len1, len2);
|
unsigned int lm = min(len1, len2);
|
||||||
unsigned char c1, c2;
|
unsigned char c1, c2;
|
||||||
struct cpu_str *uni1, *uni2;
|
struct cpu_str *uni1;
|
||||||
|
struct le_str *uni2;
|
||||||
|
|
||||||
/* First try fast implementation. */
|
/* First try fast implementation. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -464,8 +465,9 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
|
|||||||
|
|
||||||
uni2 = Add2Ptr(uni1, 2048);
|
uni2 = Add2Ptr(uni1, 2048);
|
||||||
|
|
||||||
ret = ntfs_nls_to_utf16(sbi, name->name, name->len, uni2, NTFS_NAME_LEN,
|
ret = ntfs_nls_to_utf16(sbi, name->name, name->len,
|
||||||
UTF16_HOST_ENDIAN);
|
(struct cpu_str *)uni2, NTFS_NAME_LEN,
|
||||||
|
UTF16_LITTLE_ENDIAN);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -474,10 +476,7 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = !ntfs_cmp_names(uni1->name, uni1->len, uni2->name, uni2->len,
|
ret = !ntfs_cmp_names_cpu(uni1, uni2, sbi->upcase, false) ? 0 : 1;
|
||||||
sbi->upcase, false)
|
|
||||||
? 0
|
|
||||||
: 1;
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
__putname(uni1);
|
__putname(uni1);
|
||||||
|
Reference in New Issue
Block a user