]> xenbits.xensource.com Git - libvirt.git/commitdiff
securityselinuxlabeltest: Prefer virGetLastErrorMessage() over virGetLastError
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Aug 2016 07:20:31 +0000 (09:20 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Aug 2016 13:32:20 +0000 (15:32 +0200)
At the beginning of the test, some preparation work is done. For
instance new virSecurityManager is created. If this fails for
whatever reason, we try to fetch the latest error and print the
error message contained in it. However, if there's a bug in our
code and no error is reported, this approach will lead to crash,
while with virGetLastErrorMessage() it won't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/securityselinuxlabeltest.c

index 7d5544b730a29a0857c511bee33195ad4eff405b..4c0f427e637d19968a5f2fdced0ca9d60d15c9ce 100644 (file)
@@ -354,9 +354,8 @@ mymain(void)
     if (!(mgr = virSecurityManagerNew("selinux", "QEMU",
                                       VIR_SECURITY_MANAGER_DEFAULT_CONFINED |
                                       VIR_SECURITY_MANAGER_PRIVILEGED))) {
-        virErrorPtr err = virGetLastError();
         VIR_TEST_VERBOSE("Unable to initialize security driver: %s\n",
-                err->message);
+                         virGetLastErrorMessage());
         return EXIT_FAILURE;
     }