diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-02-06 13:29:02 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-02-06 13:30:53 +0100 |
commit | 0747cde76c3df131c3f29e563bf51dd33fc5f7d2 (patch) | |
tree | d765ad6a64f312b6904740c85c22bd072d070725 /src/busctl | |
parent | 143aea3813ee10c45bd9b35c67665ffe21b43503 (diff) | |
download | systemd-0747cde76c3df131c3f29e563bf51dd33fc5f7d2.tar.gz |
busctl: shorten code a bit by using SYNTHETIC_ERRNO()
Diffstat (limited to 'src/busctl')
-rw-r--r-- | src/busctl/busctl.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 46263bd6b2..a61fd2e706 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -796,10 +796,8 @@ static int on_interface(const char *interface, uint64_t flags, void *userdata) { return log_oom(); r = set_put(members, m); - if (r <= 0) { - log_error("Duplicate interface"); - return -EINVAL; - } + if (r <= 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Duplicate interface"); m = NULL; return 0; @@ -837,10 +835,8 @@ static int on_method(const char *interface, const char *name, const char *signat return log_oom(); r = set_put(members, m); - if (r <= 0) { - log_error("Duplicate method"); - return -EINVAL; - } + if (r <= 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Duplicate method"); m = NULL; return 0; @@ -874,10 +870,8 @@ static int on_signal(const char *interface, const char *name, const char *signat return log_oom(); r = set_put(members, m); - if (r <= 0) { - log_error("Duplicate signal"); - return -EINVAL; - } + if (r <= 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Duplicate signal"); m = NULL; return 0; @@ -912,10 +906,8 @@ static int on_property(const char *interface, const char *name, const char *sign return log_oom(); r = set_put(members, m); - if (r <= 0) { - log_error("Duplicate property"); - return -EINVAL; - } + if (r <= 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Duplicate property"); m = NULL; return 0; @@ -1196,10 +1188,8 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f STRV_FOREACH(i, argv+1) { _cleanup_free_ char *m = NULL; - if (!service_name_is_valid(*i)) { - log_error("Invalid service name '%s'", *i); - return -EINVAL; - } + if (!service_name_is_valid(*i)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid service name '%s'", *i); m = strjoin("sender='", *i, "'"); if (!m) @@ -1979,10 +1969,8 @@ static int call(int argc, char **argv, void *userdata) { if (r < 0) return r; - if (*p) { - log_error("Too many parameters for signature."); - return -EINVAL; - } + if (*p) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Too many parameters for signature."); } if (!arg_expect_reply) { @@ -2176,10 +2164,8 @@ static int set_property(int argc, char **argv, void *userdata) { if (r < 0) return bus_log_create_error(r); - if (*p) { - log_error("Too many parameters for signature."); - return -EINVAL; - } + if (*p) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Too many parameters for signature."); r = sd_bus_call(bus, m, arg_timeout, &error, NULL); if (r < 0) |