[libvirt PATCH 0/2] coverity fixes

Ján Tomko (2): remote: close outfiles faster remote: dispatch: free and close infiles too src/remote/remote_daemon_dispatch.c | 5 ++++- src/remote/remote_driver.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) -- 2.34.1

Switch the operands in the loop condition to make it converge. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d6295f32e9..7e7a21fcab 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5977,7 +5977,7 @@ remoteDomainQemuMonitorCommandWithFiles(virDomainPtr domain, done: if (rpc_outfiles) { - for (i = 0; rpc_noutfiles < i; i++) { + for (i = 0; i < rpc_noutfiles; i++) { VIR_FORCE_CLOSE(rpc_outfiles[i]); } } -- 2.34.1

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_dispatch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 510856024c..e468bbf261 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -4693,7 +4693,7 @@ qemuDispatchDomainMonitorCommandWithFiles(virNetServer *server G_GNUC_UNUSED, qemu_domain_monitor_command_with_files_ret *ret) { virDomainPtr dom = NULL; - int *infiles = NULL; + g_autofree int *infiles = NULL; unsigned int ninfiles = 0; int *outfiles = NULL; unsigned int noutfiles = 0; @@ -4736,6 +4736,9 @@ qemuDispatchDomainMonitorCommandWithFiles(virNetServer *server G_GNUC_UNUSED, rv = 0; cleanup: + for (i = 0; i < ninfiles; i++) + VIR_FORCE_CLOSE(infiles[i]); + for (i = 0; i < noutfiles; i++) VIR_FORCE_CLOSE(outfiles[i]); -- 2.34.1
participants (2)
-
Ján Tomko
-
Peter Krempa