mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-03 17:47:15 +03:00
virNetworkPortDefSaveStatus: Fix potentially uninitialized 'path' by refactoring cleanup
Use 'g_autofree' to clean both 'path' and 'xml' which mandates initialization and get rid of the 'cleanup' label and 'ret variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
71ebda3af1
commit
78ead2529b
@ -444,29 +444,24 @@ virNetworkPortDefSaveStatus(virNetworkPortDef *def,
|
|||||||
const char *dir)
|
const char *dir)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *path;
|
g_autofree char *path = NULL;
|
||||||
char *xml = NULL;
|
g_autofree char *xml = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
virUUIDFormat(def->uuid, uuidstr);
|
virUUIDFormat(def->uuid, uuidstr);
|
||||||
|
|
||||||
if (virFileMakePath(dir) < 0)
|
if (virFileMakePath(dir) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(path = virNetworkPortDefConfigFile(dir, uuidstr)))
|
if (!(path = virNetworkPortDefConfigFile(dir, uuidstr)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(xml = virNetworkPortDefFormat(def)))
|
if (!(xml = virNetworkPortDefFormat(def)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virXMLSaveFile(path, uuidstr, "net-port-create", xml) < 0)
|
if (virXMLSaveFile(path, uuidstr, "net-port-create", xml) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(xml);
|
|
||||||
VIR_FREE(path);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user