zipl: add free_common_ipl_data()

Add a small helper function to free the common ipl data to avoid
having the same code duplicated multiple times. Also remove the if()
check before the free as it is allowed to pass NULL pointers to free().

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Sven Schnelle
2021-11-08 08:48:17 +01:00
committed by Jan Höppner
parent e384f06014
commit 5894e3f700
+13 -22
View File
@@ -367,29 +367,26 @@ free_envblk_data(struct job_envblk_data *data)
free(data->buf);
}
static void
free_common_ipl_data(struct job_common_ipl_data *common)
{
free(common->image);
free(common->parmline);
free(common->ramdisk);
}
static void
free_ipl_data(struct job_ipl_data* data)
{
if (data->common.image != NULL)
free(data->common.image);
if (data->common.parmline != NULL)
free(data->common.parmline);
if (data->common.ramdisk != NULL)
free(data->common.ramdisk);
free_common_ipl_data(&data->common);
}
static void
free_ipl_tape_data(struct job_ipl_tape_data* data)
{
if (data->device != NULL)
free(data->device);
if (data->common.image != NULL)
free(data->common.image);
if (data->common.parmline != NULL)
free(data->common.parmline);
if (data->common.ramdisk != NULL)
free(data->common.ramdisk);
free(data->device);
free_common_ipl_data(&data->common);
}
@@ -404,14 +401,8 @@ free_segment_data(struct job_segment_data* data)
static void
free_dump_data(struct job_dump_data* data)
{
if (data->device != NULL)
free(data->device);
if (data->common.image != NULL)
free(data->common.image);
if (data->common.parmline != NULL)
free(data->common.parmline);
if (data->common.ramdisk != NULL)
free(data->common.ramdisk);
free(data->device);
free_common_ipl_data(&data->common);
}