chiark / gitweb /
gpt-auto-generator: allow type check to fail
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 14 Mar 2015 02:10:13 +0000 (21:10 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 14 Mar 2015 03:42:16 +0000 (23:42 -0400)
add_mount() is OK with unknow file type, but we have to initalize
the variable to NULL not to pass garbage on error.

src/gpt-auto-generator/gpt-auto-generator.c

index 580f9929bd8d9995aad56d319324f8d80ebc714f..9f2da79e2c354dc9780fcadebd658dee639a5f45 100644 (file)
@@ -288,7 +288,7 @@ static int probe_and_add_mount(
                 const char *post) {
 
         _cleanup_blkid_free_probe_ blkid_probe b = NULL;
-        const char *fstype;
+        const char *fstype = NULL;
         int r;
 
         assert(id);
@@ -321,14 +321,11 @@ static int probe_and_add_mount(
         r = blkid_do_safeprobe(b);
         if (r == -2 || r == 1) /* no result or uncertain */
                 return 0;
-        else if (r != 0) {
-                if (errno == 0)
-                        errno = EIO;
-                log_error_errno(errno, "Failed to probe %s: %m", what);
-                return -errno;
-        }
+        else if (r != 0)
+                return log_error_errno(errno ?: EIO, "Failed to probe %s: %m", what);
 
-        blkid_probe_lookup_value(b, "TYPE", &fstype, NULL);
+        /* add_mount is OK with fstype being NULL. */
+        (void) blkid_probe_lookup_value(b, "TYPE", &fstype, NULL);
 
         return add_mount(
                         id,