tux3: Some cleanup for checkpatch

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
diff --git a/fs/tux3/btree.c b/fs/tux3/btree.c
index 2f1f2d7..6bd0813 100644
--- a/fs/tux3/btree.c
+++ b/fs/tux3/btree.c
@@ -826,7 +826,8 @@
 		 * FIXME: If leaf was merged and freed later, we don't
 		 * need to redirect leaf and leaf_chop()
 		 */
-		if ((ret = cursor_redirect(cursor)))
+		ret = cursor_redirect(cursor);
+		if (ret)
 			goto out;
 		leafbuf = cursor_pop(cursor);
 
diff --git a/fs/tux3/commit.c b/fs/tux3/commit.c
index 59de34b..dd76d49 100644
--- a/fs/tux3/commit.c
+++ b/fs/tux3/commit.c
@@ -776,10 +776,10 @@
  *
  * change_begin()
  * while (stop) {
- * 	change_begin_if_need()
- * 	if (do_something() < 0)
- * 		break;
- * 	change_end_if_need()
+ *	change_begin_if_need()
+ *	if (do_something() < 0)
+ *		break;
+ *	change_end_if_need()
  * }
  * change_end_if_need()
  */
diff --git a/fs/tux3/dir.c b/fs/tux3/dir.c
index 9007e94..26feaa5 100644
--- a/fs/tux3/dir.c
+++ b/fs/tux3/dir.c
@@ -35,7 +35,7 @@
 #endif
 
 #define TUX_DIR_ALIGN		sizeof(inum_t)
-#define TUX_DIR_HEAD		(offsetof(tux_dirent, name))
+#define TUX_DIR_HEAD		(offsetof(struct tux3_dirent, name))
 #define TUX_REC_LEN(name_len)	ALIGN((name_len) + TUX_DIR_HEAD, TUX_DIR_ALIGN)
 #define TUX_MAX_REC_LEN		((1 << 16) - 1)
 
@@ -56,12 +56,12 @@
 	return cpu_to_be16(len);
 }
 
-static inline int is_deleted(tux_dirent *entry)
+static inline int is_deleted(struct tux3_dirent *entry)
 {
 	return !entry->name_len; /* ext2 uses !inum for this */
 }
 
-static inline int tux_match(tux_dirent *entry, const char *const name,
+static inline int tux_match(struct tux3_dirent *entry, const char *const name,
 			    unsigned len)
 {
 	if (len != entry->name_len)
@@ -71,7 +71,7 @@
 	return !memcmp(name, entry->name, len);
 }
 
-static inline tux_dirent *next_entry(tux_dirent *entry)
+static inline struct tux3_dirent *next_entry(struct tux3_dirent *entry)
 {
 	return (void *)entry + tux_rec_len_from_disk(entry->rec_len);
 }
@@ -105,7 +105,7 @@
 		      "zero length entry at inum %Lu, block %Lu",	\
 		      tux_inode(dir)->inum, block)
 
