summaryrefslogtreecommitdiffstats
path: root/src/systemctl
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-10 19:17:47 +0100
committerGitHub <noreply@github.com>2021-02-10 19:17:47 +0100
commitfa7924db0bd836e30021c9b2c0480f0beb1a85d6 (patch)
tree140ee965dbe69032363640110dec3fe8089d379f /src/systemctl
parenttest: count call instructions as well (diff)
parenttest-string-util: add missing comma (diff)
downloadsystemd-fa7924db0bd836e30021c9b2c0480f0beb1a85d6.tar.xz
systemd-fa7924db0bd836e30021c9b2c0480f0beb1a85d6.zip
Merge pull request #11484 from keszybz/udevadm-error-logs
Use real return codes in _from_string() functions
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-log-setting.c6
-rw-r--r--src/systemctl/systemctl-show.c5
-rw-r--r--src/systemctl/systemctl-util.c2
-rw-r--r--src/systemctl/systemctl.h2
4 files changed, 7 insertions, 8 deletions
diff --git a/src/systemctl/systemctl-log-setting.c b/src/systemctl/systemctl-log-setting.c
index 64984e4a81..9a95c7dab4 100644
--- a/src/systemctl/systemctl-log-setting.c
+++ b/src/systemctl/systemctl-log-setting.c
@@ -30,9 +30,9 @@ static int log_setting_internal(sd_bus *bus, const BusLocator* bloc, const char
if (value) {
if (level) {
- if (log_level_from_string(value) < 0)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "\"%s\" is not a valid log level.", value);
+ r = log_level_from_string(value);
+ if (r < 0)
+ return log_error_errno(r, "\"%s\" is not a valid log level.", value);
}
r = bus_set_property(bus, bloc,
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index ab66977a7a..9b04b698be 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -1708,7 +1708,7 @@ typedef enum SystemctlShowMode{
SYSTEMCTL_SHOW_STATUS,
SYSTEMCTL_SHOW_HELP,
_SYSTEMCTL_SHOW_MODE_MAX,
- _SYSTEMCTL_SHOW_MODE_INVALID = -1,
+ _SYSTEMCTL_SHOW_MODE_INVALID = -EINVAL,
} SystemctlShowMode;
static const char* const systemctl_show_mode_table[_SYSTEMCTL_SHOW_MODE_MAX] = {
@@ -2040,8 +2040,7 @@ int show(int argc, char *argv[], void *userdata) {
show_mode = systemctl_show_mode_from_string(argv[0]);
if (show_mode < 0)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Invalid argument.");
+ return log_error_errno(show_mode, "Invalid argument.");
if (show_mode == SYSTEMCTL_SHOW_HELP && argc <= 1)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c
index a854107cc8..89c342a0b1 100644
--- a/src/systemctl/systemctl-util.c
+++ b/src/systemctl/systemctl-util.c
@@ -143,7 +143,7 @@ int get_state_one_unit(sd_bus *bus, const char *unit, UnitActiveState *ret_activ
state = unit_active_state_from_string(buf);
if (state < 0)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid unit state '%s' for: %s", buf, unit);
+ return log_error_errno(state, "Invalid unit state '%s' for: %s", buf, unit);
*ret_active_state = state;
return 0;
diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h
index 722853db2a..0ebe4580c6 100644
--- a/src/systemctl/systemctl.h
+++ b/src/systemctl/systemctl.h
@@ -32,7 +32,7 @@ enum action {
ACTION_TELINIT,
ACTION_CANCEL_SHUTDOWN,
_ACTION_MAX,
- _ACTION_INVALID = -1
+ _ACTION_INVALID = -EINVAL,
};
enum dependency {