]> xenbits.xensource.com Git - libvirt.git/commitdiff
event-test: Check for virConnectRegisterCloseCallback return value
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 16 Mar 2016 08:32:44 +0000 (09:32 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 24 Mar 2016 09:49:39 +0000 (10:49 +0100)
In an unlikely event of virConnectRegisterCloseCallback failing,
the error is ignored. This is an example file and we shouldn't
get a bad example.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
examples/object-events/event-test.c

index 81830c7914529ce8b85ebbe36922892e4ba04bd6..7be1d21e1b3bb4dc8cbe5f2ea549e26a62a783fb 100644 (file)
@@ -668,8 +668,11 @@ int main(int argc, char **argv)
         goto cleanup;
     }
 
-    virConnectRegisterCloseCallback(dconn,
-                                    connectClose, NULL, NULL);
+    if (virConnectRegisterCloseCallback(dconn,
+                                        connectClose, NULL, NULL) < 0) {
+        fprintf(stderr, "Unable to register close callback\n");
+        goto cleanup;
+    }
 
     sigaction(SIGTERM, &action_stop, NULL);
     sigaction(SIGINT, &action_stop, NULL);