From f3179d5abeeb9a2f98c39dce0e16c230a3dc6d33 Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Thu, 28 Nov 2024 18:21:20 +0300 Subject: [PATCH] rpc: Change return type of virNetClientAddStream to void This function return value is invariant since VIR_EXPAND_N check removal in 7d2fd6e, so change its type and remove all dependent checks. Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Pavel Nekrasov Signed-off-by: Alexander Kuznetsov Reviewed-by: Jiri Denemark --- src/remote/remote_driver.c | 10 ++-------- src/rpc/gendispatch.pl | 5 +---- src/rpc/virnetclient.c | 5 ++--- src/rpc/virnetclient.h | 4 ++-- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 4a16b8ef1d..307f9ca945 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5663,10 +5663,7 @@ remoteDomainMigratePrepareTunnel3(virConnectPtr dconn, false))) return -1; - if (virNetClientAddStream(priv->client, netst) < 0) { - virObjectUnref(netst); - return -1; - } + virNetClientAddStream(priv->client, netst); st->driver = &remoteStreamDrv; st->privateData = netst; @@ -6432,10 +6429,7 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr dconn, false))) goto cleanup; - if (virNetClientAddStream(priv->client, netst) < 0) { - virObjectUnref(netst); - goto cleanup; - } + virNetClientAddStream(priv->client, netst); st->driver = &remoteStreamDrv; st->privateData = netst; diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index c5842dc796..724a6aed6e 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1822,10 +1822,7 @@ elsif ($mode eq "client") { print " if (!(netst = virNetClientStreamNew(priv->remoteProgram, $call->{constname}, priv->counter, sparse)))\n"; print " goto cleanup;\n"; print "\n"; - print " if (virNetClientAddStream(priv->client, netst) < 0) {\n"; - print " virObjectUnref(netst);\n"; - print " goto cleanup;\n"; - print " }"; + print " virNetClientAddStream(priv->client, netst);\n"; print "\n"; print " st->driver = &remoteStreamDrv;\n"; print " st->privateData = netst;\n"; diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 62d2368c9a..92933220e2 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1065,8 +1065,8 @@ void virNetClientAddProgram(virNetClient *client, } -int virNetClientAddStream(virNetClient *client, - virNetClientStream *st) +void virNetClientAddStream(virNetClient *client, + virNetClientStream *st) { virObjectLock(client); @@ -1074,7 +1074,6 @@ int virNetClientAddStream(virNetClient *client, client->streams[client->nstreams-1] = virObjectRef(st); virObjectUnlock(client); - return 0; } diff --git a/src/rpc/virnetclient.h b/src/rpc/virnetclient.h index ade3f8babe..d21dd089d8 100644 --- a/src/rpc/virnetclient.h +++ b/src/rpc/virnetclient.h @@ -120,8 +120,8 @@ bool virNetClientHasPassFD(virNetClient *client); void virNetClientAddProgram(virNetClient *client, virNetClientProgram *prog); -int virNetClientAddStream(virNetClient *client, - virNetClientStream *st); +void virNetClientAddStream(virNetClient *client, + virNetClientStream *st); void virNetClientRemoveStream(virNetClient *client, virNetClientStream *st);