diff mbox series

[1/1] fs: ext4: avoid NULL check before free()

Message ID 20200428195002.14787-1-xypron.glpk@gmx.de
State Accepted
Commit 4fb0f55fd294aca02407ef1def74a22612fa041b
Headers show
Series [1/1] fs: ext4: avoid NULL check before free() | expand

Commit Message

Heinrich Schuchardt April 28, 2020, 7:50 p.m. UTC
free() checks if its argument is NULL. Don't duplicate this in the calling
code.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 fs/ext4/ext4_journal.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

--
2.26.2

Comments

Tom Rini May 1, 2020, 9:57 p.m. UTC | #1
On Tue, Apr 28, 2020 at 09:50:02PM +0200, Heinrich Schuchardt wrote:

> free() checks if its argument is NULL. Don't duplicate this in the calling
> code.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c
index f8524e5a99..0ceb73d9c9 100644
--- a/fs/ext4/ext4_journal.c
+++ b/fs/ext4/ext4_journal.c
@@ -107,22 +107,18 @@  void ext4fs_free_journal(void)
 	for (i = 0; i < MAX_JOURNAL_ENTRIES; i++) {
 		if (dirty_block_ptr[i]->blknr == -1)
 			break;
-		if (dirty_block_ptr[i]->buf)
-			free(dirty_block_ptr[i]->buf);
+		free(dirty_block_ptr[i]->buf);
 	}

 	for (i = 0; i < MAX_JOURNAL_ENTRIES; i++) {
 		if (journal_ptr[i]->blknr == -1)
 			break;
-		if (journal_ptr[i]->buf)
-			free(journal_ptr[i]->buf);
+		free(journal_ptr[i]->buf);
 	}

 	for (i = 0; i < MAX_JOURNAL_ENTRIES; i++) {
-		if (journal_ptr[i])
-			free(journal_ptr[i]);
-		if (dirty_block_ptr[i])
-			free(dirty_block_ptr[i]);
+		free(journal_ptr[i]);
+		free(dirty_block_ptr[i]);
 	}
 	gindex = 0;
 	gd_index = 0;
@@ -272,8 +268,7 @@  void ext4fs_free_revoke_blks(void)
 	struct revoke_blk_list *next_node = NULL;

 	while (tmp_node != NULL) {
-		if (tmp_node->content)
-			free(tmp_node->content);
+		free(tmp_node->content);
 		tmp_node = tmp_node->next;
 	}