util: remove virObjectUnref() adapters

These wrapper functions were used to adapt the virObjectUnref() function
signature for different callbacks. But in commit 0d184072, the
virObjectUnref() function was changed to return a void instead of a
bool, so these adapters are no longer necessary.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Jonathon Jongsma 2022-07-13 15:26:51 -05:00
parent d531b9c724
commit 62ca300530
28 changed files with 43 additions and 81 deletions

View File

@ -165,7 +165,7 @@ remoteAdminConnectOpen(virAdmConnectPtr conn, unsigned int flags)
virObjectRef(conn->closeCallback);
virNetClientSetCloseCallback(priv->client, remoteAdminClientCloseFunc,
conn->closeCallback,
virObjectFreeCallback);
virObjectUnref);
if (call(conn, 0, ADMIN_PROC_CONNECT_OPEN,
(xdrproc_t)xdr_admin_connect_open_args, (char *)&args,
@ -195,7 +195,7 @@ remoteAdminConnectClose(virAdmConnectPtr conn)
}
virNetClientSetCloseCallback(priv->client, NULL, conn->closeCallback,
virObjectFreeCallback);
virObjectUnref);
virNetClientClose(priv->client);
rv = 0;

View File

@ -82,7 +82,7 @@ bhyveMonitorRegister(bhyveMonitor *mon)
VIR_EVENT_HANDLE_HANGUP,
bhyveMonitorIO,
mon,
virObjectFreeCallback);
virObjectUnref);
if (mon->watch < 0) {
VIR_DEBUG("failed to add event handle for mon %p", mon);
virObjectUnref(mon);

View File

@ -876,7 +876,7 @@ virObjectEventStateRegisterID(virConnectPtr conn,
if ((state->timer = virEventAddTimeout(-1,
virObjectEventTimer,
state,
virObjectFreeCallback)) < 0) {
virObjectUnref)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not initialize domain event timer"));
goto cleanup;

View File

@ -73,8 +73,8 @@ virDomainObjList *virDomainObjListNew(void)
if (!(doms = virObjectRWLockableNew(virDomainObjListClass)))
return NULL;
doms->objs = virHashNew(virObjectFreeHashData);
doms->objsName = virHashNew(virObjectFreeHashData);
doms->objs = virHashNew(virObjectUnref);
doms->objsName = virHashNew(virObjectUnref);
return doms;
}
@ -217,7 +217,7 @@ virDomainObjListFindByName(virDomainObjList *doms,
* tables. Once successfully added into a table, increase the
* reference count since upon removal in virHashRemoveEntry
* the virObjectUnref will be called since the hash tables were
* configured to call virObjectFreeHashData when the object is
* configured to call virObjectUnref when the object is
* removed from the hash table.
*
* Returns 0 on success with 3 references and locked
@ -453,7 +453,7 @@ virDomainObjListRename(virDomainObjList *doms,
/* Increment the refcnt for @new_name. We're about to remove
* the @old_name which will cause the refcnt to be decremented
* via the virObjectUnref call made during the virObjectFreeHashData
* via the virObjectUnref call made during the virObjectUnref
* as a result of removing something from the object list hash
* table as set up during virDomainObjListNew. */
virObjectRef(dom);

View File

@ -140,7 +140,7 @@ virInterfaceObjListNew(void)
if (!(interfaces = virObjectRWLockableNew(virInterfaceObjListClass)))
return NULL;
interfaces->objsName = virHashNew(virObjectFreeHashData);
interfaces->objsName = virHashNew(virObjectUnref);
return interfaces;
}

View File

@ -326,7 +326,7 @@ virNetworkObjListNew(void)
if (!(nets = virObjectRWLockableNew(virNetworkObjListClass)))
return NULL;
nets->objs = virHashNew(virObjectFreeHashData);
nets->objs = virHashNew(virObjectUnref);
return nets;
}

View File

@ -465,7 +465,7 @@ virNodeDeviceObjListNew(void)
if (!(devs = virObjectRWLockableNew(virNodeDeviceObjListClass)))
return NULL;
devs->objs = virHashNew(virObjectFreeHashData);
devs->objs = virHashNew(virObjectUnref);
return devs;
}

View File

