From: Lennart Poettering Date: Fri, 8 Oct 2021 14:58:42 +0000 (+0200) Subject: homed: use crypt_token_max() where appropriate X-Git-Tag: v250-rc1~543^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e7e30330ff9fe0c2df3debe8cdf89bf6f5ed1bfd;p=thirdparty%2Fsystemd.git homed: use crypt_token_max() where appropriate Let's use the new crypt_token_max() API in systemd-homework too, to cut iteration of tokens short. We already use it in cryptenroll/cryptsetup, so let's use it here too. --- diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c index 8af9223d57a..b7162187166 100644 --- a/src/home/homework-luks.c +++ b/src/home/homework-luks.c @@ -698,7 +698,7 @@ static int luks_validate_home_record( assert(cd); assert(h); - for (int token = 0;; token++) { + for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *rr = NULL; _cleanup_(EVP_CIPHER_CTX_freep) EVP_CIPHER_CTX *context = NULL; _cleanup_(user_record_unrefp) UserRecord *lhr = NULL; @@ -894,7 +894,7 @@ int home_store_header_identity_luks( _cleanup_(user_record_unrefp) UserRecord *header_home = NULL; _cleanup_free_ char *text = NULL; - int token = 0, r; + int r; assert(h); @@ -924,7 +924,7 @@ int home_store_header_identity_luks( if (r < 0) return r; - for (;; token++) { + for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) { crypt_token_info state; const char *type;