[PATCH 08/10] udf: simplify __udf_read_inode

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: LKML <linux-kernel@...>
Cc: Jan Kara <jack@...>, Marcin Slusarz <marcin.slusarz@...>
Date: Wednesday, January 30, 2008 - 5:03 pm

- move all brelse(ibh) after main if, because it's called
  on every path except one where ibh is null
- move variables to the most inner blocks

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jan Kara <jack@suse.cz>
---
 fs/udf/inode.c |   52 +++++++++++++++++++++++-----------------------------
 1 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 68db2ea..c2d0477 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1116,42 +1116,36 @@ static void __udf_read_inode(struct inode *inode)
 	fe = (struct fileEntry *)bh->b_data;
 
 	if (fe->icbTag.strategyType == cpu_to_le16(4096)) {
-		struct buffer_head *ibh = NULL, *nbh = NULL;
-		struct indirectEntry *ie;
+		struct buffer_head *ibh;
 
 		ibh = udf_read_ptagged(inode->i_sb, iinfo->i_location, 1,
 					&ident);
-		if (ident == TAG_IDENT_IE) {
-			if (ibh) {
-				kernel_lb_addr loc;
-				ie = (struct indirectEntry *)ibh->b_data;
-
-				loc = lelb_to_cpu(ie->indirectICB.extLocation);
-
-				if (ie->indirectICB.extLength &&
-				    (nbh = udf_read_ptagged(inode->i_sb, loc, 0,
-							    &ident))) {
-					if (ident == TAG_IDENT_FE ||
-					    ident == TAG_IDENT_EFE) {
-						memcpy(&iinfo->i_location,
-						       &loc,
-						       sizeof(kernel_lb_addr));
-						brelse(bh);
-						brelse(ibh);
-						brelse(nbh);
-						__udf_read_inode(inode);
-						return;
-					} else {
-						brelse(nbh);
-						brelse(ibh);
-					}
-				} else {
+		if (ident == TAG_IDENT_IE && ibh) {
+			struct buffer_head *nbh = NULL;
+			kernel_lb_addr loc;
+			struct indirectEntry *ie;
+
+			ie = (struct indirectEntry *)ibh->b_data;
+			loc = lelb_to_cpu(ie->indirectICB.extLocation);
+
+			if (ie->indirectICB.extLength &&
+				(nbh = udf_read_ptagged(inode->i_sb, loc, 0,
+							&ident))) {
+				if (ident == TAG_IDENT_FE ||
+					ident == TAG_IDENT_EFE) {
+					memcpy(&iinfo->i_location,
+						&loc,
+						sizeof(kernel_lb_addr));
+					brelse(bh);
 					brelse(ibh);
+					brelse(nbh);
+					__udf_read_inode(inode);
+					return;
 				}
+				brelse(nbh);
 			}
-		} else {
-			brelse(ibh);
 		}
+		brelse(ibh);
 	} else if (fe->icbTag.strategyType != cpu_to_le16(4)) {
 		printk(KERN_ERR "udf: unsupported strategy type: %d\n",
 		       le16_to_cpu(fe->icbTag.strategyType));
-- 
1.5.3.7

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/10] udf: cleanups, , (Wed Jan 30, 5:03 pm)
Re: [PATCH 10/10] udf: constify udf_bitmap_lookup array, Marcin Slusarz, (Sat Feb 2, 5:37 pm)
[PATCH 08/10] udf: simplify __udf_read_inode, , (Wed Jan 30, 5:03 pm)
Re: [PATCH 08/10] udf: simplify __udf_read_inode, Jan Kara, (Thu Jan 31, 12:46 pm)
[PATCH 04/10] udf: constify crc, , (Wed Jan 30, 5:03 pm)
Re: [PATCH 04/10] udf: constify crc, Jan Kara, (Thu Jan 31, 8:58 am)
Re: [PATCH 03/10] udf: udf_CS0toNLS cleanup, Jan Kara, (Thu Jan 31, 8:23 am)
[PATCH 02/10] udf: fix udf_build_ustr, , (Wed Jan 30, 5:03 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Jan Kara, (Thu Jan 31, 6:45 am)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Marcin Slusarz, (Thu Jan 31, 3:57 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Jan Kara, (Mon Feb 4, 3:31 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Marcin Slusarz, (Mon Feb 4, 5:27 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Jan Kara, (Tue Feb 5, 11:29 am)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Marcin Slusarz, (Tue Feb 5, 3:17 pm)
Re: [PATCH 01/10] udf: udf_CS0toUTF8 cleanup, Jan Kara, (Thu Jan 31, 5:57 am)