[libvirt] [PATCH v3 8/9] interface: Introduce virInterfaceObjNew
Bjoern Walk
bwalk at linux.vnet.ibm.com
Tue May 30 12:00:51 UTC 2017
John Ferlan <jferlan at redhat.com> [2017-05-30, 06:43AM -0400]:
>Create/use a helper to perform the object allocation
>
>Signed-off-by: John Ferlan <jferlan at redhat.com>
>---
> src/conf/virinterfaceobj.c | 31 +++++++++++++++++++++++--------
> 1 file changed, 23 insertions(+), 8 deletions(-)
>
>diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
>index 8bd8094..1e3f25c 100644
>--- a/src/conf/virinterfaceobj.c
>+++ b/src/conf/virinterfaceobj.c
>@@ -46,6 +46,27 @@ struct _virInterfaceObjList {
>
> /* virInterfaceObj manipulation */
>
>+static virInterfaceObjPtr
>+virInterfaceObjNew(void)
>+{
>+ virInterfaceObjPtr obj;
>+
>+ if (VIR_ALLOC(obj) < 0)
>+ return NULL;
>+
>+ if (virMutexInit(&obj->lock) < 0) {
>+ virReportError(VIR_ERR_INTERNAL_ERROR,
>+ "%s", _("cannot initialize mutex"));
>+ VIR_FREE(obj);
>+ return NULL;
>+ }
>+
>+ virInterfaceObjLock(obj);
>+
>+ return obj;
>+}
>+
>+
> void
> virInterfaceObjLock(virInterfaceObjPtr obj)
> {
>@@ -230,18 +251,12 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr interfaces,
> return obj;
> }
>
>- if (VIR_ALLOC(obj) < 0)
>- return NULL;
>- if (virMutexInit(&obj->lock) < 0) {
>- virReportError(VIR_ERR_INTERNAL_ERROR,
>- "%s", _("cannot initialize mutex"));
>- VIR_FREE(obj);
>+ if (!(obj = virInterfaceObjNew()))
> return NULL;
>- }
>- virInterfaceObjLock(obj);
>
> if (VIR_APPEND_ELEMENT_COPY(interfaces->objs,
> interfaces->count, obj) < 0) {
>+ virInterfaceObjUnlock(obj);
> virInterfaceObjFree(obj);
> return NULL;
> }
>--
>2.9.4
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
>
Looks good to me.
--
IBM Systems
Linux on z Systems & Virtualization Development
------------------------------------------------------------------------
IBM Deutschland
Schönaicher Str. 220
71032 Böblingen
Phone: +49 7031 16 1819
E-Mail: bwalk at de.ibm.com
------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 896 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170530/4917737a/attachment-0001.sig>
More information about the libvir-list
mailing list