1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

tree-wide: use errno_or_else() more, instead of homegrown checks

This commit is contained in:
Lennart Poettering 2022-12-01 15:36:55 +01:00
parent 003cb0e046
commit ef1f0a14fa
2 changed files with 9 additions and 9 deletions

View File

@ -141,7 +141,7 @@ static int probe_file_system_by_fd(
errno = 0;
r = blkid_probe_set_device(b, fd, 0, 0);
if (r != 0)
return errno > 0 ? -errno : -ENOMEM;
return errno_or_else(ENOMEM);
(void) blkid_probe_enable_superblocks(b, 1);
(void) blkid_probe_set_superblocks_flags(b, BLKID_SUBLKS_TYPE|BLKID_SUBLKS_UUID);
@ -656,7 +656,7 @@ static int luks_validate(
errno = 0;
r = blkid_probe_set_device(b, fd, 0, 0);
if (r != 0)
return errno > 0 ? -errno : -ENOMEM;
return errno_or_else(ENOMEM);
(void) blkid_probe_enable_superblocks(b, 1);
(void) blkid_probe_set_superblocks_flags(b, BLKID_SUBLKS_TYPE);
@ -687,12 +687,12 @@ static int luks_validate(
errno = 0;
pl = blkid_probe_get_partitions(b);
if (!pl)
return errno > 0 ? -errno : -ENOMEM;
return errno_or_else(ENOMEM);
errno = 0;
n = blkid_partlist_numof_partitions(pl);
if (n < 0)
return errno > 0 ? -errno : -EIO;
return errno_or_else(EIO);
for (int i = 0; i < n; i++) {
sd_id128_t id = SD_ID128_NULL;
@ -701,7 +701,7 @@ static int luks_validate(
errno = 0;
pp = blkid_partlist_get_partition(pl, i);
if (!pp)
return errno > 0 ? -errno : -EIO;
return errno_or_else(EIO);
if (sd_id128_string_equal(blkid_partition_get_type_string(pp), SD_GPT_USER_HOME) <= 0)
continue;

View File

@ -564,7 +564,7 @@ static int verify_xbootldr_blkid(
errno = 0;
b = blkid_new_probe_from_filename(node);
if (!b)
return log_error_errno(errno ?: SYNTHETIC_ERRNO(ENOMEM), "%s: Failed to create blkid probe: %m", node);
return log_error_errno(errno_or_else(ENOMEM), "%s: Failed to create blkid probe: %m", node);
blkid_probe_enable_partitions(b, 1);
blkid_probe_set_partitions_flags(b, BLKID_PARTS_ENTRY_DETAILS);
@ -588,7 +588,7 @@ static int verify_xbootldr_blkid(
errno = 0;
r = blkid_probe_lookup_value(b, "PART_ENTRY_TYPE", &v, NULL);
if (r != 0)
return log_error_errno(errno ?: SYNTHETIC_ERRNO(EIO), "%s: Failed to probe PART_ENTRY_TYPE: %m", node);
return log_error_errno(errno_or_else(EIO), "%s: Failed to probe PART_ENTRY_TYPE: %m", node);
if (sd_id128_string_equal(v, SD_GPT_XBOOTLDR) <= 0)
return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
searching ? SYNTHETIC_ERRNO(EADDRNOTAVAIL) : SYNTHETIC_ERRNO(ENODEV),
@ -597,7 +597,7 @@ static int verify_xbootldr_blkid(
errno = 0;
r = blkid_probe_lookup_value(b, "PART_ENTRY_UUID", &v, NULL);
if (r != 0)
return log_error_errno(errno ?: SYNTHETIC_ERRNO(EIO), "%s: Failed to probe PART_ENTRY_UUID: %m", node);
return log_error_errno(errno_or_else(EIO), "%s: Failed to probe PART_ENTRY_UUID: %m", node);
r = sd_id128_from_string(v, &uuid);
if (r < 0)
return log_error_errno(r, "%s: Partition has invalid UUID PART_ENTRY_TYPE=%s: %m", node, v);
@ -607,7 +607,7 @@ static int verify_xbootldr_blkid(
errno = 0;
r = blkid_probe_lookup_value(b, "PART_ENTRY_TYPE", &v, NULL);
if (r != 0)
return log_error_errno(errno ?: SYNTHETIC_ERRNO(EIO), "%s: Failed to probe PART_ENTRY_TYPE: %m", node);
return log_error_errno(errno_or_else(EIO), "%s: Failed to probe PART_ENTRY_TYPE: %m", node);
if (!streq(v, "0xea"))
return log_full_errno(searching ? LOG_DEBUG : LOG_ERR,
searching ? SYNTHETIC_ERRNO(EADDRNOTAVAIL) : SYNTHETIC_ERRNO(ENODEV),