From: Zbigniew Jędrzejewski-Szmek Date: Wed, 31 Mar 2021 16:07:57 +0000 (+0200) Subject: cryptsetup: silence gcc maybe-unused warning X-Git-Tag: v249-rc1~490^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c26f7dd9f0098e7528619588bc940119d331001e;p=thirdparty%2Fsystemd.git cryptsetup: silence gcc maybe-unused warning Simplify one debug stmt while at it. --- diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 5c55dcd1975..ee31400e3f7 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -1008,7 +1008,7 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2( _cleanup_(sd_event_unrefp) sd_event *event = NULL; _cleanup_free_ char *friendly = NULL; int keyslot = arg_key_slot, r; - size_t decrypted_key_size; + size_t decrypted_key_size = 0; /* Silence gcc warning about unitialized variable */ assert(cd); assert(name); @@ -1058,15 +1058,12 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2( &policy_hash, &policy_hash_size, &keyslot, &token); - if (r == -ENXIO) { + if (r == -ENXIO) /* No further TPM2 tokens found in the LUKS2 header.*/ - if (found_some) - return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN), - "No TPM2 metadata matching the current system state found in LUKS2 header, falling back to traditional unlocking."); - else - return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN), - "No TPM2 metadata enrolled in LUKS2 header, falling back to traditional unlocking."); - } + return log_debug_errno(SYNTHETIC_ERRNO(EAGAIN), + found_some + ? "No TPM2 metadata matching the current system state found in LUKS2 header, falling back to traditional unlocking." + : "No TPM2 metadata enrolled in LUKS2 header, falling back to traditional unlocking."); if (r < 0) return r; @@ -1091,6 +1088,7 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2( if (r != -EAGAIN) /* EAGAIN means: no tpm2 chip found */ return r; } + assert(decrypted_key); if (!monitor) { /* We didn't find the TPM2 device. In this case, watch for it via udev. Let's create