[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/2] event: remove unneeded virObjectEventGetEventID



Any file with access to object_event_private.h also has access to
the internals of virObjectEvent, without needing an accessor
function.  Not to mention the accessor function was doing type
checks that would always succeed.

* src/conf/object_event_private.h (virObjectEventGetEventID): Drop.
* src/conf/object_event.c (virObjectEventGetEventID): Drop.
(virObjectEventDispatchMatchCallback): Simplify caller.
* src/conf/domain_event.c (virDomainEventDispatchDefaultFunc):
Likewise.

Signed-off-by: Eric Blake <eblake redhat com>
---
 src/conf/domain_event.c         |  5 ++---
 src/conf/object_event.c         | 14 +-------------
 src/conf/object_event_private.h |  5 +----
 3 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 8800568..5e5bac5 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -1191,12 +1191,11 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
                                   void *cbopaque)
 {
     virDomainPtr dom = virGetDomain(conn, event->meta.name, event->meta.uuid);
-    int eventID = virObjectEventGetEventID(event);
     if (!dom)
         return;
     dom->id = event->meta.id;

-    switch ((virDomainEventID) eventID) {
+    switch ((virDomainEventID) event->eventID) {
     case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
         {
             virDomainEventLifecyclePtr lifecycleEvent;
@@ -1360,7 +1359,7 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
         break;
     }

-    VIR_WARN("Unexpected event ID %d", eventID);
+    VIR_WARN("Unexpected event ID %d", event->eventID);

 cleanup:
     virDomainFree(dom);
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index eca6a10..4a389f5 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -73,18 +73,6 @@ virClassForObjectEvent(void)
     return virObjectEventClass;
 }

-int
-virObjectEventGetEventID(void *anyobj)
-{
-    virObjectEventPtr obj = anyobj;
-
-    if (!virObjectIsClass(obj, virClassForObjectEvent())) {
-        VIR_WARN("Object %p (%s) is not a virObjectEvent instance",
-                 obj, obj ? virClassName(obj->parent.klass) : "(unknown)");
-        return -1;
-    }
-    return obj->eventID;
-}

 static void
 virObjectEventDispose(void *obj)
@@ -599,7 +587,7 @@ virObjectEventDispatchMatchCallback(virObjectEventPtr event,
         return 0;
     if (!virObjectIsClass(event, cb->klass))
         return 0;
-    if (cb->eventID != virObjectEventGetEventID(event))
+    if (cb->eventID != event->eventID)
         return 0;

     if (cb->meta) {
diff --git a/src/conf/object_event_private.h b/src/conf/object_event_private.h
index 89c7675..bc80425 100644
--- a/src/conf/object_event_private.h
+++ b/src/conf/object_event_private.h
@@ -1,7 +1,7 @@
 /*
  * object_event_private.h: object event queue processing helpers
  *
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
  * Copyright (C) 2008 VirtualIron
  * Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
  *
@@ -87,9 +87,6 @@ virClassPtr
 virClassForObjectEvent(void);

 int
-virObjectEventGetEventID(void *anyobj);
-
-int
 virObjectEventCallbackListAddID(virConnectPtr conn,
                                 virObjectEventCallbackListPtr cbList,
                                 unsigned char *uuid,
-- 
1.8.4.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]