From 344e1f51305c922ee442344de596e945d4e436ce Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 2 Jan 2014 07:40:50 -0700 Subject: [PATCH] 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 --- 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 880056852d..5e5bac5e78 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 f05949943d..dad98d63f7 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 89c7675218..bc80425a32 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. * @@ -86,9 +86,6 @@ struct _virObjectEvent { virClassPtr virClassForObjectEvent(void); -int -virObjectEventGetEventID(void *anyobj); - int virObjectEventCallbackListAddID(virConnectPtr conn, virObjectEventCallbackListPtr cbList, -- GitLab