mirror of
https://github.com/systemd/systemd
synced 2024-10-01 13:55:20 +00:00
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.
This commit is contained in:
parent
82f57401d9
commit
50df39f2dc
|
@ -554,14 +554,15 @@ static int parse_one_option(const char *option) {
|
||||||
|
|
||||||
} else if ((val = startswith(option, "link-volume-key="))) {
|
} else if ((val = startswith(option, "link-volume-key="))) {
|
||||||
#ifdef HAVE_CRYPT_SET_KEYRING_TO_LINK
|
#ifdef HAVE_CRYPT_SET_KEYRING_TO_LINK
|
||||||
const char *sep, *c;
|
|
||||||
_cleanup_free_ char *keyring = NULL, *key_type = NULL, *key_description = NULL;
|
_cleanup_free_ char *keyring = NULL, *key_type = NULL, *key_description = NULL;
|
||||||
|
const char *sep;
|
||||||
|
|
||||||
/* Stick with cryptsetup --link-vk-to-keyring format
|
/* Stick with cryptsetup --link-vk-to-keyring format
|
||||||
* <keyring_description>::%<key_type>:<key_description>,
|
* <keyring_description>::%<key_type>:<key_description>,
|
||||||
* where %<key_type> is optional and defaults to 'user'.
|
* where %<key_type> 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);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to parse link-volume-key= option value: %s", val);
|
||||||
|
|
||||||
/* cryptsetup (cli) supports <keyring_description> passed in various formats:
|
/* cryptsetup (cli) supports <keyring_description> passed in various formats:
|
||||||
|
@ -582,7 +583,8 @@ static int parse_one_option(const char *option) {
|
||||||
/* %<key_type> is optional (and defaults to 'user') */
|
/* %<key_type> is optional (and defaults to 'user') */
|
||||||
if (*sep == '%') {
|
if (*sep == '%') {
|
||||||
/* must be separated by colon */
|
/* 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);
|
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);
|
key_type = strndup(sep + 1, c - sep - 1);
|
||||||
|
|
Loading…
Reference in a new issue