From 47c8fcbeb75976db2f8c4015cbf67cb6049a8934 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 12 Jan 2019 08:33:09 +0900 Subject: [PATCH] udevadm: use SYNTHETIC_ERRNO() macro --- src/udev/udevadm-control.c | 7 +++---- src/udev/udevadm-info.c | 6 ++---- src/udev/udevadm-trigger.c | 12 ++++-------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c index 1966af7..5e1bf27 100644 --- a/src/udev/udevadm-control.c +++ b/src/udev/udevadm-control.c @@ -116,10 +116,9 @@ int control_main(int argc, char *argv[], void *userdata) { return r; break; case 'p': - if (!strchr(optarg, '=')) { - log_error("expect = instead of '%s'", optarg); - return -EINVAL; - } + if (!strchr(optarg, '=')) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "expect = instead of '%s'", optarg); + r = udev_ctrl_send_set_env(uctrl, optarg, timeout); if (r < 0) return r; diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index 140950d..ae38e77 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -387,10 +387,8 @@ int info_main(int argc, char *argv[], void *userdata) { query = QUERY_PATH; else if (streq(optarg, "all")) query = QUERY_ALL; - else { - log_error("unknown query type"); - return -EINVAL; - } + else + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "unknown query type"); break; case 'r': arg_root = true; diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index aa9ebd5..b0be6e8 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -188,18 +188,14 @@ int trigger_main(int argc, char *argv[], void *userdata) { device_type = TYPE_DEVICES; else if (streq(optarg, "subsystems")) device_type = TYPE_SUBSYSTEMS; - else { - log_error("Unknown type --type=%s", optarg); - return -EINVAL; - } + else + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg); break; case 'c': if (STR_IN_SET(optarg, "add", "remove", "change")) action = optarg; - else { - log_error("Unknown action '%s'", optarg); - return -EINVAL; - } + else + log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg); break; case 's': -- 2.7.4