]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptenroll: merge two if checks with same condition 29685/head
authorLennart Poettering <lennart@poettering.net>
Mon, 23 Oct 2023 20:17:46 +0000 (22:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 23 Oct 2023 20:19:40 +0000 (22:19 +0200)
This removes a duplicate condition check by adding a common surrounding
if block.

This also change a confusing if check: "(X && Y) && Z" to simply "X && Y && Z"

src/cryptenroll/cryptenroll.c

index 4086f7f9a77a2f7169ebc217f625db979fa98d7a..a3332f5e7d1d423c1f940c9c04ab32fd9e3be5ea 100644 (file)
@@ -467,16 +467,18 @@ static int parse_argv(int argc, char *argv[]) {
                 }
         }
 
-        if ((arg_enroll_type == ENROLL_FIDO2 && arg_unlock_type == UNLOCK_FIDO2)
-                        && !(arg_fido2_device && arg_unlock_fido2_device))
-                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-                                       "When both enrolling and unlocking with FIDO2 tokens, automatic discovery is unsupported. "
-                                       "Please specify device paths for enrolling and unlocking respectively.");
+        if (arg_enroll_type == ENROLL_FIDO2) {
 
-        if (arg_enroll_type == ENROLL_FIDO2 && !arg_fido2_device) {
-                r = fido2_find_device_auto(&arg_fido2_device);
-                if (r < 0)
-                        return r;
+                if (arg_unlock_type == UNLOCK_FIDO2 && !(arg_fido2_device && arg_unlock_fido2_device))
+                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                               "When both enrolling and unlocking with FIDO2 tokens, automatic discovery is unsupported. "
+                                               "Please specify device paths for enrolling and unlocking respectively.");
+
+                if (!arg_fido2_device) {
+                        r = fido2_find_device_auto(&arg_fido2_device);
+                        if (r < 0)
+                                return r;
+                }
         }
 
         if (optind >= argc)