提交 344e1f51 编写于 作者: E Eric Blake

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: NEric Blake <eblake@redhat.com>
上级 6742fb0b
...@@ -1191,12 +1191,11 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn, ...@@ -1191,12 +1191,11 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
void *cbopaque) void *cbopaque)
{ {
virDomainPtr dom = virGetDomain(conn, event->meta.name, event->meta.uuid); virDomainPtr dom = virGetDomain(conn, event->meta.name, event->meta.uuid);
int eventID = virObjectEventGetEventID(event);
if (!dom) if (!dom)
return; return;
dom->id = event->meta.id; dom->id = event->meta.id;
switch ((virDomainEventID) eventID) { switch ((virDomainEventID) event->eventID) {
case VIR_DOMAIN_EVENT_ID_LIFECYCLE: case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
{ {
virDomainEventLifecyclePtr lifecycleEvent; virDomainEventLifecyclePtr lifecycleEvent;
...@@ -1360,7 +1359,7 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn, ...@@ -1360,7 +1359,7 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
break; break;
} }
VIR_WARN("Unexpected event ID %d", eventID); VIR_WARN("Unexpected event ID %d", event->eventID);
cleanup: cleanup:
virDomainFree(dom); virDomainFree(dom);
......
...@@ -73,18 +73,6 @@ virClassForObjectEvent(void) ...@@ -73,18 +73,6 @@ virClassForObjectEvent(void)
return virObjectEventClass; 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 static void
virObjectEventDispose(void *obj) virObjectEventDispose(void *obj)
...@@ -599,7 +587,7 @@ virObjectEventDispatchMatchCallback(virObjectEventPtr event, ...@@ -599,7 +587,7 @@ virObjectEventDispatchMatchCallback(virObjectEventPtr event,
return 0; return 0;
if (!virObjectIsClass(event, cb->klass)) if (!virObjectIsClass(event, cb->klass))
return 0; return 0;
if (cb->eventID != virObjectEventGetEventID(event)) if (cb->eventID != event->eventID)
return 0; return 0;
if (cb->meta) { if (cb->meta) {
......
/* /*
* object_event_private.h: object event queue processing helpers * 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) 2008 VirtualIron
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. * Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
* *
...@@ -86,9 +86,6 @@ struct _virObjectEvent { ...@@ -86,9 +86,6 @@ struct _virObjectEvent {
virClassPtr virClassPtr
virClassForObjectEvent(void); virClassForObjectEvent(void);
int
virObjectEventGetEventID(void *anyobj);
int int
virObjectEventCallbackListAddID(virConnectPtr conn, virObjectEventCallbackListAddID(virConnectPtr conn,
virObjectEventCallbackListPtr cbList, virObjectEventCallbackListPtr cbList,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册