From b382db9f3b1f1ffa33ed4970cf2e01d2ee4e8d88 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 21 Feb 2017 16:41:33 -0500 Subject: tree-wide: simplify handling of blkid errors --- src/shared/dissect-image.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'src/shared/dissect-image.c') diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 410a7764ed..39e724c51a 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -61,12 +61,8 @@ static int probe_filesystem(const char *node, char **ret_fstype) { log_debug("Failed to identify any partition type on partition %s", node); goto not_found; } - if (r != 0) { - if (errno == 0) - return -EIO; - - return -errno; - } + if (r != 0) + return -errno ?: -EIO; (void) blkid_probe_lookup_value(b, "TYPE", &fstype, NULL); @@ -146,12 +142,8 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI errno = 0; r = blkid_probe_set_device(b, fd, 0, 0); - if (r != 0) { - if (errno == 0) - return -ENOMEM; - - return -errno; - } + if (r != 0) + return -errno ?: -ENOMEM; if ((flags & DISSECT_IMAGE_GPT_ONLY) == 0) { /* Look for file system superblocks, unless we only shall look for GPT partition tables */ @@ -168,12 +160,8 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI log_debug("Failed to identify any partition table."); return -ENOPKG; } - if (r != 0) { - if (errno == 0) - return -EIO; - - return -errno; - } + if (r != 0) + return -errno ?: -EIO; m = new0(DissectedImage, 1); if (!m) @@ -232,12 +220,8 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI errno = 0; pl = blkid_probe_get_partitions(b); - if (!pl) { - if (errno == 0) - return -ENOMEM; - - return -errno; - } + if (!pl) + return -errno ?: -ENOMEM; udev = udev_new(); if (!udev) -- cgit v1.2.3-54-g00ecf