diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-10-23 22:17:46 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-10-23 22:19:40 +0200 |
commit | 475c473d328c12f5e9fd43cee959154a0d0c78a4 (patch) | |
tree | e8660cf290da90c3a34e0df1611d19683f1f1819 /src | |
parent | cryptenroll: reduce scope of two global variables (diff) | |
download | systemd-475c473d328c12f5e9fd43cee959154a0d0c78a4.tar.xz systemd-475c473d328c12f5e9fd43cee959154a0d0c78a4.zip |
cryptenroll: merge two if checks with same condition
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"
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptenroll/cryptenroll.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/cryptenroll/cryptenroll.c b/src/cryptenroll/cryptenroll.c index 4086f7f9a7..a3332f5e7d 100644 --- a/src/cryptenroll/cryptenroll.c +++ b/src/cryptenroll/cryptenroll.c @@ -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) |