From: Yu Watanabe Date: Sat, 9 Mar 2019 01:20:42 +0000 (+0900) Subject: udevadm-test: check action string earlier X-Git-Tag: v242-rc1~160^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a12b87f59c8601aceaf58a8e1c3464aae329700a;p=thirdparty%2Fsystemd.git udevadm-test: check action string earlier The string will be checked later in device_new_from_synthetic_event(), but let's check it earlier in parse_argv(). --- diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index 9c1784489a8..da4c4cb87cc 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -53,9 +53,17 @@ static int parse_argv(int argc, char *argv[]) { while ((c = getopt_long(argc, argv, "a:N:Vh", options, NULL)) >= 0) switch (c) { - case 'a': + case 'a': { + DeviceAction a; + + a = device_action_from_string(optarg); + if (a < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Invalid action '%s'", optarg); + arg_action = optarg; break; + } case 'N': arg_resolve_name_timing = resolve_name_timing_from_string(optarg); if (arg_resolve_name_timing < 0)