summaryrefslogtreecommitdiffstats
path: root/src/shared/bootspec.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-20 23:40:44 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-22 10:54:38 +0100
commitbaaa35ad706419ae5aacc11d2bece5bd8b73ee42 (patch)
treebb4b9c576fc56b3237d59e959ded7c245917fcd7 /src/shared/bootspec.c
parentbasic/log: add concept of "synthethic errnos" (diff)
downloadsystemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.tar.xz
systemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.zip
coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
Diffstat (limited to 'src/shared/bootspec.c')
-rw-r--r--src/shared/bootspec.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 9ba6978962..db4fd411e2 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -593,10 +593,10 @@ int find_esp_and_warn(
path = getenv("SYSTEMD_ESP_PATH");
if (path) {
- if (!path_is_valid(path) || !path_is_absolute(path)) {
- log_error("$SYSTEMD_ESP_PATH does not refer to absolute path, refusing to use it: %s", path);
- return -EINVAL;
- }
+ if (!path_is_valid(path) || !path_is_absolute(path))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "$SYSTEMD_ESP_PATH does not refer to absolute path, refusing to use it: %s",
+ path);
/* Note: when the user explicitly configured things with an env var we won't validate the mount
* point. After all we want this to be useful for testing. */
@@ -649,10 +649,9 @@ int find_default_boot_entry(
if (r < 0)
return log_error_errno(r, "Failed to load bootspec config from \"%s/loader\": %m", where);
- if (config->default_entry < 0) {
- log_error("No entry suitable as default, refusing to guess.");
- return -ENOENT;
- }
+ if (config->default_entry < 0)
+ return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
+ "No entry suitable as default, refusing to guess.");
*e = &config->entries[config->default_entry];
log_debug("Found default boot entry in file \"%s\"", (*e)->path);