]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
examples: hellolibvirt: fix argc check
authorJán Tomko <jtomko@redhat.com>
Tue, 14 Dec 2021 10:59:43 +0000 (11:59 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 14 Dec 2021 11:12:40 +0000 (12:12 +0100)
https://gitlab.com/libvirt/libvirt/-/issues/255

Reported-by: Jeremy Alcim
Signed-off-by: Ján Tomko <jtomko@redhat.com>
examples/c/misc/hellolibvirt.c

index a598e01be2a8a70323d0c214d2ba13ad2aad2059..39cefe934cbdee21ffd84672619dbb876eea0aae 100644 (file)
@@ -107,11 +107,12 @@ main(int argc, char *argv[])
 {
     int ret = 0;
     virConnectPtr conn;
-    char *uri;
+    char *uri = NULL;
 
     printf("Attempting to connect to hypervisor\n");
 
-    uri = (argc > 0 ? argv[1] : NULL);
+    if (argc > 1)
+        uri = argv[1];
 
     /* virConnectOpenAuth is called here with all default parameters,
      * except, possibly, the URI of the hypervisor. */