Skip to contentSkip to conversation

ntfs3: trivial style cleanups

PATCH New Joe Perches 1 participant 4 messages Aug 28, 2020 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

cover ntfs3: trivial style cleanups

Joe Perches (3):
ntfs3: Add and use logging macros
ntfs3: Use more common brace style
ntfs3: Rename NTFS_FLAGS_LOG_REPLAING to NTFS_FLAGS_LOG_REPLAYING

 fs/ntfs3/attrib.c   |  7 +++--
 fs/ntfs3/attrlist.c |  4 +--
 fs/ntfs3/bitmap.c   | 43 +++++++++++++++--------------
 fs/ntfs3/debug.h    | 12 ++++++++
 fs/ntfs3/dir.c      | 24 +++++++---------
 fs/ntfs3/file.c     | 62 +++++++++++++++++------------------------
 fs/ntfs3/frecord.c  | 45 +++++++++++++++---------------
 fs/ntfs3/fslog.c    | 24 ++++++++--------
 fs/ntfs3/fsntfs.c   | 60 +++++++++++++++++-----------------------
 fs/ntfs3/index.c    | 18 ++++++------
 fs/ntfs3/inode.c    | 22 ++++++---------
 fs/ntfs3/lznt.c     |  3 +-
 fs/ntfs3/namei.c    |  3 +-
 fs/ntfs3/ntfs_fs.h  |  6 ++--
 fs/ntfs3/record.c   | 13 +++++----
 fs/ntfs3/run.c      |  8 +++---
 fs/ntfs3/super.c    | 67 ++++++++++++++++++---------------------------
 fs/ntfs3/xattr.c    | 24 ++++++++--------
 18 files changed, 207 insertions(+), 238 deletions(-)
Signature · 1 line
2.26.0
#1 lore raw

PATCH 1/3 ntfs3: Add and use logging macros

Use more common kernel style by removing direct uses of KERN_<LEVEL>.

Miscellanea:

o Correct spelling of garbage in logging

---
 fs/ntfs3/debug.h   | 12 +++++++++
 fs/ntfs3/dir.c     | 24 ++++++++----------
 fs/ntfs3/file.c    | 47 +++++++++++++----------------------
 fs/ntfs3/frecord.c | 11 +++------
 fs/ntfs3/fslog.c   |  6 ++---
 fs/ntfs3/fsntfs.c  | 43 ++++++++++++--------------------
 fs/ntfs3/index.c   |  2 +-
 fs/ntfs3/inode.c   | 18 +++++---------
 fs/ntfs3/ntfs_fs.h |  4 +--
 fs/ntfs3/super.c   | 61 +++++++++++++++++-----------------------------
 10 files changed, 93 insertions(+), 135 deletions(-)
fs/ntfs3/debug.h +12 -0
index eff8e52b1560..cd3d23dff2d9 100644
@@ -40,6 +40,18 @@ static inline __printf(2, 3) void ntfs_inode_printk(struct inode *inode,
 }
 #endif
 
