rpc: Change return type of virNetServerAddProgram 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 <p.nekrasov@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Alexander Kuznetsov 2024-11-28 18:21:18 +03:00 committed by Jiri Denemark
parent 393b0471a7
commit 5afe228ea7
5 changed files with 11 additions and 36 deletions

View File

@ -1066,10 +1066,7 @@ int main(int argc, char **argv) {
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(lockSrv, lockProgram) < 0) { virNetServerAddProgram(lockSrv, lockProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
if (adminSrv != NULL) { if (adminSrv != NULL) {
if (!(adminProgram = virNetServerProgramNew(ADMIN_PROGRAM, if (!(adminProgram = virNetServerProgramNew(ADMIN_PROGRAM,
@ -1079,10 +1076,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT; ret = VIR_DAEMON_ERR_INIT;
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(adminSrv, adminProgram) < 0) { virNetServerAddProgram(adminSrv, adminProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
} }
/* Disable error func, now logging is setup */ /* Disable error func, now logging is setup */

View File

@ -868,10 +868,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT; ret = VIR_DAEMON_ERR_INIT;
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(logSrv, logProgram) < 0) { virNetServerAddProgram(logSrv, logProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
if (adminSrv != NULL) { if (adminSrv != NULL) {
if (!(adminProgram = virNetServerProgramNew(ADMIN_PROGRAM, if (!(adminProgram = virNetServerProgramNew(ADMIN_PROGRAM,
@ -881,10 +878,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT; ret = VIR_DAEMON_ERR_INIT;
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(adminSrv, adminProgram) < 0) { virNetServerAddProgram(adminSrv, adminProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
} }
/* Disable error func, now logging is setup */ /* Disable error func, now logging is setup */

View File

@ -1063,10 +1063,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT; ret = VIR_DAEMON_ERR_INIT;
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(srv, remoteProgram) < 0) { virNetServerAddProgram(srv, remoteProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
if (!(lxcProgram = virNetServerProgramNew(LXC_PROGRAM, if (!(lxcProgram = virNetServerProgramNew(LXC_PROGRAM,
LXC_PROTOCOL_VERSION, LXC_PROTOCOL_VERSION,
@ -1075,10 +1072,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT; ret = VIR_DAEMON_ERR_INIT;
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(srv, lxcProgram) < 0) { virNetServerAddProgram(srv, lxcProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
if (!(qemuProgram = virNetServerProgramNew(QEMU_PROGRAM, if (!(qemuProgram = virNetServerProgramNew(QEMU_PROGRAM,
QEMU_PROTOCOL_VERSION, QEMU_PROTOCOL_VERSION,
@ -1087,10 +1081,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT; ret = VIR_DAEMON_ERR_INIT;
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(srv, qemuProgram) < 0) { virNetServerAddProgram(srv, qemuProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
if (!(srvAdm = virNetServerNew("admin", 1, if (!(srvAdm = virNetServerNew("admin", 1,
config->admin_min_workers, config->admin_min_workers,
@ -1120,10 +1111,7 @@ int main(int argc, char **argv) {
ret = VIR_DAEMON_ERR_INIT; ret = VIR_DAEMON_ERR_INIT;
goto cleanup; goto cleanup;
} }
if (virNetServerAddProgram(srvAdm, adminProgram) < 0) { virNetServerAddProgram(srvAdm, adminProgram);
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
}
if (timeout > 0) { if (timeout > 0) {
if (virNetDaemonAutoShutdown(dmn, timeout) < 0) if (virNetDaemonAutoShutdown(dmn, timeout) < 0)

View File

@ -768,7 +768,7 @@ virNetServerAddServiceUNIX(virNetServer *srv,
} }
int void
virNetServerAddProgram(virNetServer *srv, virNetServerAddProgram(virNetServer *srv,
virNetServerProgram *prog) virNetServerProgram *prog)
{ {
@ -776,7 +776,6 @@ virNetServerAddProgram(virNetServer *srv,
VIR_EXPAND_N(srv->programs, srv->nprograms, 1); VIR_EXPAND_N(srv->programs, srv->nprograms, 1);
srv->programs[srv->nprograms-1] = virObjectRef(prog); srv->programs[srv->nprograms-1] = virObjectRef(prog);
return 0;
} }

View File

@ -84,7 +84,7 @@ int virNetServerAddServiceUNIX(virNetServer *srv,
size_t max_queued_clients, size_t max_queued_clients,
size_t nrequests_client_max); size_t nrequests_client_max);
int virNetServerAddProgram(virNetServer *srv, void virNetServerAddProgram(virNetServer *srv,
virNetServerProgram *prog); virNetServerProgram *prog);
int virNetServerSetTLSContext(virNetServer *srv, int virNetServerSetTLSContext(virNetServer *srv,