mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
util: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Add another usage for VIR_AUTOFREE macro which was left in the commit ec3e878, thereby dropping a VIR_FREE call and and a cleanup section. Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
34a6962c41
commit
cbc1326b21
@ -208,7 +208,8 @@ static int
|
|||||||
virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
||||||
char **ifacename)
|
char **ifacename)
|
||||||
{
|
{
|
||||||
int ret = -1, exitstatus = -1;
|
int exitstatus = -1;
|
||||||
|
VIR_AUTOFREE(char *) iface_name = NULL;
|
||||||
VIR_AUTOFREE(char *) temp_ifacename = NULL;
|
VIR_AUTOFREE(char *) temp_ifacename = NULL;
|
||||||
VIR_AUTOPTR(virCommand) cmd = NULL;
|
VIR_AUTOPTR(virCommand) cmd = NULL;
|
||||||
|
|
||||||
@ -233,7 +234,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to run command '%s' to create new iscsi interface"),
|
_("Failed to run command '%s' to create new iscsi interface"),
|
||||||
ISCSIADM);
|
ISCSIADM);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
|
|
||||||
@ -252,26 +253,23 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to run command '%s' to update iscsi interface with IQN '%s'"),
|
_("Failed to run command '%s' to update iscsi interface with IQN '%s'"),
|
||||||
ISCSIADM, initiatoriqn);
|
ISCSIADM, initiatoriqn);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check again to make sure the interface was created. */
|
/* Check again to make sure the interface was created. */
|
||||||
if (virStorageBackendIQNFound(initiatoriqn, ifacename) != IQN_FOUND) {
|
if (virStorageBackendIQNFound(initiatoriqn, &iface_name) != IQN_FOUND) {
|
||||||
VIR_DEBUG("Failed to find interface '%s' with IQN '%s' "
|
VIR_DEBUG("Failed to find interface '%s' with IQN '%s' "
|
||||||
"after attempting to create it",
|
"after attempting to create it",
|
||||||
&temp_ifacename[0], initiatoriqn);
|
&temp_ifacename[0], initiatoriqn);
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
VIR_DEBUG("Interface '%s' with IQN '%s' was created successfully",
|
VIR_DEBUG("Interface '%s' with IQN '%s' was created successfully",
|
||||||
*ifacename, initiatoriqn);
|
iface_name, initiatoriqn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
VIR_STEAL_PTR(*ifacename, iface_name);
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
if (ret != 0)
|
|
||||||
VIR_FREE(*ifacename);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user