+#define ntfs_err(sb, fmt, ...)						\
+	ntfs_printk(sb, KERN_ERR fmt, ##__VA_ARGS__)
+#define ntfs_warn(sb, fmt, ...)						\
+	ntfs_printk(sb, KERN_WARNING fmt, ##__VA_ARGS__)
+#define ntfs_notice(sb, fmt, ...)					\
+	ntfs_printk(sb, KERN_NOTICE fmt, ##__VA_ARGS__)
+
+#define ntfs_inode_err(inode, fmt, ...)					\
+	ntfs_inode_printk(inode, KERN_ERR fmt, ##__VA_ARGS__)
+#define ntfs_inode_warn(inode, fmt, ...)				\
+	ntfs_inode_printk(inode, KERN_WARNING fmt, ##__VA_ARGS__)
+
 #define ntfs_alloc(s, z) kmalloc(s, z ? (GFP_NOFS | __GFP_ZERO) : GFP_NOFS)
 #define ntfs_free(p) kfree(p)
 #define ntfs_memdup(src, len) kmemdup(src, len, GFP_NOFS)
fs/ntfs3/dir.c +10 -14
index 5bf0297f6b2f..5a06c6db16ce 100644
@@ -47,8 +47,8 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
 		int charlen;
 
 		if (buf_len < NLS_MAX_CHARSET_SIZE) {
-			ntfs_printk(sbi->sb, KERN_WARNING
-				    "filename was truncated while converting.");
+			ntfs_warn(sbi->sb,
+				  "filename was truncated while converting");
 			break;
 		}
 
@@ -199,13 +199,12 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
 
 		if (!warn) {
 			warn = 1;
-			ntfs_printk(
-				sbi->sb,
-				KERN_ERR
-				"%s -> utf16 failed: '%.*s', pos %d, chars %x %x %x",
-				nls->charset, name_len, name, (int)(str - name),
-				str[0], tail > 1 ? str[1] : 0,
-				tail > 2 ? str[2] : 0);
+			ntfs_err(sbi->sb,
+				 "%s -> utf16 failed: '%.*s', pos %d, chars %x %x %x",
+				 nls->charset, name_len, name,
+				 (int)(str - name),
+				 str[0], tail > 1 ? str[1] : 0,
+				 tail > 2 ? str[2] : 0);
 		}
 
 		if (max_ulen < 3)
@@ -348,10 +347,7 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni,
 	name_len = ntfs_utf16_to_nls(sbi, (struct le_str *)&fname->name_len,
 				     name, PATH_MAX);
 	if (name_len <= 0) {
-		ntfs_printk(sbi->sb,
-			    KERN_WARNING
-			    "failed to convert name for inode %lx.",
-			    ino);
+		ntfs_warn(sbi->sb, "failed to convert name for inode %lx", ino);
 		return 0;
 	}
 
@@ -515,7 +511,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *ctx)
 	}
 
 fs_error:
-	ntfs_inode_printk(dir, KERN_ERR "Looks like your dir is corrupt");
+	ntfs_inode_err(dir, "Looks like your dir is corrupt");
 	err = -EINVAL;
 out:
 
fs/ntfs3/file.c +17 -30

101 lines not on this page · raw message

fs/ntfs3/frecord.c +4 -7
index ad09fca5d7db..3402863c8352 100644
@@ -2298,11 +2298,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 		/*ntfs_iget5 may sleep*/
 		dir = ntfs_iget5(sb, &fname->home, NULL);
 		if (IS_ERR(dir)) {
-			ntfs_inode_printk(
-				inode,
-				KERN_WARNING
-				"failed to open parent directory r=%lx to update",
-				(long)ino_get(&fname->home));
+			ntfs_inode_warn(inode,
+					"failed to open parent directory r=%lx to update",
+					(long)ino_get(&fname->home));
 			continue;
 		}
 
@@ -2362,8 +2360,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 	ni_unlock(ni);
 
 	if (err) {
-		ntfs_printk(sb, KERN_ERR "%s r=%lx failed, %d.", hint,
-			    inode->i_ino, err);
+		ntfs_err(sb, "%s r=%lx failed, %d", hint, inode->i_ino, err);
 		ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
 		return err;
 	}
fs/ntfs3/fslog.c +2 -4
index e9d41b7d99dd..f282e96a45cb 100644
@@ -4096,10 +4096,8 @@ int log_replay(struct ntfs_inode *ni)
 	case 0x20000:
 		break;
 	default:
-		ntfs_printk(sbi->sb,
-			    KERN_WARNING
-			    "$LogFile version %d.%d is not supported",
-			    log->major_ver, log->minor_ver);
+		ntfs_warn(sbi->sb, "$LogFile version %d.%d is not supported",
+			  log->major_ver, log->minor_ver);
 		err = -EOPNOTSUPP;
 		log->set_dirty = true;
 		goto out;
fs/ntfs3/fsntfs.c +16 -27

115 lines not on this page · raw message

fs/ntfs3/index.c +1 -1
index 37ea369318ec..43853daa3a48 100644
@@ -1707,7 +1707,7 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
 		 * new entry classic case when mft record is 1K and index
 		 * buffer 4K the problem should not occurs
 		 */
-		ntfs_printk(sbi->sb, KERN_NOTICE
+		ntfs_notice(sbi->sb,
 			    "Failed: root + new entry > index. Reinsert");
 		ntfs_free(re);
 		indx_write(indx, ni, n, 0);
fs/ntfs3/inode.c +6 -12
index ddc1b5810959..117800126c17 100644
@@ -79,13 +79,12 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 		;
 	else if (ref->seq != rec->seq) {
 		err = -EINVAL;
-		ntfs_printk(sb,
-			    KERN_ERR "MFT: r=%lx, expect seq=%x instead of %x!",
-			    ino, le16_to_cpu(ref->seq), le16_to_cpu(rec->seq));
+		ntfs_err(sb, "MFT: r=%lx, expect seq=%x instead of %x!",
+			 ino, le16_to_cpu(ref->seq), le16_to_cpu(rec->seq));
 		goto out;
 	} else if (!is_rec_inuse(rec)) {
 		err = -EINVAL;
-		ntfs_printk(sb, KERN_ERR "Inode r=%x is not in use!", (u32)ino);
+		ntfs_err(sb, "Inode r=%x is not in use!", (u32)ino);
 		goto out;
 	}
 
@@ -781,10 +780,7 @@ int ntfs_readpage(struct file *file, struct page *page)
 		if (PageLocked(page))
 			wait_on_page_bit(page, PG_locked);
 		if (PageError(page)) {
-			ntfs_inode_printk(inode,
-					  KERN_WARNING
-					  "file garbadge at 0x%llx",
-					  valid);
+			ntfs_inode_warn(inode, "file garbage at 0x%llx", valid);
 			goto out;
 		}
 		zero_user_segment(page, valid & (PAGE_SIZE - 1), PAGE_SIZE);
@@ -904,7 +900,7 @@ static ssize_t ntfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 out:
 	return ret;
 fix_error:
-	ntfs_inode_printk(inode, KERN_WARNING "file garbadge at 0x%llx", valid);
+	ntfs_inode_warn(inode, "file garbage at 0x%llx", valid);
 	goto out;
 }
 
@@ -1414,9 +1410,7 @@ int ntfs_create_inode(struct inode *dir, struct dentry *dentry,
 		nsize = ntfs_reparse_bytes(err);
 
 		if (nsize > sbi->reparse.max_size) {
-			ntfs_printk(sb,
-				    KERN_WARNING "Symbolic link %u is too big",
-				    size);
+			ntfs_warn(sb, "Symbolic link %u is too big", size);
 			err = -EFBIG;
 			goto out4;
 		}
fs/ntfs3/ntfs_fs.h +2 -2
index a28ccc36b288..066c5d0549b1 100644
@@ -892,8 +892,8 @@ static inline struct buffer_head *ntfs_bread(struct super_block *sb,
 	if (bh)
 		return bh;
 
-	ntfs_printk(sb, KERN_ERR "failed to read volume at offset 0x%llx",
-		    (u64)block << sb->s_blocksize_bits);
+	ntfs_err(sb, "failed to read volume at offset 0x%llx",
+		 (u64)block << sb->s_blocksize_bits);
 	return NULL;
 }
 
fs/ntfs3/super.c +23 -38

167 lines not on this page · raw message

Signature · 1 line
2.26.0
#3 lore raw

PATCH 3/3 ntfs3: Rename NTFS_FLAGS_LOG_REPLAING to NTFS_FLAGS_LOG_REPLAYING

In reply to Joe Perches

Use the correct spelling of REPLAY

---
 fs/ntfs3/frecord.c | 2 +-
 fs/ntfs3/fsntfs.c  | 4 ++--
 fs/ntfs3/inode.c   | 2 +-
 fs/ntfs3/ntfs_fs.h | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
fs/ntfs3/frecord.c +1 -1
index 77a9a46d1510..13454de34c21 100644
@@ -2177,7 +2177,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 	upd_parent = ni->ni_flags & NI_FLAG_UPDATE_PARENT;
 	rec = ni->mi.mrec;
 
-	if (!is_rec_inuse(rec) || (sbi->flags & NTFS_FLAGS_LOG_REPLAING))
+	if (!is_rec_inuse(rec) || (sbi->flags & NTFS_FLAGS_LOG_REPLAYING))
 		goto write_subrecords;
 
 	if (!inode->i_nlink)
fs/ntfs3/fsntfs.c +2 -2
index 9c489e8be91a..10cc86ee85b8 100644
@@ -249,7 +249,7 @@ int ntfs_loadlog_and_replay(struct ntfs_inode *ni, struct ntfs_sb_info *sbi)
 		goto out;
 	}
 
-	sbi->flags |= NTFS_FLAGS_LOG_REPLAING;
+	sbi->flags |= NTFS_FLAGS_LOG_REPLAYING;
 
 	ref.low = cpu_to_le32(MFT_REC_MFT);
 	ref.high = 0;
@@ -309,7 +309,7 @@ int ntfs_loadlog_and_replay(struct ntfs_inode *ni, struct ntfs_sb_info *sbi)
 	}
 
 out:
-	sbi->flags &= ~NTFS_FLAGS_LOG_REPLAING;
+	sbi->flags &= ~NTFS_FLAGS_LOG_REPLAYING;
 
 	return err;
 }
fs/ntfs3/inode.c +1 -1
index 3e66ad89d2fd..2f443bd151b0 100644
@@ -75,7 +75,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 
 	rec = ni->mi.mrec;
 
-	if (sbi->flags & NTFS_FLAGS_LOG_REPLAING) {
+	if (sbi->flags & NTFS_FLAGS_LOG_REPLAYING) {
 		;
 	} else if (ref->seq != rec->seq) {
 		err = -EINVAL;
fs/ntfs3/ntfs_fs.h +1 -1
index 066c5d0549b1..0239fe7c6527 100644
@@ -143,7 +143,7 @@ struct ntfs_index {
 };
 
 /* Set when $LogFile is replaying */
-#define NTFS_FLAGS_LOG_REPLAING 0x00000008
+#define NTFS_FLAGS_LOG_REPLAYING 0x00000008
 
 /* Set when we changed first MFT's which copy must be updated in $MftMirr */
 #define NTFS_FLAGS_MFTMIRR 0x00001000
Signature · 1 line
2.26.0
#2 lore raw

PATCH 2/3 ntfs3: Use more common brace style

In reply to Joe Perches

Add open and close braces when if/else arms have multiple statements.

---
 fs/ntfs3/attrib.c   |  7 ++++---
 fs/ntfs3/attrlist.c |  4 ++--
 fs/ntfs3/bitmap.c   | 43 ++++++++++++++++++++++---------------------
 fs/ntfs3/file.c     | 15 ++++++++-------
 fs/ntfs3/frecord.c  | 32 +++++++++++++++++---------------
 fs/ntfs3/fslog.c    | 18 ++++++++++--------
 fs/ntfs3/fsntfs.c   | 13 +++++++------
 fs/ntfs3/index.c    | 16 ++++++++--------
 fs/ntfs3/inode.c    |  4 ++--
 fs/ntfs3/lznt.c     |  3 ++-
 fs/ntfs3/namei.c    |  3 ++-
 fs/ntfs3/record.c   | 13 +++++++------
 fs/ntfs3/run.c      |  8 ++++----
 fs/ntfs3/super.c    |  6 +++---
 fs/ntfs3/xattr.c    | 24 ++++++++++++------------
 15 files changed, 110 insertions(+), 99 deletions(-)
fs/ntfs3/attrib.c +4 -3
index 3a61dbbe2b5f..566847af3c55 100644
@@ -1071,9 +1071,9 @@ int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr,
 				return -ENOENT;
 		}
 
-		if (lcn == SPARSE_LCN)
+		if (lcn == SPARSE_LCN) {
 			slen += len;
-		else {
+		} else {
 			if (slen) {
 				/*
 				 * data_clusters + sparse_clusters =
@@ -1091,8 +1091,9 @@ int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr,
 				 * So it is not compressed
 				 */
 				*clst_data = clst_frame;
-			} else
+			} else {
 				*is_compr = *clst_data < clst_frame;
+			}
 			break;
 		}
 	}
fs/ntfs3/attrlist.c +2 -2
index 3739572a4eca..95a80fe9756d 100644
@@ -444,9 +444,9 @@ int al_update(struct ntfs_inode *ni)
 	if (err)
 		goto out;
 
-	if (!attr->non_res)
+	if (!attr->non_res) {
 		memcpy(resident_data(attr), al->le, al->size);
-	else {
+	} else {
 		err = ntfs_sb_write_run(sbi, &al->run, 0, al->le, al->size);
 		if (err)
 			goto out;
fs/ntfs3/bitmap.c +22 -21

105 lines not on this page · raw message

fs/ntfs3/file.c +8 -7
index 52511299b4b7..5cc34f8661cb 100644
@@ -142,9 +142,9 @@ static int ntfs_extend_initialized_size(struct file *file,
 					goto next;
 				}
 
-				if (vbo < pos)
+				if (vbo < pos) {
 					pos = vbo;
-				else {
+				} else {
 					to = (new_valid >> bits) << bits;
 					if (pos < to) {
 						ni->i_valid = to;
@@ -355,8 +355,9 @@ void ntfs_sparse_cluster(struct inode *inode, struct page *page0, loff_t vbo,
 				if (from <= bh_off && bh_next <= to) {
 					set_buffer_uptodate(bh);
 					mark_buffer_dirty(bh);
-				} else if (!buffer_uptodate(bh))
+				} else if (!buffer_uptodate(bh)) {
 					partial = true;
+				}
 				bh_off = bh_next;
 			} while (head != (bh = bh->b_this_page));
 		}
@@ -995,17 +996,17 @@ static noinline ssize_t ntfs_compress_write(struct kiocb *iocb,
 			if (!bytes || !cp)
 				break;
 
-			if (cp < tail)
+			if (cp < tail) {
 				off += cp;
-			else {
+			} else {
 				ip++;
 				off = 0;
 			}
 		}
 
-		if (!copied)
+		if (!copied) {
 			force_uptodate = true;
-		else {
+		} else {
 			size_t dpages;
 
 			force_uptodate = false;
fs/ntfs3/frecord.c +17 -15
index 3402863c8352..77a9a46d1510 100644
@@ -598,9 +598,9 @@ int ni_create_attr_list(struct ntfs_inode *ni)
 	ni->attr_list.size = lsize;
 
 	to_free = le32_to_cpu(rec->used) + lsize + SIZEOF_RESIDENT;
-	if (to_free <= rs)
+	if (to_free <= rs) {
 		to_free = 0;
-	else {
+	} else {
 		to_free -= rs;
 
 		if (to_free > free_b) {
@@ -1303,9 +1303,9 @@ int ni_delete_all(struct ntfs_inode *ni)
 	if (!attr)
 		goto attr_list;
 
-	if (!nt5 || attr->name_len)
+	if (!nt5 || attr->name_len) {
 		;
-	else if (attr->type == ATTR_REPARSE) {
+	} else if (attr->type == ATTR_REPARSE) {
 		get_mi_ref(&ni->mi, &ref);
 		err = ntfs_remove_reparse(sbi, 0, &ref);
 	} else if (attr->type == ATTR_ID) {
@@ -1653,9 +1653,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
 		}
 
 		flags = FIEMAP_EXTENT_MERGED;
-		if (S_ISDIR(ni->vfs_inode.i_mode))
+		if (S_ISDIR(ni->vfs_inode.i_mode)) {
 			;
-		else if (is_attr_compressed(attr)) {
+		} else if (is_attr_compressed(attr)) {
 			bool is_compr;
 			CLST clst_data;
 
@@ -1666,8 +1666,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
 				break;
 			if (is_compr)
 				flags |= FIEMAP_EXTENT_ENCODED;
-		} else if (is_attr_encrypted(attr))
+		} else if (is_attr_encrypted(attr)) {
 			flags |= FIEMAP_EXTENT_DATA_ENCRYPTED;
+		}
 
 		vbo = (u64)vcn << cluster_bits;
 		bytes = (u64)clen << cluster_bits;
@@ -1680,11 +1681,11 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
 			flags |= FIEMAP_EXTENT_LAST;
 		}
 
-		if (vbo + bytes <= valid)
+		if (vbo + bytes <= valid) {
 			;
-		else if (vbo >= valid)
+		} else if (vbo >= valid) {
 			flags |= FIEMAP_EXTENT_UNWRITTEN;
-		else {
+		} else {
 			/* vbo < valid && valid < vbo + bytes */
 			u64 dlen = valid - vbo;
 
@@ -2234,9 +2235,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 
 		attr = ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL,
 				    &mi);
-		if (!attr)
+		if (!attr) {
 			dup.alloc_size = dup.data_size = 0;
-		else if (!attr->non_res) {
+		} else if (!attr->non_res) {
 			u32 data_size = le32_to_cpu(attr->res.data_size);
 
 			dup.alloc_size = cpu_to_le64(QuadAlign(data_size));
@@ -2289,8 +2290,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 		if (memcmp(&fname->dup, &dup, sizeof(fname->dup))) {
 			memcpy(&fname->dup, &dup, sizeof(fname->dup));
 			mi->dirty = true;
-		} else if (!upd_parent)
+		} else if (!upd_parent) {
 			continue;
+		}
 
 		if (!active)
 			continue; /*avoid __wait_on_freeing_inode(inode); */
@@ -2307,9 +2309,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 		if (!is_bad_inode(dir)) {
 			struct ntfs_inode *dir_ni = ntfs_i(dir);
 
-			if (!ni_trylock(dir_ni))
+			if (!ni_trylock(dir_ni)) {
 				re_dirty = true;
-			else {
+			} else {
 				indx_update_dup(dir_ni, sbi, fname, &dup, sync);
 				ni_unlock(dir_ni);
 			}
fs/ntfs3/fslog.c +10 -8
index f282e96a45cb..c80b5d594d9b 100644
@@ -841,8 +841,9 @@ static inline struct RESTART_TABLE *extend_rsttbl(struct RESTART_TABLE *tbl,
 	if (tbl->first_free) {
 		rt->first_free = tbl->first_free;
 		*(__le32 *)Add2Ptr(rt, le32_to_cpu(tbl->last_free)) = osize;
-	} else
+	} else {
 		rt->first_free = osize;
+	}
 
 	rt->total = tbl->total;
 
@@ -3735,9 +3736,9 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
 			ib->rhdr.lsn = t64;
 	}
 
-	if (inode)
+	if (inode) {
 		err = _ni_write_inode(inode, 0);
-	else if (mi && mi->dirty) {
+	} else if (mi && mi->dirty) {
 		err = mi_write(mi, 0);
 		if (err)
 			goto out;
@@ -4056,9 +4057,9 @@ int log_replay(struct ntfs_inode *ni)
 	log->ra = ra;
 
 	t16 = le16_to_cpu(ra2->client_off);
-	if (t16 == offsetof(struct RESTART_AREA, clients))
+	if (t16 == offsetof(struct RESTART_AREA, clients)) {
 		memcpy(ra, ra2, log->ra_size);
-	else {
+	} else {
 		memcpy(ra, ra2, offsetof(struct RESTART_AREA, clients));
 		memcpy(ra->clients, Add2Ptr(ra2, t16),
 		       le16_to_cpu(ra2->ra_len) - t16);
@@ -4511,11 +4512,11 @@ int log_replay(struct ntfs_inode *ni)
 		 * Calculate the number of clusters per page the system
 		 * which wrote the checkpoint, possibly creating the table
 		 */
-		if (dptbl)
+		if (dptbl) {
 			t32 = 1 + (le16_to_cpu(dptbl->size) -
 				   sizeof(struct DIR_PAGE_ENTRY)) /
 					  sizeof(u64);
-		else {
+		} else {
 			t32 = log->clst_per_page;
 			ntfs_free(dptbl);
 			dptbl = init_rsttbl(sizeof(struct DIR_PAGE_ENTRY) +
@@ -4615,8 +4616,9 @@ int log_replay(struct ntfs_inode *ni)
 			oe->name_len = 0; //oe0.name_len;
 			oe->ref = oe0->ref;
 			oe->open_record_lsn = oe0->open_record_lsn;
-		} else
+		} else {
 			memcpy(oe, Add2Ptr(lrh, t16), bytes_per_attr_entry);
+		}
 
 		t16 = le16_to_cpu(lrh->undo_len);
 		if (t16) {
fs/ntfs3/fsntfs.c +7 -6
index d142b42f2cc2..9c489e8be91a 100644
@@ -196,9 +196,9 @@ int ntfs_extend_init(struct ntfs_sb_info *sbi)
 	/* Try to find $ObjId */
 	inode2 = dir_search_u(inode, &NAME_OBJID, NULL);
 	if (inode2 && !IS_ERR(inode2)) {
-		if (is_bad_inode(inode2))
+		if (is_bad_inode(inode2)) {
 			iput(inode2);
-		else {
+		} else {
 			sbi->objid.ni = ntfs_i(inode2);
 			sbi->objid_no = inode2->i_ino;
 		}
@@ -690,11 +690,11 @@ int ntfs_look_free_mft(struct ntfs_sb_info *sbi, CLST *rno, bool mft,
 		sbi->mft.next_free = MFT_REC_USER;
 
 	for (;;) {
-		if (sbi->mft.next_free >= sbi->mft.bitmap.nbits)
+		if (sbi->mft.next_free >= sbi->mft.bitmap.nbits) {
 			;
-		else if (!wnd_find(wnd, 1, MFT_REC_USER, 0, &fr))
+		} else if (!wnd_find(wnd, 1, MFT_REC_USER, 0, &fr)) {
 			sbi->mft.next_free = sbi->mft.bitmap.nbits;
-		else {
+		} else {
 			*rno = fr;
 			sbi->mft.next_free = *rno + 1;
 			break;
@@ -743,8 +743,9 @@ void ntfs_mark_rec_free(struct ntfs_sb_info *sbi, CLST rno)
 			ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
 		else
 			wnd_set_free(wnd, rno, 1);
-	} else if (rno >= MFT_REC_RESERVED && sbi->mft.reserved_bitmap_inited)
+	} else if (rno >= MFT_REC_RESERVED && sbi->mft.reserved_bitmap_inited) {
 		__clear_bit(rno - MFT_REC_RESERVED, &sbi->mft.reserved_bitmap);
+	}
 
 	if (rno < wnd_zone_bit(wnd))
 		wnd_zone_set(wnd, rno, 1);
fs/ntfs3/index.c +8 -8
index 43853daa3a48..304d48b4e838 100644
@@ -388,9 +388,9 @@ static int scan_nres_bitmap(struct ntfs_sb_info *sbi, struct ATTRIB *bitmap,
 			return -EIO;
 
 		vbo = (u64)vblock << sb->s_blocksize_bits;
-		if (vbo >= valid_size)
+		if (vbo >= valid_size) {
 			memset(bh->b_data, 0, blocksize);
-		else if (vbo + blocksize > valid_size) {
+		} else if (vbo + blocksize > valid_size) {
 			u32 voff = valid_size & sbi->block_mask;
 
 			memset(bh->b_data + voff, 0, blocksize - voff);
@@ -1608,9 +1608,9 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
 	}
 
 	n = NULL;
-	if (!to_move)
+	if (!to_move) {
 		re = NULL;
-	else {
+	} else {
 		re = ntfs_memdup(e0, to_move);
 		if (!re) {
 			err = -ENOMEM;
@@ -2327,9 +2327,9 @@ int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni,
 
 		de_set_vbn_le(next, de_get_vbn_le(e));
 		hdr_delete_de(hdr, e);
-		if (level)
+		if (level) {
 			indx_write(indx, ni, n, 0);
-		else {
+		} else {
 			hdr->total = hdr->used;
 
 			/* Shrink resident root attribute */
@@ -2643,9 +2643,9 @@ int indx_update_dup(struct ntfs_inode *ni, struct ntfs_sb_info *sbi,
 
 	memcpy(&e_fname->dup, dup, sizeof(*dup));
 
-	if (fnd->level)
+	if (fnd->level) {
 		err = indx_write(indx, ni, fnd->nodes[fnd->level - 1], sync);
-	else if (sync) {
+	} else if (sync) {
 		mi->dirty = true;
 		err = mi_write(mi, 1);
 	} else {
fs/ntfs3/inode.c +2 -2
index 117800126c17..3e66ad89d2fd 100644
@@ -75,9 +75,9 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 
 	rec = ni->mi.mrec;
 
-	if (sbi->flags & NTFS_FLAGS_LOG_REPLAING)
+	if (sbi->flags & NTFS_FLAGS_LOG_REPLAING) {
 		;
-	else if (ref->seq != rec->seq) {
+	} else if (ref->seq != rec->seq) {
 		err = -EINVAL;
 		ntfs_err(sb, "MFT: r=%lx, expect seq=%x instead of %x!",
 			 ino, le16_to_cpu(ref->seq), le16_to_cpu(rec->seq));
fs/ntfs3/lznt.c +2 -1
index 123ee648dc38..c9bdecfb1294 100644
@@ -76,8 +76,9 @@ static size_t longest_match_std(const u8 *src, struct lznt *ctx)
 	if (len1 < len2) {
 		ctx->best_match = hash[1];
 		len1 = len2;
-	} else
+	} else {
 		ctx->best_match = hash[0];
+	}
 
 	hash[1] = hash[0];
 	hash[0] = src;
fs/ntfs3/namei.c +2 -1
index 55116311ade9..8dd4adf64058 100644
@@ -515,8 +515,9 @@ static int ntfs_atomic_open(struct inode *dir, struct dentry *dentry,
 			if (file->f_mode & FMODE_OPENED) {
 				dput(d);
 				err = 0;
-			} else
+			} else {
 				err = finish_no_open(file, d);
+			}
 			goto out1;
 		}
 		WARN_ON(d);
fs/ntfs3/record.c +7 -6
index 8a3f7af581b7..4dcddc903b0b 100644
@@ -290,8 +290,9 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr)
 
 		if (attr->nres.c_unit)
 			goto out;
-	} else if (asize + 8 < SIZEOF_NONRESIDENT_EX)
+	} else if (asize + 8 < SIZEOF_NONRESIDENT_EX) {
 		goto out;
+	}
 
 	return attr;
 
@@ -370,15 +371,15 @@ int mi_format_new(struct mft_inode *mi, struct ntfs_sb_info *sbi, CLST rno,
 
 	rec = mi->mrec;
 
-	if (rno == MFT_REC_MFT)
+	if (rno == MFT_REC_MFT) {
 		;
-	else if (rno < MFT_REC_FREE)
+	} else if (rno < MFT_REC_FREE) {
 		seq = rno;
-	else if (rno >= sbi->mft.used)
+	} else if (rno >= sbi->mft.used) {
 		;
-	else if (mi_read(mi, is_mft))
+	} else if (mi_read(mi, is_mft)) {
 		;
-	else if (rec->rhdr.sign == NTFS_FILE_SIGNATURE) {
+	} else if (rec->rhdr.sign == NTFS_FILE_SIGNATURE) {
 		/* Record is reused. Update its sequence number */
 		seq = le16_to_cpu(rec->seq) + 1;
 		if (!seq)
fs/ntfs3/run.c +4 -4
index 4c6757b8bb82..90700de3f346 100644
@@ -401,9 +401,9 @@ bool run_add_entry(struct runs_tree *run, CLST vcn, CLST lcn, CLST len)
 		struct ntfs_run *new_ptr;
 
 		/* Use power of 2 for 'bytes'*/
-		if (!used)
+		if (!used) {
 			bytes = 64;
-		else if (used <= 16 * PAGE_SIZE) {
+		} else if (used <= 16 * PAGE_SIZE) {
 			if (is_power_of2(run->allocated))
 				bytes = run->allocated << 1;
 			else
@@ -603,9 +603,9 @@ int run_pack(const struct runs_tree *run, CLST svcn, CLST len, u8 *run_buf,
 	size_size = run_packed_size(&len64);
 
 	/* offset_size - how much bytes is packed dlcn */
-	if (lcn == SPARSE_LCN)
+	if (lcn == SPARSE_LCN) {
 		offset_size = 0;
-	else {
+	} else {
 		/* NOTE: lcn can be less than prev_lcn! */
 		dlcn = (s64)lcn - prev_lcn;
 		offset_size = run_packed_size(&dlcn);
fs/ntfs3/super.c +3 -3
index 8c8cba759471..f87b91ee04a1 100644
@@ -128,10 +128,10 @@ void *ntfs_set_shared(void *ptr, u32 bytes)
 
 	spin_lock(&s_shared_lock);
 	for (i = 0; i < ARRAY_SIZE(s_shared); i++) {
-		if (!s_shared[i].cnt)
+		if (!s_shared[i].cnt) {
 			j = i;
-		else if (bytes == s_shared[i].len &&
-			 !memcmp(s_shared[i].ptr, ptr, bytes)) {
+		} else if (bytes == s_shared[i].len &&
+			   !memcmp(s_shared[i].ptr, ptr, bytes)) {
 			s_shared[i].cnt += 1;
 			ret = s_shared[i].ptr;
 			break;
fs/ntfs3/xattr.c +12 -12
index 04e1c74b0e3d..496023b0ba4c 100644
@@ -756,11 +756,11 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
 	if (name_len == sizeof(SYSTEM_DOS_ATTRIB) - 1 &&
 	    !memcmp(name, SYSTEM_DOS_ATTRIB, sizeof(SYSTEM_DOS_ATTRIB))) {
 		/* system.dos_attrib */
-		if (!buffer)
+		if (!buffer) {
 			err = sizeof(u8);
-		else if (size < sizeof(u8))
+		} else if (size < sizeof(u8)) {
 			err = -ENODATA;
-		else {
+		} else {
 			err = sizeof(u8);
 			*(u8 *)buffer = le32_to_cpu(ni->std_fa);
 		}
@@ -770,11 +770,11 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
 	if (name_len == sizeof(SYSTEM_NTFS_ATTRIB) - 1 &&
 	    !memcmp(name, SYSTEM_NTFS_ATTRIB, sizeof(SYSTEM_NTFS_ATTRIB))) {
 		/* system.ntfs_attrib */
-		if (!buffer)
+		if (!buffer) {
 			err = sizeof(u32);
-		else if (size < sizeof(u32))
+		} else if (size < sizeof(u32)) {
 			err = -ENODATA;
-		else {
+		} else {
 			err = sizeof(u32);
 			*(u32 *)buffer = le32_to_cpu(ni->std_fa);
 		}
@@ -785,11 +785,11 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
 	    !memcmp(name, SYSTEM_NTFS_ATTRIB_BE,
 		    sizeof(SYSTEM_NTFS_ATTRIB_BE))) {
 		/* system.ntfs_attrib_be */
-		if (!buffer)
+		if (!buffer) {
 			err = sizeof(u32);
-		else if (size < sizeof(u32))
+		} else if (size < sizeof(u32)) {
 			err = -ENODATA;
-		else {
+		} else {
 			err = sizeof(u32);
 			*(__be32 *)buffer =
 				cpu_to_be32(le32_to_cpu(ni->std_fa));
@@ -802,11 +802,11 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
 		    sizeof(SAMBA_PROCESS_NAME)) &&
 	    !memcmp(name, USER_DOSATTRIB, sizeof(USER_DOSATTRIB))) {
 		/* user.DOSATTRIB */
-		if (!buffer)
+		if (!buffer) {
 			err = 5;
-		else if (size < 5)
+		} else if (size < 5) {
 			err = -ENODATA;
-		else {
+		} else {
 			err = sprintf((char *)buffer, "0x%x",
 				      le32_to_cpu(ni->std_fa) & 0xff) +
 			      1;
Signature · 1 line
2.26.0