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 <p.nekrasov@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
---
src/locking/lock_daemon.c | 10 ++--------
src/logging/log_daemon.c | 10 ++--------
src/remote/remote_daemon.c | 20 ++++----------------
src/rpc/virnetserver.c | 3 +--
src/rpc/virnetserver.h | 2 +-
5 files changed, 10 insertions(+), 35 deletions(-)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index ba52ce7d77..0b86300b43 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -1066,10 +1066,7 @@ int main(int argc, char **argv) {
goto cleanup;
}
- if (virNetServerAddProgram(lockSrv, lockProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(lockSrv, lockProgram);
if (adminSrv != NULL) {
if (!(adminProgram = virNetServerProgramNew(ADMIN_PROGRAM,
@@ -1079,10 +1076,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
- if (virNetServerAddProgram(adminSrv, adminProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(adminSrv, adminProgram);
}
/* Disable error func, now logging is setup */
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index daf7ef4b2f..606aafd071 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -868,10 +868,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
- if (virNetServerAddProgram(logSrv, logProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(logSrv, logProgram);
if (adminSrv != NULL) {
if (!(adminProgram = virNetServerProgramNew(ADMIN_PROGRAM,
@@ -881,10 +878,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
- if (virNetServerAddProgram(adminSrv, adminProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(adminSrv, adminProgram);
}
/* Disable error func, now logging is setup */
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 9e82132654..1d079c7e4b 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -1063,10 +1063,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
- if (virNetServerAddProgram(srv, remoteProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(srv, remoteProgram);
if (!(lxcProgram = virNetServerProgramNew(LXC_PROGRAM,
LXC_PROTOCOL_VERSION,
@@ -1075,10 +1072,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
- if (virNetServerAddProgram(srv, lxcProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(srv, lxcProgram);
if (!(qemuProgram = virNetServerProgramNew(QEMU_PROGRAM,
QEMU_PROTOCOL_VERSION,
@@ -1087,10 +1081,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
- if (virNetServerAddProgram(srv, qemuProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(srv, qemuProgram);
if (!(srvAdm = virNetServerNew("admin", 1,
config->admin_min_workers,
@@ -1120,10 +1111,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
- if (virNetServerAddProgram(srvAdm, adminProgram) < 0) {
- ret = VIR_DAEMON_ERR_INIT;
- goto cleanup;
- }
+ virNetServerAddProgram(srvAdm, adminProgram);
if (timeout > 0) {
if (virNetDaemonAutoShutdown(dmn, timeout) < 0)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index a6c6443c55..91219c3eed 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -768,7 +768,7 @@ virNetServerAddServiceUNIX(virNetServer *srv,
}
-int
+void
virNetServerAddProgram(virNetServer *srv,
virNetServerProgram *prog)
{
@@ -776,7 +776,6 @@ virNetServerAddProgram(virNetServer *srv,
VIR_EXPAND_N(srv->programs, srv->nprograms, 1);
srv->programs[srv->nprograms-1] = virObjectRef(prog);
- return 0;
}
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 7756a1dd6c..c14d8bd10f 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -84,7 +84,7 @@ int virNetServerAddServiceUNIX(virNetServer *srv,
size_t max_queued_clients,
size_t nrequests_client_max);
-int virNetServerAddProgram(virNetServer *srv,
+void virNetServerAddProgram(virNetServer *srv,
virNetServerProgram *prog);
int virNetServerSetTLSContext(virNetServer *srv,
--
2.42.2
On Thu, Nov 28, 2024 at 18:21:18 +0300, Alexander Kuznetsov wrote: > 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 <p.nekrasov@fobos-nt.ru> > Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org> > --- > src/locking/lock_daemon.c | 10 ++-------- > src/logging/log_daemon.c | 10 ++-------- > src/remote/remote_daemon.c | 20 ++++---------------- > src/rpc/virnetserver.c | 3 +-- > src/rpc/virnetserver.h | 2 +- > 5 files changed, 10 insertions(+), 35 deletions(-) ... > diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h > index 7756a1dd6c..c14d8bd10f 100644 > --- a/src/rpc/virnetserver.h > +++ b/src/rpc/virnetserver.h > @@ -84,7 +84,7 @@ int virNetServerAddServiceUNIX(virNetServer *srv, > size_t max_queued_clients, > size_t nrequests_client_max); > > -int virNetServerAddProgram(virNetServer *srv, > +void virNetServerAddProgram(virNetServer *srv, > virNetServerProgram *prog); Indentation error. Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
© 2016 - 2024 Red Hat, Inc.