diff mbox series

[1/1] cmd/gpt: avoid NULL check before free()

Message ID 20200428194013.13489-1-xypron.glpk@gmx.de
State Accepted
Commit b142d0ac1946701f4d592869c2d81e42afe2e294
Headers show
Series [1/1] cmd/gpt: avoid NULL check before free() | expand

Commit Message

Heinrich Schuchardt April 28, 2020, 7:40 p.m. UTC
free() checks if its argument is NULL. Do not duplicate this in the calling
code.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 cmd/gpt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--
2.26.2

Comments

Tom Rini April 29, 2020, 12:48 p.m. UTC | #1
On Tue, Apr 28, 2020 at 09:40:13PM +0200, Heinrich Schuchardt wrote:

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

Reviewed-by: Tom Rini <trini at konsulko.com>
Tom Rini May 1, 2020, 9:57 p.m. UTC | #2
On Tue, Apr 28, 2020 at 09:40:13PM +0200, Heinrich Schuchardt wrote:

> free() checks if its argument is NULL. Do not duplicate this in the calling
> code.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Reviewed-by: Tom Rini <trini at konsulko.com>

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

Patch

diff --git a/cmd/gpt.c b/cmd/gpt.c
index efaf1bcecb..fb58e4fdc7 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -772,11 +772,9 @@  static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
  out:
 	del_gpt_info();
 #ifdef CONFIG_RANDOM_UUID
-	if (str_disk_guid)
-		free(str_disk_guid);
+	free(str_disk_guid);
 #endif
-	if (new_partitions)
-		free(new_partitions);
+	free(new_partitions);
 	free(partitions_list);
 	return ret;
 }