@ -66,7 +66,7 @@ virNWFilterBindingObjListNew(void)
if (!(bindings = virObjectRWLockableNew(virNWFilterBindingObjListClass)))
return NULL;
bindings->objs = virHashNew(virObjectFreeHashData);
bindings->objs = virHashNew(virObjectUnref);
return bindings;
}
@ -131,7 +131,7 @@ virNWFilterBindingObjListFindByPortDev(virNWFilterBindingObjList *bindings,
* tables. Once successfully added into a table, increase the
* reference count since upon removal in virHashRemoveEntry
* the virObjectUnref will be called since the hash tables were
* configured to call virObjectFreeHashData when the object is
* configured to call virObjectUnref when the object is
* removed from the hash table.
*
* Returns 0 on success with 2 references and locked

View File

@ -118,7 +118,7 @@ virSecretObjListNew(void)
if (!(secrets = virObjectRWLockableNew(virSecretObjListClass)))
return NULL;
if (!(secrets->objs = virHashNew(virObjectFreeHashData))) {
if (!(secrets->objs = virHashNew(virObjectUnref))) {
virObjectUnref(secrets);
return NULL;
}

View File

@ -151,9 +151,9 @@ virStorageVolObjListNew(void)
if (!(vols = virObjectRWLockableNew(virStorageVolObjListClass)))
return NULL;
vols->objsKey = virHashNew(virObjectFreeHashData);
vols->objsName = virHashNew(virObjectFreeHashData);
vols->objsPath = virHashNew(virObjectFreeHashData);
vols->objsKey = virHashNew(virObjectUnref);
vols->objsName = virHashNew(virObjectUnref);
vols->objsPath = virHashNew(virObjectUnref);
return vols;
}
@ -378,8 +378,8 @@ virStoragePoolObjListNew(void)
if (!(pools = virObjectRWLockableNew(virStoragePoolObjListClass)))
return NULL;
pools->objs = virHashNew(virObjectFreeHashData);
pools->objsName = virHashNew(virObjectFreeHashData);
pools->objs = virHashNew(virObjectUnref);
pools->objsName = virHashNew(virObjectUnref);
return pools;
}

View File

@ -2978,8 +2978,6 @@ virClassForObjectRWLockable;
virClassIsDerivedFrom;
virClassName;
virClassNew;
virObjectFreeCallback;
virObjectFreeHashData;
virObjectIsClass;
virObjectListFree;
virObjectListFreeCount;

View File

@ -1764,7 +1764,7 @@ qemuDomainObjPrivateAlloc(void *opaque)
if (!(priv->devs = virChrdevAlloc()))
return NULL;
priv->blockjobs = virHashNew(virObjectFreeHashData);
priv->blockjobs = virHashNew(virObjectUnref);
/* agent commands block by default, user can choose different behavior */
priv->agentTimeout = VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK;

View File

@ -440,7 +440,7 @@ int daemonAddClientStream(virNetServerClient *client,
if (virStreamEventAddCallback(stream->st, 0,
daemonStreamEvent, client,
virObjectFreeCallback) < 0)
virObjectUnref) < 0)
return -1;
virObjectRef(client);

View File

