[PATCH 11/11] ocfs2: One function call less in ocfs2_journal_shutdown() from input checks

From: SF Markus Elfring
Date: Sun Jul 05 2015 - 09:42:55 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 5 Jul 2015 14:54:33 +0200

The iput() function was called in one case by the ocfs2_journal_shutdown()
function during input parameter validation even if the passed
variable contained still a null pointer.

* Return directly if received values indicate that at the beginning.

* Delete the unnecessary jump label "done".

* Drop unnecessary initialisations for the variables "inode",
"journal" and "num_running_trans" then.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
fs/ocfs2/journal.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 7bb50f4..f13e6fdb 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -951,22 +951,20 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
*/
void ocfs2_journal_shutdown(struct ocfs2_super *osb)
{
- struct ocfs2_journal *journal = NULL;
+ struct ocfs2_journal *journal;
int status = 0;
- struct inode *inode = NULL;
- int num_running_trans = 0;
+ struct inode *inode;
+ int num_running_trans;

BUG_ON(!osb);

journal = osb->journal;
if (!journal)
- goto done;
-
- inode = journal->j_inode;
-
+ return;
if (journal->j_state != OCFS2_JOURNAL_LOADED)
- goto done;
+ return;

+ inode = journal->j_inode;
/* need to inc inode use count - jbd2_journal_destroy will iput. */
if (!igrab(inode))
BUG();
@@ -1025,7 +1023,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
journal->j_state = OCFS2_JOURNAL_FREE;

// up_write(&journal->j_trans_barrier);
-done:
iput(inode);
}

--
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/