linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] ext4: simplify some code in read_mmp_block()
@ 2015-08-10 21:34 Dan Carpenter
  2015-08-10 23:07 ` Andreas Dilger
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2015-08-10 21:34 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Andreas Dilger, linux-ext4, kernel-janitors

My static checker complains because it is not necessary to test
"if (*bh)" when we just tested "if (!*bh)" on the lines before.
We can remove the condition and pull everything in one indent level.

Then we have another "if (unlikely(!*bh))" check and the only way that
can be true is if the "if (!buffer_uptodate(*bh))" condition was true so
we can combine them together.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index 8313ca3..736f12e 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -80,18 +80,15 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
 		*bh = sb_getblk(sb, mmp_block);
 	if (!*bh)
 		return -ENOMEM;
-	if (*bh) {
-		get_bh(*bh);
-		lock_buffer(*bh);
-		(*bh)->b_end_io = end_buffer_read_sync;
-		submit_bh(READ_SYNC | REQ_META | REQ_PRIO, *bh);
-		wait_on_buffer(*bh);
-		if (!buffer_uptodate(*bh)) {
-			brelse(*bh);
-			*bh = NULL;
-		}
-	}
-	if (unlikely(!*bh)) {
+
+	get_bh(*bh);
+	lock_buffer(*bh);
+	(*bh)->b_end_io = end_buffer_read_sync;
+	submit_bh(READ_SYNC | REQ_META | REQ_PRIO, *bh);
+	wait_on_buffer(*bh);
+	if (!buffer_uptodate(*bh)) {
+		brelse(*bh);
+		*bh = NULL;
 		ext4_warning(sb, "Error while reading MMP block %llu",
 			     mmp_block);
 		return -EIO;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-17 16:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-10 21:34 [patch] ext4: simplify some code in read_mmp_block() Dan Carpenter
2015-08-10 23:07 ` Andreas Dilger
2015-08-14  9:47   ` [patch 1/2 v2] " Dan Carpenter
2015-08-14 17:03     ` Andreas Dilger
2015-08-15 15:37       ` Theodore Ts'o
2015-08-17 16:47         ` Andreas Dilger
2015-08-14  9:47   ` [patch 2/2] ext4: silence a format string false positive Dan Carpenter
2015-08-15 15:40     ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).