mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
interface: Remove some unnecessary goto's for Interface tests
Rather than using goto cleanup on object find failure and having cleanup need to check if the obj was present before unlocking, just return immediately. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
3a18ee91b7
commit
4845df2784
@ -3709,12 +3709,10 @@ testInterfaceLookupByName(virConnectPtr conn,
|
||||
virInterfacePtr ret = NULL;
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, name)))
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
|
||||
ret = virGetInterface(conn, obj->def->name, obj->def->mac);
|
||||
|
||||
cleanup:
|
||||
if (obj)
|
||||
virInterfaceObjUnlock(obj);
|
||||
return ret;
|
||||
}
|
||||
@ -3760,12 +3758,10 @@ testInterfaceIsActive(virInterfacePtr iface)
|
||||
int ret = -1;
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = virInterfaceObjIsActive(obj);
|
||||
|
||||
cleanup:
|
||||
if (obj)
|
||||
virInterfaceObjUnlock(obj);
|
||||
return ret;
|
||||
}
|
||||
@ -3875,12 +3871,10 @@ testInterfaceGetXMLDesc(virInterfacePtr iface,
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
|
||||
ret = virInterfaceDefFormat(obj->def);
|
||||
|
||||
cleanup:
|
||||
if (obj)
|
||||
virInterfaceObjUnlock(obj);
|
||||
return ret;
|
||||
}
|
||||
@ -3922,16 +3916,13 @@ testInterfaceUndefine(virInterfacePtr iface)
|
||||
{
|
||||
testDriverPtr privconn = iface->conn->privateData;
|
||||
virInterfaceObjPtr obj;
|
||||
int ret = -1;
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
virInterfaceObjRemove(&privconn->ifaces, obj);
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -3946,7 +3937,7 @@ testInterfaceCreate(virInterfacePtr iface,
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (obj->active != 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
||||
@ -3957,7 +3948,6 @@ testInterfaceCreate(virInterfacePtr iface,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (obj)
|
||||
virInterfaceObjUnlock(obj);
|
||||
return ret;
|
||||
}
|
||||
@ -3974,7 +3964,7 @@ testInterfaceDestroy(virInterfacePtr iface,
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (obj->active == 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
||||
@ -3985,7 +3975,6 @@ testInterfaceDestroy(virInterfacePtr iface,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (obj)
|
||||
virInterfaceObjUnlock(obj);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user