From 6a39c906d2d2144f0bf59ca488a5d7cc6ffc253e Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 17 Oct 2018 11:28:18 -0700 Subject: Remove unnecessary if before free checks Caught by make syntax-check --- libparted/labels/fdasd.c | 12 ++++-------- parted/parted.c | 13 ++++--------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c index 713ed6b..cee4d46 100644 --- a/libparted/labels/fdasd.c +++ b/libparted/labels/fdasd.c @@ -111,14 +111,10 @@ fdasd_cleanup (fdasd_anchor_t *anchor) if (anchor == NULL) return; - if (anchor->f4 != NULL) - free(anchor->f4); - if (anchor->f5 != NULL) - free(anchor->f5); - if (anchor->f7 != NULL) - free(anchor->f7); - if (anchor->vlabel != NULL) - free(anchor->vlabel); + free(anchor->f4); + free(anchor->f5); + free(anchor->f7); + free(anchor->vlabel); part_info = anchor->first; for (i = 1; i <= USABLE_PARTITIONS && part_info != NULL; i++) { diff --git a/parted/parted.c b/parted/parted.c index fe7c26d..25633bf 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -799,12 +799,10 @@ do_mkpart (PedDevice** dev, PedDisk** diskp) "aligned for best performance: %s"), align_err ? align_err : _("unknown (malloc failed)")) == PED_EXCEPTION_CANCEL) { - if (align_err) - free(align_err); + free(align_err); /* undo partition addition */ goto error_remove_part; } - if (align_err) free(align_err); } } else { @@ -848,8 +846,7 @@ error_remove_part: error_destroy_simple_constraints: ped_partition_destroy (part); error: - if (part_name) - free (part_name); + free (part_name); if (range_start != NULL) ped_geometry_destroy (range_start); if (range_end != NULL) @@ -1714,8 +1711,7 @@ do_align_check (PedDevice **dev, PedDisk** diskp) /* Don't print the error in script mode */ if (opt_script_mode) { - if (align_err) - free(align_err); + free(align_err); return aligned ? 1 : 0; } @@ -1726,8 +1722,7 @@ do_align_check (PedDevice **dev, PedDisk** diskp) part->num, align_err ? align_err : _("unknown (malloc failed)")); - if (align_err) - free(align_err); + free(align_err); /* Always return 1 in interactive mode, to be consistent with the other modes. */ -- cgit v1.2.1