]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Fix compilation warning when tpm2 is disabled
authorKrzesimir Nowak <knowak@microsoft.com>
Wed, 15 Nov 2023 16:39:10 +0000 (17:39 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 15 Nov 2023 19:55:50 +0000 (19:55 +0000)
The warning is about unused variable "flags":

```
../src/partition/repart.c: In function ‘partition_encrypt’:
../src/partition/repart.c:3690:19: warning: unused variable ‘flags’ [-Wunused-variable]
 3690 |         TPM2Flags flags = 0;
      |                   ^~~~~
```

Move the flags variable into the scope where it is actually used, which happens
to be inside the HAVE_TPM2 block.

src/partition/repart.c

index 88d4c5186db5fef6aa7de1f723c586ee0e163bc7..654b931c1920bc2d6d0b2b2f139bb765101edfb9 100644 (file)
@@ -3687,7 +3687,6 @@ static int partition_encrypt(Context *context, Partition *p, PartitionTarget *ta
         _cleanup_free_ char *hp = NULL, *vol = NULL, *dm_name = NULL;
         const char *passphrase = NULL;
         size_t passphrase_size = 0;
-        TPM2Flags flags = 0;
         const char *vt;
         int r;
 
@@ -3782,6 +3781,7 @@ static int partition_encrypt(Context *context, Partition *p, PartitionTarget *ta
                 size_t secret_size, blob_size, pubkey_size = 0, srk_buf_size = 0;
                 ssize_t base64_encoded_size;
                 int keyslot;
+                TPM2Flags flags = 0;
 
                 if (arg_tpm2_public_key_pcr_mask != 0) {
                         r = tpm2_load_pcr_public_key(arg_tpm2_public_key, &pubkey, &pubkey_size);