]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm-info: reject devices passed via opts too
authorDavid Tardon <dtardon@redhat.com>
Wed, 7 May 2025 12:35:54 +0000 (14:35 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 May 2025 03:14:21 +0000 (12:14 +0900)
Follow-up-for a6b4b2fa010f6dc5e18f1a14d93204c6c1416278

src/udev/udevadm-info.c

index 2eda70d1c01e7fae1afe086f7dfdac34f5634ce9..373ecdbe5d532c1a72edab323322aa6f6aa43ea0 100644 (file)
@@ -1250,11 +1250,10 @@ static int parse_argv(int argc, char *argv[]) {
         r = strv_extend_strv(&arg_devices, argv + optind, /* filter_duplicates= */ false);
         if (r < 0)
                 return log_error_errno(r, "Failed to build argument list: %m");
-        bool has_positional_args = r > 0;
 
-        if (IN_SET(arg_action_type, ACTION_DEVICE_ID_FILE, ACTION_CLEANUP_DB) && has_positional_args)
+        if (IN_SET(arg_action_type, ACTION_DEVICE_ID_FILE, ACTION_CLEANUP_DB) && !strv_isempty(arg_devices))
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-                                       "Positional arguments are not allowed with -d/--device-id-of-file and -c/--cleanup-db.");
+                                       "Devices are not allowed with -d/--device-id-of-file and -c/--cleanup-db.");
 
         if (!IN_SET(arg_action_type, ACTION_DEVICE_ID_FILE, ACTION_CLEANUP_DB, ACTION_EXPORT, ACTION_TREE) &&
             strv_isempty(arg_devices))