]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Need to check return of virGetLastError
authorJohn Ferlan <jferlan@redhat.com>
Mon, 18 Jul 2016 18:25:43 +0000 (14:25 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 19 Jul 2016 11:51:10 +0000 (07:51 -0400)
Cannot assume virGetLastError returns non-NULL value - modify the code to
fetch err and check if err && err->code

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
tests/qemuhelptest.c

index 8aac9974a8af3a3d1951a36c9b0616e0f604aef4..7c8b84133cf7af84d3dd35c3fae152b4f5e5e1f7 100644 (file)
@@ -60,7 +60,9 @@ static int testHelpStrParsing(const void *data)
 
     if (virQEMUCapsParseHelpStr("QEMU", help, flags,
                                 &version, &is_kvm, &kvm_version, false, NULL) == -1) {
-        if (info->error && virGetLastError()->code == info->error)
+        virErrorPtr err = virGetLastError();
+
+        if (info->error && err && err->code == info->error)
             ret = 0;
         goto cleanup;
     }