Skip to contentSkip to conversation

Remove unnecessary goto statements

PATCH New Goldwyn Rodrigues 3 participants 5 messages Jul 22, 2010 – Jul 23, 2010 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove unnecessary goto statements

Remove unnecessary goto statements.

---

fs/ocfs2/suballoc.c +0 -0
index c30b644..c91527f 100644
@@ -824,10 +824,8 @@ int ocfs2_reserve_cluster_bitmap_bits(struct

ocfs2_super *osb,
ALLOC_NEW_GROUP);
if (status < 0 && status != -ENOSPC) {
mlog_errno(status);
- goto bail;
}

-bail:
return status;
}

@@ -1050,7 +1048,6 @@ static inline int
ocfs2_block_group_set_bits(handle_t *handle,
group_bh);
if (status < 0) {
mlog_errno(status);
- goto bail;
}

bail:

#1 lore raw

PATCH 1/1 Remove unnecessary goto statements

Quoted 9 lines · Goldwyn Rodrigues

Remove unnecessary goto statements.

---

fs/ocfs2/suballoc.c +0 -0
index c30b644..c91527f 100644

fs/ocfs2/suballoc.c int ocfs2_reserve_cluster_bitmap_bits(struct · line 828

Quoted 6 lines
fs/ocfs2/suballoc.c +0 -1
@@ -824,10 +824,8 @@ int ocfs2_reserve_cluster_bitmap_bits(struct
 ocfs2_super *osb,
 					     ALLOC_NEW_GROUP);
 	if (status < 0 && status != -ENOSPC) {
 		mlog_errno(status);
-		goto bail;
 	}

The duplicated check for "status != -ENOSPC" can be removed too :) mlog_errno() is doing that check.

fs/ocfs2/suballoc.c static inline int · line 1052

Quoted 12 lines
fs/ocfs2/suballoc.c +0 -2
-bail:
 	return status;
 }
 
@@ -1050,7 +1048,6 @@ static inline int
 ocfs2_block_group_set_bits(handle_t *handle,
 				     group_bh);
 	if (status < 0) {
 		mlog_errno(status);
-		goto bail;
 	}

Why this?
the following lines are modifying the buffer head.

1361 le16_add_cpu(&bg->bg_free_bits_count, -num_bits);
1362 while(num_bits--)
1363 ocfs2_set_bit(bit_off++, bitmap);
1364
1365 ocfs2_journal_dirty(handle, group_bh);
1366
1367 bail:

For the next read of this group descriptor, we can't be sure it will be dirty read. So that it may get wrong contents and then the following write will write the wrong contents to disk.

regards,
wengang.

Quoted 2 lines
fs/ocfs2/suballoc.c +0 -0
 bail:
#2 lore raw

PATCH 1/1 Remove unnecessary goto statements

Quoted 23 lines · Wengang Wang

Review static inline int · line 1052

Quoted 11 lines

-bail:
? ? ? return status;
?}

(quoted diff) +0 -1
@@ -1050,7 +1048,6 @@ static inline int
 ocfs2_block_group_set_bits(handle_t *handle,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?group_bh);
 ? ? ? if (status < 0) {
 ? ? ? ? ? ? ? mlog_errno(status);
- ? ? ? ? ? ? goto bail;
 ? ? ? }

Why this?
the following lines are modifying the buffer head.

1361 ? ? ? ? le16_add_cpu(&bg->bg_free_bits_count, -num_bits); 1362 ? ? ? ? while(num_bits--)
1363 ? ? ? ? ? ? ? ? ocfs2_set_bit(bit_off++, bitmap); 1364
1365 ? ? ? ? ocfs2_journal_dirty(handle, group_bh); 1366
1367 bail:

Quoted 3 lines

For the next read of this group descriptor, we can't be sure it will be dirty read. So that it may get wrong contents and then the following write will write the wrong contents to disk.

Not sure which codebase you are referring to. According to the patch and the code in the Joel's git repo from kernel.org, the statement immediately following this was a bail tag.

Signature · 1 line
Goldwyn
#3 lore raw

PATCH 1/1 Remove unnecessary goto statements

Quoted 24 lines · Goldwyn Rodrigues
Quoted 23 lines · Wengang Wang

Review static inline int · line 1052

Quoted 11 lines

-bail:
? ? ? return status;
?}

(quoted diff) +0 -1
@@ -1050,7 +1048,6 @@ static inline int
 ocfs2_block_group_set_bits(handle_t *handle,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?group_bh);
 ? ? ? if (status < 0) {
 ? ? ? ? ? ? ? mlog_errno(status);
- ? ? ? ? ? ? goto bail;
 ? ? ? }

Why this?
the following lines are modifying the buffer head.

1361 ? ? ? ? le16_add_cpu(&bg->bg_free_bits_count, -num_bits); 1362 ? ? ? ? while(num_bits--)
1363 ? ? ? ? ? ? ? ? ocfs2_set_bit(bit_off++, bitmap); 1364
1365 ? ? ? ? ocfs2_journal_dirty(handle, group_bh); 1366
1367 bail:

Quoted 8 lines
Quoted 3 lines

For the next read of this group descriptor, we can't be sure it will be dirty read. So that it may get wrong contents and then the following write will write the wrong contents to disk.

Not sure which codebase you are referring to. According to the patch and the code in the Joel's git repo from kernel.org, the statement immediately following this was a bail tag.

Oh, sorry. I made a mistake for this.

regards,
wengang.

#4 lore raw

PATCH 1/1 Remove unnecessary goto statements

In reply to Goldwyn Rodrigues

NAK. Sorry. I don't think the patch is worth it. It's not like the compiler cannot detect this already.

Quoted 35 lines · Goldwyn Rodrigues

Remove unnecessary goto statements.

---

fs/ocfs2/suballoc.c +0 -3
index c30b644..c91527f 100644
@@ -824,10 +824,8 @@ int ocfs2_reserve_cluster_bitmap_bits(struct
 ocfs2_super *osb,
  					     ALLOC_NEW_GROUP);
  	if (status<  0&&  status != -ENOSPC) {
  		mlog_errno(status);
-		goto bail;
  	}
 
-bail:
  	return status;
  }
@@ -1050,7 +1048,6 @@ static inline int
 ocfs2_block_group_set_bits(handle_t *handle,
  				     group_bh);
  	if (status<  0) {
  		mlog_errno(status);
-		goto bail;
  	}
 

bail:

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel