diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-13 21:10:13 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-13 23:42:16 -0400 |
commit | a0b1209c4a59754f428894e0485413542da50014 (patch) | |
tree | 55ffcc48ed00e7cb35b39bc6dd07673c16ca2eed | |
parent | 7c5925a448551129ec2e11157c847703def79608 (diff) |
gpt-auto-generator: allow type check to fail
add_mount() is OK with unknow file type, but we have to initalize
the variable to NULL not to pass garbage on error.
-rw-r--r-- | src/gpt-auto-generator/gpt-auto-generator.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 580f9929bd..9f2da79e2c 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -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, |