[libvirt] [PATCH 3/7] tests: Return failure if log not fopen'd

John Ferlan posted 7 patches 7 years ago
[libvirt] [PATCH 3/7] tests: Return failure if log not fopen'd
Posted by John Ferlan 7 years ago
If @log is not fopen'd then, going to cleanup and calling fclose
will make for an unhappy caller. So just fail immediately instead
since there's nothing to clean up.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 tests/commandhelper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 1da2834aa4..bf91550ede 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -67,7 +67,7 @@ int main(int argc, char **argv) {
     int ret = EXIT_FAILURE;
 
     if (!log)
-        goto cleanup;
+        return ret;
 
     for (i = 1; i < argc; i++)
         fprintf(log, "ARG:%s\n", argv[i]);
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/7] tests: Return failure if log not fopen'd
Posted by Peter Krempa 7 years ago
On Tue, Apr 17, 2018 at 12:22:14 -0400, John Ferlan wrote:
> If @log is not fopen'd then, going to cleanup and calling fclose
> will make for an unhappy caller. So just fail immediately instead

s/caller/callee/

> since there's nothing to clean up.
> 
> Found by Coverity
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
>  tests/commandhelper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list