conf: Rewrite virNetDevVPortProfileCopy

This makes it nicer to use as since it cannot fail shortens the usage in all
callers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Martin Kletzander 2022-08-11 14:59:09 +02:00
parent 9c9fc39ded
commit f519f77d81
3 changed files with 16 additions and 16 deletions

View File

@ -29348,8 +29348,7 @@ virDomainNetDefToNetworkPort(virDomainDef *dom,
memcpy(&port->mac, &iface->mac, VIR_MAC_BUFLEN);
if (virNetDevVPortProfileCopy(&port->virtPortProfile, iface->virtPortProfile) < 0)
return NULL;
port->virtPortProfile = virNetDevVPortProfileCopy(iface->virtPortProfile);
if (virNetDevBandwidthCopy(&port->bandwidth, iface->bandwidth) < 0)
return NULL;
@ -29448,8 +29447,7 @@ virDomainNetDefActualFromNetworkPort(virDomainNetDef *iface,
goto error;
}
if (virNetDevVPortProfileCopy(&actual->virtPortProfile, port->virtPortProfile) < 0)
goto error;
actual->virtPortProfile = virNetDevVPortProfileCopy(port->virtPortProfile);
if (virNetDevBandwidthCopy(&actual->bandwidth, port->bandwidth) < 0)
goto error;
@ -29589,8 +29587,7 @@ virDomainNetDefActualToNetworkPort(virDomainDef *dom,
return NULL;
}
if (virNetDevVPortProfileCopy(&port->virtPortProfile, actual->virtPortProfile) < 0)
return NULL;
port->virtPortProfile = virNetDevVPortProfileCopy(actual->virtPortProfile);
if (virNetDevBandwidthCopy(&port->bandwidth, actual->bandwidth) < 0)
return NULL;

View File

@ -122,16 +122,18 @@ virNetDevVPortProfileEqual(const virNetDevVPortProfile *a, const virNetDevVPortP
}
int virNetDevVPortProfileCopy(virNetDevVPortProfile **dst, const virNetDevVPortProfile *src)
virNetDevVPortProfile *
virNetDevVPortProfileCopy(const virNetDevVPortProfile *src)
{
if (!src) {
*dst = NULL;
return 0;
}
virNetDevVPortProfile *ret = NULL;
*dst = g_new0(virNetDevVPortProfile, 1);
memcpy(*dst, src, sizeof(*src));
return 0;
if (!src)
return NULL;
ret = g_new0(virNetDevVPortProfile, 1);
memcpy(ret, src, sizeof(*ret));
return ret;
}

View File

@ -77,8 +77,9 @@ struct _virNetDevVPortProfile {
bool virNetDevVPortProfileEqual(const virNetDevVPortProfile *a,
const virNetDevVPortProfile *b);
int virNetDevVPortProfileCopy(virNetDevVPortProfile **dst,
const virNetDevVPortProfile *src);
virNetDevVPortProfile *
virNetDevVPortProfileCopy(const virNetDevVPortProfile *src);
int virNetDevVPortProfileCheckComplete(virNetDevVPortProfile *virtport,
bool generateMissing);