[PATCH 05/10] udf: simple cleanup of truncate.c

!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

- remove one indentation level by little code reorganization
- convert "if (smth) BUG();" to "BUG_ON(smth);"

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

diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index fe61be1..f64f827 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -224,34 +224,29 @@ void udf_truncate_extents(struct inode *inode)
 				if (indirect_ext_len) {
 					/* We managed to free all extents in the
 					 * indirect extent - free it too */
-					if (!epos.bh)
-						BUG();
+					BUG_ON(!epos.bh);
 					udf_free_blocks(sb, inode, epos.block,
 							0, indirect_ext_len);
+				} else if (!epos.bh) {
+					iinfo->i_lenAlloc = lenalloc;
+					mark_inode_dirty(inode);
 				} else {
-					if (!epos.bh) {
-						iinfo->i_lenAlloc =
-								lenalloc;
-						mark_inode_dirty(inode);
-					} else {
-						struct allocExtDesc *aed =
-							(struct allocExtDesc *)
-							(epos.bh->b_data);
-						int len =
-						    sizeof(struct allocExtDesc);
+					struct allocExtDesc *aed =
+						(struct allocExtDesc *)
+						(epos.bh->b_data);
+					int len = sizeof(struct allocExtDesc);
 
-						aed->lengthAllocDescs =
-						    cpu_to_le32(lenalloc);
-						if (!UDF_QUERY_FLAG(sb,
-							UDF_FLAG_STRICT) ||
-						    sbi->s_udfrev >= 0x0201)
-							len += lenalloc;
+					aed->lengthAllocDescs =
+						cpu_to_le32(lenalloc);
+					if (!UDF_QUERY_FLAG(sb,
+						UDF_FLAG_STRICT) ||
+						sbi->s_udfrev >= 0x0201)
+						len += lenalloc;
 
-						udf_update_tag(epos.bh->b_data,
-								len);
-						mark_buffer_dirty_inode(
-								epos.bh, inode);
-					}
+					udf_update_tag(epos.bh->b_data,
+							len);
+					mark_buffer_dirty_inode(
+							epos.bh, inode);
 				}
 				brelse(epos.bh);
 				epos.offset = sizeof(struct allocExtDesc);
@@ -272,28 +267,25 @@ void udf_truncate_extents(struct inode *inode)
 		}
 
 		if (indirect_ext_len) {
-			if (!epos.bh)
-				BUG();
+			BUG_ON(!epos.bh);
 			udf_free_blocks(sb, inode, epos.block, 0,
 					indirect_ext_len);
+		} else if (!epos.bh) {
+			iinfo->i_lenAlloc = lenalloc;
+			mark_inode_dirty(inode);
 		} else {
-			if (!epos.bh) {
-				iinfo->i_lenAlloc = lenalloc;
-				mark_inode_dirty(inode);
-			} else {
-				struct allocExtDesc *aed =
-				    (struct allocExtDesc *)(epos.bh->b_data);
-				aed->lengthAllocDescs = cpu_to_le32(lenalloc);
-				if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
-				    sbi->s_udfrev >= 0x0201)
-					udf_update_tag(epos.bh->b_data,
-						lenalloc +
-						sizeof(struct allocExtDesc));
-				else
-					udf_update_tag(epos.bh->b_data,
-						sizeof(struct allocExtDesc));
-				mark_buffer_dirty_inode(epos.bh, inode);
-			}
+			struct allocExtDesc *aed =
+				(struct allocExtDesc *)(epos.bh->b_data);
+			aed->lengthAllocDescs = cpu_to_le32(lenalloc);
+			if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
+				sbi->s_udfrev >= 0x0201)
+				udf_update_tag(epos.bh->b_data,
+					lenalloc +
+					sizeof(struct allocExtDesc));
+			else
+				udf_update_tag(epos.bh->b_data,
+					sizeof(struct allocExtDesc));
+			mark_buffer_dirty_inode(epos.bh, inode);
 		}
 	} else if (inode->i_size) {
 		if (byte_offset) {
-- 
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)
Re: [PATCH 08/10] udf: simplify __udf_read_inode, Jan Kara, (Thu Jan 31, 12:46 pm)
[PATCH 05/10] udf: simple cleanup of truncate.c, , (Wed Jan 30, 5:03 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)