@ -1096,7 +1096,7 @@ doRemoteOpen(virConnectPtr conn,
virObjectRef(priv->closeCallback);
virNetClientSetCloseCallback(priv->client,
remoteClientCloseFunc,
priv->closeCallback, virObjectFreeCallback);
priv->closeCallback, virObjectUnref);
if (!(priv->remoteProgram = virNetClientProgramNew(REMOTE_PROGRAM,
REMOTE_PROTOCOL_VERSION,
@ -1301,7 +1301,7 @@ doRemoteClose(virConnectPtr conn, struct private_data *priv)
virNetClientSetCloseCallback(priv->client,
NULL,
priv->closeCallback, virObjectFreeCallback);
priv->closeCallback, virObjectUnref);
virNetClientClose(priv->client);
g_clear_pointer(&priv->client, virObjectUnref);
@ -6142,7 +6142,7 @@ remoteDomainMigratePrepareTunnel3(virConnectPtr dconn,
st->driver = &remoteStreamDrv;
st->privateData = netst;
st->ff = virObjectFreeCallback;
st->ff = virObjectUnref;
args.cookie_in.cookie_in_val = (char *)cookiein;
args.cookie_in.cookie_in_len = cookieinlen;
@ -7082,7 +7082,7 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
st->driver = &remoteStreamDrv;
st->privateData = netst;
st->ff = virObjectFreeCallback;
st->ff = virObjectUnref;
if (call(dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL3_PARAMS,
(xdrproc_t) xdr_remote_domain_migrate_prepare_tunnel3_params_args,

View File

@ -1837,7 +1837,7 @@ elsif ($mode eq "client") {
print "\n";
print " st->driver = &remoteStreamDrv;\n";
print " st->privateData = netst;\n";
print " st->ff = virObjectFreeCallback;\n";
print " st->ff = virObjectUnref;\n";
}
if ($call->{ProcName} eq "SupportsFeature") {

View File

@ -275,7 +275,7 @@ virKeepAliveStart(virKeepAlive *ka,
timeout = ka->interval - delay;
ka->intervalStart = now - (ka->interval - timeout);
ka->timer = virEventAddTimeout(timeout * 1000, virKeepAliveTimer,
ka, virObjectFreeCallback);
ka, virObjectUnref);
if (ka->timer < 0)
goto cleanup;

View File

@ -658,7 +658,7 @@ int virNetClientRegisterAsyncIO(virNetClient *client)
VIR_EVENT_HANDLE_READABLE,
virNetClientIncomingEvent,
client,
virObjectFreeCallback) < 0) {
virObjectUnref) < 0) {
virObjectUnref(client);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to register async IO callback"));
@ -688,7 +688,7 @@ int virNetClientRegisterKeepAlive(virNetClient *client)
if (!(ka = virKeepAliveNew(-1, 0, client,
virNetClientKeepAliveSendCB,
virNetClientKeepAliveDeadCB,
virObjectFreeCallback)))
virObjectUnref)))
return -1;
/* keepalive object has a reference to client */

View File

@ -727,7 +727,7 @@ int virNetClientStreamEventAddCallback(virNetClientStream *st,
virEventAddTimeout(-1,
virNetClientStreamEventTimer,
st,
virObjectFreeCallback)) < 0) {
virObjectUnref)) < 0) {
virObjectUnref(st);
goto cleanup;
}

View File

@ -142,7 +142,7 @@ virNetDaemonNew(void)
if (!(dmn = virObjectLockableNew(virNetDaemonClass)))
return NULL;
dmn->servers = virHashNew(virObjectFreeHashData);
dmn->servers = virHashNew(virObjectUnref);
#ifndef WIN32
dmn->sigwrite = dmn->sigread = -1;

View File

@ -202,7 +202,7 @@ static int virNetServerClientRegisterEvent(virNetServerClient *client)
mode,
virNetServerClientDispatchEvent,
client,
virObjectFreeCallback) < 0) {
virObjectUnref) < 0) {
virObjectUnref(client);
return -1;
}
@ -1521,7 +1521,7 @@ virNetServerClientInitKeepAlive(virNetServerClient *client,
if (!(ka = virKeepAliveNew(interval, count, client,
virNetServerClientKeepAliveSendCB,
virNetServerClientKeepAliveDeadCB,
virObjectFreeCallback)))
virObjectUnref)))
return -1;
/* keepalive object has a reference to client */

View File

@ -152,7 +152,7 @@ virNetServerServiceNewSocket(virNetSocket **socks,
virObjectRef(svc);
svc->timer = virEventAddTimeout(-1, virNetServerServiceTimerFunc,
svc, virObjectFreeCallback);
svc, virObjectUnref);
if (svc->timer < 0) {
virObjectUnref(svc);
goto error;
@ -169,7 +169,7 @@ virNetServerServiceNewSocket(virNetSocket **socks,
0,
virNetServerServiceAccept,
svc,
virObjectFreeCallback) < 0) {
virObjectUnref) < 0) {
virObjectUnref(svc);
goto error;
}
@ -361,7 +361,7 @@ virNetServerService *virNetServerServiceNewPostExecRestart(virJSONValue *object)
0,
virNetServerServiceAccept,
svc,
virObjectFreeCallback) < 0) {
virObjectUnref) < 0) {
virObjectUnref(svc);
goto error;
}