-void tux_set_entry(struct buffer_head *buffer, tux_dirent *entry,
+void tux_set_entry(struct buffer_head *buffer, struct tux3_dirent *entry,
 		   inum_t inum, umode_t mode)
 {
 	entry->inum = cpu_to_be64(inum);
@@ -119,7 +119,7 @@
  * "..". rename() shouldn't update ->mtime for ".." usually.
  */
 void tux_update_dirent(struct inode *dir, struct buffer_head *buffer,
-		       tux_dirent *entry, struct inode *inode)
+		       struct tux3_dirent *entry, struct inode *inode)
 {
 	tux_set_entry(buffer, entry, tux_inode(inode)->inum, inode->i_mode);
 
@@ -133,7 +133,7 @@
 {
 	unsigned delta = tux3_get_current_delta();
 	struct sb *sb = tux_sb(dir->i_sb);
-	tux_dirent *entry;
+	struct tux3_dirent *entry;
 	struct buffer_head *buffer, *clone;
 	unsigned reclen = TUX_REC_LEN(len), rec_len, offset;
 	unsigned uninitialized_var(name_len);
@@ -146,7 +146,7 @@
 		if (!buffer)
 			return -EIO;
 		entry = bufdata(buffer);
-		tux_dirent *limit = bufdata(buffer) + blocksize - reclen;
+		struct tux3_dirent *limit = bufdata(buffer) + blocksize - reclen;
 		while (entry <= limit) {
 			if (entry->rec_len == 0) {
 				blockput(buffer);
@@ -191,7 +191,7 @@
 		entry = ptr_redirect(entry, olddata, bufdata(clone));
 
 		if (!is_deleted(entry)) {
-			tux_dirent *newent = (void *)entry + name_len;
+			struct tux3_dirent *newent = (void *)entry + name_len;
 			unsigned rest_rec_len = rec_len - name_len;
 			newent->rec_len = tux_rec_len_to_disk(rest_rec_len);
 			entry->rec_len = tux_rec_len_to_disk(name_len);
@@ -215,7 +215,7 @@
 	const char *name = (const char *)qstr->name;
 	unsigned len = qstr->len;
 	struct buffer_head *buffer;
-	tux_dirent *entry;
+	struct tux3_dirent *entry;
 	loff_t i_size, where;
 	int err, err2;
 
@@ -256,8 +256,9 @@
 	return err;
 }
 
-tux_dirent *tux_find_entry(struct inode *dir, const char *name, unsigned len,
-			   struct buffer_head **result, loff_t size)
+struct tux3_dirent *tux_find_entry(struct inode *dir, const char *name,
+				   unsigned len, struct buffer_head **result,
+				   loff_t size)
 {
 	struct sb *sb = tux_sb(dir->i_sb);
 	unsigned reclen = TUX_REC_LEN(len);
@@ -270,8 +271,8 @@
 			err = -EIO; // need ERR_PTR for blockread!!!
 			goto error;
 		}
-		tux_dirent *entry = bufdata(buffer);
-		tux_dirent *limit = (void *)entry + sb->blocksize - reclen;
+		struct tux3_dirent *entry = bufdata(buffer);
+		struct tux3_dirent *limit = (void *)entry + sb->blocksize - reclen;
 		while (entry <= limit) {
 			if (entry->rec_len == 0) {
 				blockput(buffer);
@@ -292,8 +293,8 @@
 	return ERR_PTR(err);
 }
 
-tux_dirent *tux_find_dirent(struct inode *dir, const struct qstr *qstr,
-			    struct buffer_head **result)
+struct tux3_dirent *tux_find_dirent(struct inode *dir, const struct qstr *qstr,
+				    struct buffer_head **result)
 {
 	/* Holding dir->i_mutex, so no i_size_read() */
 	return tux_find_entry(dir, (const char *)qstr->name, qstr->len,
@@ -315,7 +316,8 @@
  * Return 0 if the directory entry is OK, and 1 if there is a problem
  */
 static int __check_dir_entry(const char *func, int line, struct inode *dir,
-			     struct buffer_head *buffer, tux_dirent *entry)
+			     struct buffer_head *buffer,
+			     struct tux3_dirent *entry)
 {
 	struct sb *sb = tux_sb(dir->i_sb);
 	const char *error_msg = NULL;
@@ -366,8 +368,8 @@
 		void *base = bufdata(buffer);
 		if (revalidate) {
 			if (offset) {
-				tux_dirent *entry = base + offset;
-				tux_dirent *p = base + (offset & sb->blockmask);
+				struct tux3_dirent *entry = base + offset;
+				struct tux3_dirent *p = base + (offset & sb->blockmask);
 				while (p < entry && p->rec_len)
 					p = next_entry(p);
 				offset = (void *)p - base;
@@ -376,8 +378,8 @@
 			file->f_version = dir->i_version;
 			revalidate = 0;
 		}
-		tux_dirent *limit = base + sb->blocksize - TUX_REC_LEN(1);
-		for (tux_dirent *entry = base + offset; entry <= limit; entry = next_entry(entry)) {
+		struct tux3_dirent *limit = base + sb->blocksize - TUX_REC_LEN(1);
+		for (struct tux3_dirent *entry = base + offset; entry <= limit; entry = next_entry(entry)) {
 			if (check_dir_entry(dir, buffer, entry)) {
 				/* On error, skip to next block */
 				ctx->pos = (ctx->pos | (sb->blocksize - 1)) + 1;
@@ -405,10 +407,10 @@
 }
 
 int tux_delete_entry(struct inode *dir, struct buffer_head *buffer,
-		     tux_dirent *entry)
+		     struct tux3_dirent *entry)
 {
 	unsigned delta = tux3_get_current_delta();
-	tux_dirent *prev = NULL, *this = bufdata(buffer);
+	struct tux3_dirent *prev = NULL, *this = bufdata(buffer);
 	struct buffer_head *clone;
 	void *olddata;
 
@@ -449,7 +451,7 @@
 }
 
 int tux_delete_dirent(struct inode *dir, struct buffer_head *buffer,
-		      tux_dirent *entry)
+		      struct tux3_dirent *entry)
 {
 	int err;
 
@@ -475,8 +477,8 @@
 		if (!buffer)
 			return -EIO;
 
-		tux_dirent *entry = bufdata(buffer);
-		tux_dirent *limit = bufdata(buffer) + sb->blocksize - TUX_REC_LEN(1);
+		struct tux3_dirent *entry = bufdata(buffer);
+		struct tux3_dirent *limit = bufdata(buffer) + sb->blocksize - TUX_REC_LEN(1);
 		for (; entry <= limit; entry = next_entry(entry)) {
 			if (!entry->rec_len) {
 				blockput(buffer);
diff --git a/fs/tux3/dleaf.c b/fs/tux3/dleaf.c
index 62e0d5d..dd72f78 100644
--- a/fs/tux3/dleaf.c
+++ b/fs/tux3/dleaf.c
@@ -482,7 +482,7 @@
 		unsigned len;
 		int last, hole_len;
 
-		len = __dleaf_read(btree, key_bottom, key_limit, dleaf, key,1);
+		len = __dleaf_read(btree, key_bottom, key_limit, dleaf, key, 1);
 		last = rq->seg_cnt;
 
 		/* Remove hole from seg[] */
diff --git a/fs/tux3/iattr.c b/fs/tux3/iattr.c
index 3d9fc18..5b93a09 100644
--- a/fs/tux3/iattr.c
+++ b/fs/tux3/iattr.c
@@ -60,8 +60,7 @@
 	void *limit = attrs + size;
 	unsigned head;
 
-	while (attrs < limit - 1)
-	{
+	while (attrs < limit - 1) {
 		attrs = decode16(attrs, &head);
 		unsigned kind = head >> 12;
 		if (kind >= MAX_ATTRS)
diff --git a/fs/tux3/ileaf.c b/fs/tux3/ileaf.c
index 9cb5d33..69c3cc7 100644
--- a/fs/tux3/ileaf.c
+++ b/fs/tux3/ileaf.c
@@ -112,7 +112,8 @@
 	if (at < icount(leaf)) {
 		__be16 *dict = ileaf_dict(btree, leaf);
 		unsigned offset = atdict(dict, at);
-		if ((size = __atdict(dict, at + 1) - offset))
+		size = __atdict(dict, at + 1) - offset;
+		if (size)
 			attrs = leaf->table + offset;
 	}
 	*result = size;
@@ -122,10 +123,14 @@
 static int isinorder(struct btree *btree, struct ileaf *leaf)
 {
 	__be16 *dict = ileaf_dict(btree, leaf);
+	unsigned offset = 0;
 
-	for (int i = 0, offset = 0, limit; i < icount(leaf); i++, offset = limit)
-		if ((limit = __atdict(dict, i + 1)) < offset)
+	for (int i = 0; i < icount(leaf); i++) {
+		unsigned limit = __atdict(dict, i + 1);
+		if (limit < offset)
 			return 0;
+		offset = limit;
+	}
 	return 1;
 }
 
diff --git a/fs/tux3/inode.c b/fs/tux3/inode.c
index 9fada1a..9d9f6ff 100644
--- a/fs/tux3/inode.c
+++ b/fs/tux3/inode.c
@@ -374,9 +374,8 @@
 	case 0: /* internal inode */
 		if (tux_inode(inode)->inum == TUX_VOLMAP_INO)
 			assert(tuxnode->present == 0);
-		else {
+		else
 			assert(!(tuxnode->present & RDEV_BIT));
-		}
 		break;
 	default:
 		tux3_fs_error(tux_sb(inode->i_sb),
@@ -401,7 +400,8 @@
 		goto out;
 	}
 
-	if ((err = btree_probe(cursor, tux_inode(inode)->inum)))
+	err = btree_probe(cursor, tux_inode(inode)->inum);
+	if (err)
 		goto out;
 
 	/* Read inode attribute from inode btree */
@@ -482,7 +482,8 @@
 		return -ENOMEM;
 
 	down_write(&cursor->btree->lock);
-	if ((err = btree_probe(cursor, inum)))
+	err = btree_probe(cursor, inum);
+	if (err)
 		goto out;
 	/* paranoia check */
 	if (!is_defer_alloc_inum(inode)) {
diff --git a/fs/tux3/link.h b/fs/tux3/link.h
index 0d96c65..dbdc44e 100644
--- a/fs/tux3/link.h
+++ b/fs/tux3/link.h
@@ -39,9 +39,9 @@
 	node->next = node->next->next;
 }
 
-#define link_for_each_safe(pos, prev, n, head)			\
-        for (pos = (head)->next, prev = (head), n = pos->next;  \
-	     pos != (head);					\
+#define link_for_each_safe(pos, prev, n, head)				\
+	for (pos = (head)->next, prev = (head), n = pos->next;		\
+	     pos != (head);						\
 	     prev = ((prev->next == n) ? prev : pos), pos = n, n = pos->next)
 
 /* Single linked list (FIFO order) */
@@ -53,7 +53,7 @@
 	link_entry(flink_next(head), type, member)
 /* take care: this doesn't check member is `struct link *' or not */
 #define __flink_next_entry(head, type, member) ({			\
-	struct link *next = flink_next(head);	       			\
+	struct link *next = flink_next(head);				\
 	link_entry((typeof(((type *)0)->member) *)next, type, member);	\
 })
 
diff --git a/fs/tux3/log.c b/fs/tux3/log.c
index 3464d01..7867d69d 100644
--- a/fs/tux3/log.c
+++ b/fs/tux3/log.c
@@ -535,8 +535,8 @@
 		if (top == stash->top)
 			top = stash->pos;
 		for (; vec < top; vec++) {
-			int err;
-			if ((err = actor(sb, *vec)))
+			int err = actor(sb, *vec);
+			if (err)
 				return err;
 		}
 		if (flink_is_last(head))
@@ -569,8 +569,8 @@
 		if (top == stash->top)
 			top = stash->pos;
 		for (; vec < top; vec++) {
-			int err;
-			if ((err = actor(sb, *vec)))
+			int err = actor(sb, *vec);
+			if (err)
 				return err;
 		}
 
diff --git a/fs/tux3/namei.c b/fs/tux3/namei.c
index b73bfee..853c603 100644
--- a/fs/tux3/namei.c
+++ b/fs/tux3/namei.c
@@ -13,7 +13,7 @@
 	struct sb *sb = tux_sb(dir->i_sb);
 	struct buffer_head *buffer;
 	struct inode *inode;
-	tux_dirent *entry;
+	struct tux3_dirent *entry;
 	inum_t inum;
 
 	entry = tux_find_dirent(dir, &dentry->d_name, &buffer);
@@ -122,7 +122,7 @@
 static int tux_del_dirent(struct inode *dir, struct dentry *dentry)
 {
 	struct buffer_head *buffer;
-	tux_dirent *entry;
+	struct tux3_dirent *entry;
 
 	entry = tux_find_dirent(dir, &dentry->d_name, &buffer);
 	if (IS_ERR(entry))
@@ -235,7 +235,7 @@
 	struct inode *new_inode = new_dentry->d_inode;
 	struct sb *sb = tux_sb(old_inode->i_sb);
 	struct buffer_head *old_buffer, *new_buffer, *clone;
-	tux_dirent *old_entry, *new_entry;
+	struct tux3_dirent *old_entry, *new_entry;
 	void *olddata;
 	int err, new_subdir = 0;
 	unsigned delta;
diff --git a/fs/tux3/replay.c b/fs/tux3/replay.c
index 23056a6..06206be 100644
--- a/fs/tux3/replay.c
+++ b/fs/tux3/replay.c
@@ -10,7 +10,7 @@
 #define trace trace_on
 #endif
 
-static const char *log_name[] = {
+static const char *const log_name[] = {
 #define X(x)	[x] = #x
 	X(LOG_BALLOC),
 	X(LOG_BFREE),
diff --git a/fs/tux3/tux3.h b/fs/tux3/tux3.h
index f52e690..002d6d4 100644
--- a/fs/tux3/tux3.h
+++ b/fs/tux3/tux3.h
@@ -551,18 +551,18 @@
 
 #define TUX_NAME_LEN 255
 
-/* directory entry */
-typedef struct {
+/* Directory entry */
+struct tux3_dirent {
 	__be64 inum;
 	__be16 rec_len;
 	u8 name_len, type;
 	char name[];
 	/*
-	 * On 64bit arch sizeof(tux_dirent) == 16. We should use
-	 * offsetof(tux_dirent, name) instead.
+	 * On 64bit arch sizeof(struct tux3_dirent) == 16. We should use
+	 * offsetof(struct tux3_dirent, name) instead.
 	 */
 	/* u32 __pad; */
-} tux_dirent;
+};
 
 struct btree_key_range {
 	tuxkey_t start;
@@ -797,22 +797,23 @@
 #include "commit_flusher.h"
 
 /* dir.c */
-void tux_set_entry(struct buffer_head *buffer, tux_dirent *entry,
+void tux_set_entry(struct buffer_head *buffer, struct tux3_dirent *entry,
 		   inum_t inum, umode_t mode);
 void tux_update_dirent(struct inode *dir, struct buffer_head *buffer,
-		       tux_dirent *entry, struct inode *new_inode);
+		       struct tux3_dirent *entry, struct inode *new_inode);
 loff_t tux_alloc_entry(struct inode *dir, const char *name, unsigned len,
 		       loff_t *size, struct buffer_head **hold);
 int tux_create_dirent(struct inode *dir, const struct qstr *qstr,
 		      struct inode *inode);
-tux_dirent *tux_find_entry(struct inode *dir, const char *name, unsigned len,
-			   struct buffer_head **result, loff_t size);
-tux_dirent *tux_find_dirent(struct inode *dir, const struct qstr *qstr,
-			    struct buffer_head **result);
+struct tux3_dirent *tux_find_entry(struct inode *dir, const char *name,
+				   unsigned len, struct buffer_head **result,
+				   loff_t size);
+struct tux3_dirent *tux_find_dirent(struct inode *dir, const struct qstr *qstr,
+				    struct buffer_head **result);
 int tux_delete_entry(struct inode *dir, struct buffer_head *buffer,
-		     tux_dirent *entry);
+		     struct tux3_dirent *entry);
 int tux_delete_dirent(struct inode *dir, struct buffer_head *buffer,
-		      tux_dirent *entry);
+		      struct tux3_dirent *entry);
 int tux_readdir(struct file *file, struct dir_context *ctx);
 int tux_dir_is_empty(struct inode *dir);
 
diff --git a/fs/tux3/utility.c b/fs/tux3/utility.c
index f6cb856..910f55d 100644
--- a/fs/tux3/utility.c
+++ b/fs/tux3/utility.c
@@ -40,8 +40,11 @@
 
 int syncio(int rw, struct block_device *dev, loff_t offset, unsigned vecs, struct bio_vec *vec)
 {
-	struct biosync sync = { .done = COMPLETION_INITIALIZER_ONSTACK(sync.done) };
-	if (!(sync.err = vecio(rw, dev, offset, vecs, vec, biosync_endio, &sync)))
+	struct biosync sync = {
+		.done = COMPLETION_INITIALIZER_ONSTACK(sync.done)
+	};
+	sync.err = vecio(rw, dev, offset, vecs, vec, biosync_endio, &sync);
+	if (!sync.err)
 		wait_for_completion(&sync.done);
 	return sync.err;
 }
diff --git a/fs/tux3/xattr.c b/fs/tux3/xattr.c
index 5c5cd3f..7872119 100644
--- a/fs/tux3/xattr.c
+++ b/fs/tux3/xattr.c
@@ -41,7 +41,7 @@
 
 /* see dir.c */
 #define HEAD_ALIGN		sizeof(inum_t)
-#define HEAD_SIZE		offsetof(tux_dirent, name)
+#define HEAD_SIZE		offsetof(struct tux3_dirent, name)
 /* FIXME: probably, we should limit maximum name length */
 #define MAX_ATOM_NAME_LEN	(256 - HEAD_SIZE)
 
@@ -70,7 +70,7 @@
 		sb->atomref_base + (1U << (ATOMREF_TABLE_BITS - sb->blockbits));
 }
 
-static inline atom_t entry_atom(tux_dirent *entry)
+static inline atom_t entry_atom(struct tux3_dirent *entry)
 {
 	return be64_to_cpu(entry->inum);
 }
@@ -156,7 +156,7 @@
 		err = -EIO;
 		goto error;
 	}
-	tux_dirent *entry = bufdata(buffer) + (where & sb->blockmask);
+	struct tux3_dirent *entry = bufdata(buffer) + (where & sb->blockmask);
 	if (entry_atom(entry) != atom) {
 		tux3_fs_error(sb, "atom %x reverse entry broken", atom);
 		err = -EIO;
@@ -211,7 +211,7 @@
 {
 	struct sb *sb = tux_sb(atable->i_sb);
 	struct buffer_head *buffer;
-	tux_dirent *entry;
+	struct tux3_dirent *entry;
 
 	entry = tux_find_entry(atable, name, len, &buffer, sb->atomdictsize);
 	if (IS_ERR(entry)) {
@@ -362,7 +362,7 @@
 			return -EIO;
 		}
 
-		tux_dirent *entry = bufdata(buffer) + (where & sb->blockmask);
+		struct tux3_dirent *entry = bufdata(buffer) + (where & sb->blockmask);
 		if (entry_atom(entry) == atom) {
 			/* FIXME: better set a flag that unatom broke
 			 * or something! */
@@ -392,9 +392,11 @@
 	for (unsigned j = 0; j < blocks; j++) {
 		unsigned block = sb->atomref_base + ATOMREF_SIZE * j;
 		struct buffer_head *lobuf, *hibuf;
-		if (!(lobuf = blockread(mapping(atable), block)))
+		lobuf = blockread(mapping(atable), block);
+		if (!lobuf)
 			goto eek;
-		if (!(hibuf = blockread(mapping(atable), block + 1))) {
+		hibuf = blockread(mapping(atable), block + 1);
+		if (!hibuf) {
 			blockput(lobuf);
 			goto eek;
 		}
@@ -546,7 +548,8 @@
 			hexdump(xattr->body, xattr->size);
 		else
 			__tux3_dbg("<empty>\n");
-		if ((xattr = xcache_next(xattr)) > xlimit)
+		xattr = xcache_next(xattr);
+		if (xattr > xlimit)
 			goto fail;
 	}
 	assert(xattr == xlimit);
@@ -568,7 +571,8 @@
 		while (xattr < xlimit) {
 			if (xattr->atom == atom)
 				return xattr;
-			if ((xattr = xcache_next(xattr)) > xlimit)
+			xattr = xcache_next(xattr);
+			if (xattr > xlimit)
 				return ERR_PTR(-EINVAL);
 		}
 		assert(xattr == xlimit);
@@ -800,7 +804,8 @@
 			text += len + 1;
 		}
 
-		if ((xattr = xcache_next(xattr)) > xlimit) {
+		xattr = xcache_next(xattr);
+		if (xattr > xlimit) {
 			tux3_fs_error(sb, "xcache bug");
 			err = -EIO;
 			goto error;