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;
}
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 */

View File

@ -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 */

View File

@ -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)

View File

@ -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;
}

View File

@ -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,