From: Lennart Poettering Date: Fri, 21 Jun 2024 10:10:51 +0000 (+0200) Subject: cryptsetup: minor coding style tweaks X-Git-Tag: v257-rc1~1079 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50df39f2dca02cb899873de54e9a2368df43ae69;p=thirdparty%2Fsystemd.git cryptsetup: minor coding style tweaks Don't cram function calls and assignment into if condition checks. It's not how we usually do things. Also, define variables at innermost scope. --- diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 73e148ee67a..023ea12ab1e 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -554,14 +554,15 @@ static int parse_one_option(const char *option) { } else if ((val = startswith(option, "link-volume-key="))) { #ifdef HAVE_CRYPT_SET_KEYRING_TO_LINK - const char *sep, *c; _cleanup_free_ char *keyring = NULL, *key_type = NULL, *key_description = NULL; + const char *sep; /* Stick with cryptsetup --link-vk-to-keyring format * ::%:, * where % is optional and defaults to 'user'. */ - if (!(sep = strstr(val, "::"))) + sep = strstr(val, "::"); + if (!sep) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse link-volume-key= option value: %s", val); /* cryptsetup (cli) supports passed in various formats: @@ -582,7 +583,8 @@ static int parse_one_option(const char *option) { /* % is optional (and defaults to 'user') */ if (*sep == '%') { /* must be separated by colon */ - if (!(c = strchr(sep, ':'))) + const char *c = strchr(sep, ':'); + if (!c) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse link-volume-key= option value: %s", val); key_type = strndup(sep + 1, c - sep - 1);