daemon: debug segv correct use of dereferencing NULL.
[libguestfs.git] / examples / inspect_vm.c
index 4019a01..6c45aac 100644 (file)
@@ -11,10 +11,10 @@ compare_keys_len (const void *p1, const void *p2)
   return strlen (key1) - strlen (key2);
 }
 
   return strlen (key1) - strlen (key2);
 }
 
-static int
+static size_t
 count_strings (char *const *argv)
 {
 count_strings (char *const *argv)
 {
-  int c;
+  size_t c;
 
   for (c = 0; argv[c]; ++c)
     ;
 
   for (c = 0; argv[c]; ++c)
     ;
@@ -98,8 +98,10 @@ main (int argc, char *argv[])
     qsort (mountpoints, count_strings (mountpoints) / 2, 2 * sizeof (char *),
            compare_keys_len);
     for (i = 0; mountpoints[i] != NULL; i += 2) {
     qsort (mountpoints, count_strings (mountpoints) / 2, 2 * sizeof (char *),
            compare_keys_len);
     for (i = 0; mountpoints[i] != NULL; i += 2) {
-      if (guestfs_mount_ro (g, mountpoints[i+1], mountpoints[i]) == -1)
-        exit (EXIT_FAILURE);
+      /* Ignore failures from this call, since bogus entries can
+       * appear in the guest's /etc/fstab.
+       */
+      guestfs_mount_ro (g, mountpoints[i+1], mountpoints[i]);
       free (mountpoints[i]);
       free (mountpoints[i+1]);
     }
       free (mountpoints[i]);
       free (mountpoints[i+1]);
     }