1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

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>
This commit is contained in:
Eric Blake 2014-01-02 07:40:50 -07:00
parent 6742fb0b10
commit 344e1f5130
3 changed files with 4 additions and 20 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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.
*
@ -86,9 +86,6 @@ struct _virObjectEvent {
virClassPtr
virClassForObjectEvent(void);
int
virObjectEventGetEventID(void *anyobj);
int
virObjectEventCallbackListAddID(virConnectPtr conn,
virObjectEventCallbackListPtr cbList,