diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 23:40:44 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-22 10:54:38 +0100 |
commit | baaa35ad706419ae5aacc11d2bece5bd8b73ee42 (patch) | |
tree | bb4b9c576fc56b3237d59e959ded7c245917fcd7 /src/volatile-root/volatile-root.c | |
parent | basic/log: add concept of "synthethic errnos" (diff) | |
download | systemd-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/volatile-root/volatile-root.c')
-rw-r--r-- | src/volatile-root/volatile-root.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/volatile-root/volatile-root.c b/src/volatile-root/volatile-root.c index 70f5d957b2..ffe63d5717 100644 --- a/src/volatile-root/volatile-root.c +++ b/src/volatile-root/volatile-root.c @@ -19,10 +19,9 @@ static int make_volatile(const char *path) { r = path_is_mount_point(path, NULL, AT_SYMLINK_FOLLOW); if (r < 0) return log_error_errno(r, "Couldn't determine whether %s is a mount point: %m", path); - if (r == 0) { - log_error("%s is not a mount point.", path); - return -EINVAL; - } + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "%s is not a mount point.", path); r = path_is_temporary_fs(path); if (r < 0) @@ -84,10 +83,9 @@ static int run(int argc, char *argv[]) { log_setup_service(); - if (argc > 3) { - log_error("Too many arguments. Expected directory and mode."); - return -EINVAL; - } + if (argc > 3) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Too many arguments. Expected directory and mode."); r = query_volatile_mode(&m); if (r < 0) @@ -106,18 +104,15 @@ static int run(int argc, char *argv[]) { else { path = argv[2]; - if (isempty(path)) { - log_error("Directory name cannot be empty."); - return -EINVAL; - } - if (!path_is_absolute(path)) { - log_error("Directory must be specified as absolute path."); - return -EINVAL; - } - if (path_equal(path, "/")) { - log_error("Directory cannot be the root directory."); - return -EINVAL; - } + if (isempty(path)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Directory name cannot be empty."); + if (!path_is_absolute(path)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Directory must be specified as absolute path."); + if (path_equal(path, "/")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Directory cannot be the root directory."); } if (m != VOLATILE_YES) |