View File

@ -239,7 +239,7 @@ virFileCacheNew(const char *dir,
if (!(cache = virObjectNew(virFileCacheClass)))
return NULL;
cache->table = virHashNew(virObjectFreeHashData);
cache->table = virHashNew(virObjectUnref);
cache->dir = g_strdup(dir);

View File

@ -598,36 +598,6 @@ virClassName(virClass *klass)
}
/**
* virObjectFreeCallback:
* @opaque: a pointer to a virObject instance
*
* Provides identical functionality to virObjectUnref,
* but with the signature matching the virFreeCallback
* typedef.
*/
void virObjectFreeCallback(void *opaque)
{
virObjectUnref(opaque);
}
/**
* virObjectFreeHashData:
* @opaque: a pointer to a virObject instance
* @name: ignored, name of the hash key being deleted
*
* Provides identical functionality to virObjectUnref,
* but with the signature matching the GDestroyNotify
* typedef used with hash tables.
*/
void
virObjectFreeHashData(void *opaque)
{
virObjectUnref(opaque);
}
/**
* virObjectListFree:
* @list: A pointer to a NULL-terminated list of object pointers to free

View File

@ -104,12 +104,6 @@ virObjectIsClass(void *obj,
virClass *klass)
ATTRIBUTE_NONNULL(2);
void
virObjectFreeCallback(void *opaque);
void
virObjectFreeHashData(void *opaque);
void *
virObjectLockableNew(virClass *klass)
ATTRIBUTE_NONNULL(1);

View File

@ -78,7 +78,7 @@ mymain(void)
int ret = 0;
g_autofree char *fakerootdir = NULL;
g_autoptr(GHashTable) capslatest = testQemuGetLatestCaps();
g_autoptr(GHashTable) capscache = virHashNew(virObjectFreeHashData);
g_autoptr(GHashTable) capscache = virHashNew(virObjectUnref);
g_autoptr(virConnect) conn = NULL;
struct testQemuConf testConf = { .capslatest = capslatest,
.capscache = capscache,

View File

@ -835,7 +835,7 @@ mymain(void)
g_autofree char *fakerootdir = NULL;
g_autoptr(GHashTable) capslatest = testQemuGetLatestCaps();
g_autoptr(GHashTable) qapiSchemaCache = virHashNew((GDestroyNotify) g_hash_table_unref);
g_autoptr(GHashTable) capscache = virHashNew(virObjectFreeHashData);
g_autoptr(GHashTable) capscache = virHashNew(virObjectUnref);
struct testQemuConf testConf = { .capslatest = capslatest,
.capscache = capscache,
.qapiSchemaCache = qapiSchemaCache };

View File

@ -122,7 +122,7 @@ mymain(void)
g_autofree char *fakerootdir = NULL;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
g_autoptr(GHashTable) capslatest = testQemuGetLatestCaps();
g_autoptr(GHashTable) capscache = virHashNew(virObjectFreeHashData);
g_autoptr(GHashTable) capscache = virHashNew(virObjectUnref);
g_autoptr(virConnect) conn = NULL;
struct testQemuConf testConf = { .capslatest = capslatest,
.capscache = capscache,

View File

@ -451,7 +451,7 @@ virshRunConsole(vshControl *ctl,
VIR_EVENT_HANDLE_READABLE,
virConsoleEventOnStdin,
con,
virObjectFreeCallback)) < 0) {
virObjectUnref)) < 0) {
virObjectUnref(con);
goto cleanup;
}
@ -461,7 +461,7 @@ virshRunConsole(vshControl *ctl,
0,
virConsoleEventOnStdout,
con,
virObjectFreeCallback)) < 0) {
virObjectUnref)) < 0) {
virObjectUnref(con);
goto cleanup;
}
@ -471,7 +471,7 @@ virshRunConsole(vshControl *ctl,
VIR_STREAM_EVENT_READABLE,
virConsoleEventOnStream,
con,
virObjectFreeCallback) < 0) {
virObjectUnref) < 0) {
virObjectUnref(con);
goto cleanup;
}