From baaa35ad706419ae5aacc11d2bece5bd8b73ee42 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 20 Nov 2018 23:40:44 +0100 Subject: 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. --- src/shared/bootspec.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/shared/bootspec.c') 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); -- cgit v1.2.3