summaryrefslogtreecommitdiff
path: root/fs/ntfs3/frecord.c
diff options
context:
space:
mode:
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2023-01-17 14:01:00 +0300
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2023-03-27 16:44:35 +0300
commit96de65a9413e0422233b285368e8a9a64e461187 (patch)
treeb90c01696305460d6332cbb76673ed169541c8b6 /fs/ntfs3/frecord.c
parent75c5e0c9e5cad34deeec7c131c2b1368df5a8c75 (diff)
downloadlinux-96de65a9413e0422233b285368e8a9a64e461187.tar.xz
fs/ntfs3: Code formatting and refactoring
Added minor refactoring. Added and fixed some comments. In some places, the code has been reformatted to fit into 80 columns. clang-format-12 was used to format code according kernel's .clang-format. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3/frecord.c')
-rw-r--r--fs/ntfs3/frecord.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 9e7dfee303e8..481219f2a7cf 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -76,8 +76,8 @@ struct ATTR_STD_INFO *ni_std(struct ntfs_inode *ni)
const struct ATTRIB *attr;
attr = mi_find_attr(&ni->mi, NULL, ATTR_STD, NULL, 0, NULL);
- return attr ? resident_data_ex(attr, sizeof(struct ATTR_STD_INFO))
- : NULL;
+ return attr ? resident_data_ex(attr, sizeof(struct ATTR_STD_INFO)) :
+ NULL;
}
/*
@@ -91,8 +91,8 @@ struct ATTR_STD_INFO5 *ni_std5(struct ntfs_inode *ni)
attr = mi_find_attr(&ni->mi, NULL, ATTR_STD, NULL, 0, NULL);
- return attr ? resident_data_ex(attr, sizeof(struct ATTR_STD_INFO5))
- : NULL;
+ return attr ? resident_data_ex(attr, sizeof(struct ATTR_STD_INFO5)) :
+ NULL;
}
/*
@@ -1439,8 +1439,8 @@ int ni_insert_nonresident(struct ntfs_inode *ni, enum ATTR_TYPE type,
int err;
CLST plen;
struct ATTRIB *attr;
- bool is_ext =
- (flags & (ATTR_FLAG_SPARSED | ATTR_FLAG_COMPRESSED)) && !svcn;
+ bool is_ext = (flags & (ATTR_FLAG_SPARSED | ATTR_FLAG_COMPRESSED)) &&
+ !svcn;
u32 name_size = ALIGN(name_len * sizeof(short), 8);
u32 name_off = is_ext ? SIZEOF_NONRESIDENT_EX : SIZEOF_NONRESIDENT;
u32 run_off = name_off + name_size;
@@ -1756,9 +1756,9 @@ int ni_new_attr_flags(struct ntfs_inode *ni, enum FILE_ATTRIBUTE new_fa)
}
/* Resize nonresident empty attribute in-place only. */
- new_asize = (new_aflags & (ATTR_FLAG_COMPRESSED | ATTR_FLAG_SPARSED))
- ? (SIZEOF_NONRESIDENT_EX + 8)
- : (SIZEOF_NONRESIDENT + 8);
+ new_asize = (new_aflags & (ATTR_FLAG_COMPRESSED | ATTR_FLAG_SPARSED)) ?
+ (SIZEOF_NONRESIDENT_EX + 8) :
+ (SIZEOF_NONRESIDENT + 8);
if (!mi_resize_attr(mi, attr, new_asize - le32_to_cpu(attr->size)))
return -EOPNOTSUPP;
@@ -2965,14 +2965,14 @@ bool ni_remove_name_undo(struct ntfs_inode *dir_ni, struct ntfs_inode *ni,
{
struct ntfs_sb_info *sbi = ni->mi.sbi;
struct ATTRIB *attr;
- u16 de_key_size = de2 ? le16_to_cpu(de2->key_size) : 0;
+ u16 de_key_size;
switch (undo_step) {
case 4:
+ de_key_size = le16_to_cpu(de2->key_size);
if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0,
- &attr, NULL, NULL)) {
+ &attr, NULL, NULL))
return false;
- }
memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), de2 + 1, de_key_size);
mi_get_ref(&ni->mi, &de2->ref);
@@ -2981,19 +2981,16 @@ bool ni_remove_name_undo(struct ntfs_inode *dir_ni, struct ntfs_inode *ni,
de2->flags = 0;
de2->res = 0;
- if (indx_insert_entry(&dir_ni->dir, dir_ni, de2, sbi, NULL,
- 1)) {
+ if (indx_insert_entry(&dir_ni->dir, dir_ni, de2, sbi, NULL, 1))
return false;
- }
fallthrough;
case 2:
de_key_size = le16_to_cpu(de->key_size);
if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0,
- &attr, NULL, NULL)) {
+ &attr, NULL, NULL))
return false;
- }
memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), de + 1, de_key_size);
mi_get_ref(&ni->mi, &de->ref);
@@ -3162,9 +3159,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
u64 data_size = le64_to_cpu(attr->nres.data_size);
__le64 valid_le;
- dup->alloc_size = is_attr_ext(attr)
- ? attr->nres.total_size
- : attr->nres.alloc_size;
+ dup->alloc_size = is_attr_ext(attr) ?
+ attr->nres.total_size :
+ attr->nres.alloc_size;
dup->data_size = attr->nres.data_size;
if (new_valid > data_size)