1ff636
From e2353e7c13808e47efb844f8fb10b7aa2142e619 Mon Sep 17 00:00:00 2001
1ff636
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
1ff636
Date: Fri, 13 Mar 2015 21:10:13 -0500
1ff636
Subject: [PATCH] gpt-auto-generator: allow type check to fail
1ff636
1ff636
add_mount() is OK with unknow file type, but we have to initalize
1ff636
the variable to NULL not to pass garbage on error.
1ff636
1ff636
(cherry picked from commit a0b1209c4a59754f428894e0485413542da50014)
1ff636
---
1ff636
 src/gpt-auto-generator/gpt-auto-generator.c | 13 +++++--------
1ff636
 1 file changed, 5 insertions(+), 8 deletions(-)
1ff636
1ff636
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
c62b8e
index cceeeb845c..00a2141a58 100644
1ff636
--- a/src/gpt-auto-generator/gpt-auto-generator.c
1ff636
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
1ff636
@@ -291,7 +291,7 @@ static int probe_and_add_mount(
1ff636
                 const char *post) {
1ff636
 
1ff636
         _cleanup_blkid_free_probe_ blkid_probe b = NULL;
1ff636
-        const char *fstype;
1ff636
+        const char *fstype = NULL;
1ff636
         int r;
1ff636
 
1ff636
         assert(id);
1ff636
@@ -324,14 +324,11 @@ static int probe_and_add_mount(
1ff636
         r = blkid_do_safeprobe(b);
1ff636
         if (r == -2 || r == 1) /* no result or uncertain */
1ff636
                 return 0;
1ff636
-        else if (r != 0) {
1ff636
-                if (errno == 0)
1ff636
-                        errno = EIO;
1ff636
-                log_error_errno(errno, "Failed to probe %s: %m", what);
1ff636
-                return -errno;
1ff636
-        }
1ff636
+        else if (r != 0)
1ff636
+                return log_error_errno(errno ?: EIO, "Failed to probe %s: %m", what);
1ff636
 
1ff636
-        blkid_probe_lookup_value(b, "TYPE", &fstype, NULL);
1ff636
+        /* add_mount is OK with fstype being NULL. */
1ff636
+        (void) blkid_probe_lookup_value(b, "TYPE", &fstype, NULL);
1ff636
 
1ff636
         return add_mount(
1ff636
                         id,