appliance: Modernize guestfs_int_build_appliance with compound literal

No functional change.

Signed-off-by: Susant Sahani <ssahani@redhat.com>
This commit is contained in:
Susant Sahani
2025-11-24 22:19:40 +05:30
committed by rwmjones
parent 0a8d1aefef
commit 257bfad817

View File

@@ -109,17 +109,20 @@ static int run_supermin_build (guestfs_h *g, const char *lockfile, const char *a
* provides a I<--lock> flag and atomic update of the F<appliance.d>
* subdirectory.
*/
int
guestfs_int_build_appliance (guestfs_h *g,
char **kernel_rtn,
char **initrd_rtn,
char **appliance_rtn)
{
struct appliance_files appliance = {
.kernel = NULL,
.initrd = NULL,
.image = NULL,
};
struct appliance_files appliance;
memset (&appliance, 0, sizeof appliance);
/* search_appliance fills the struct on success */
if (search_appliance (g, &appliance) != 1)
return -1;
@@ -129,6 +132,10 @@ guestfs_int_build_appliance (guestfs_h *g,
*kernel_rtn = appliance.kernel;
*initrd_rtn = appliance.initrd;
*appliance_rtn = appliance.image;
/* Zero the struct so nothing gets freed twice if caller messes up */
appliance.kernel = appliance.initrd = appliance.image = NULL;
return 0;
}