systemd/0523-tpm2-rename-pcr_values...

88 lines
3.4 KiB
Diff

From 9c49d0b64ff66bf4d8199abf7989c0a50bb79757 Mon Sep 17 00:00:00 2001
From: Dan Streetman <ddstreet@ieee.org>
Date: Thu, 11 May 2023 15:33:31 -0400
Subject: [PATCH] tpm2: rename pcr_values_size vars to n_pcr_values
Using the n_ prefix is more appropriate/conventional than the _size suffix.
No functional change, this is cosmetic only.
(cherry picked from commit c648a4b85e9ef71098afba3c7ac36a31f9372a4d)
Related: RHEL-16182
---
src/shared/tpm2-util.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index 629e1bc5ce..a6fab45898 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -1019,11 +1019,11 @@ static int tpm2_pcr_read(
const TPML_PCR_SELECTION *pcr_selection,
TPML_PCR_SELECTION *ret_pcr_selection,
TPM2B_DIGEST **ret_pcr_values,
- size_t *ret_pcr_values_size) {
+ size_t *ret_n_pcr_values) {
_cleanup_free_ TPM2B_DIGEST *pcr_values = NULL;
TPML_PCR_SELECTION remaining, total_read = {};
- size_t pcr_values_size = 0;
+ size_t n_pcr_values = 0;
TSS2_RC rc;
assert(c);
@@ -1058,12 +1058,12 @@ static int tpm2_pcr_read(
tpm2_tpml_pcr_selection_sub(&remaining, current_read);
tpm2_tpml_pcr_selection_add(&total_read, current_read);
- if (!GREEDY_REALLOC(pcr_values, pcr_values_size + current_values->count))
+ if (!GREEDY_REALLOC(pcr_values, n_pcr_values + current_values->count))
return log_oom();
- memcpy_safe(&pcr_values[pcr_values_size], current_values->digests,
+ memcpy_safe(&pcr_values[n_pcr_values], current_values->digests,
current_values->count * sizeof(TPM2B_DIGEST));
- pcr_values_size += current_values->count;
+ n_pcr_values += current_values->count;
if (DEBUG_LOGGING) {
unsigned i = 0;
@@ -1086,8 +1086,8 @@ static int tpm2_pcr_read(
*ret_pcr_selection = total_read;
if (ret_pcr_values)
*ret_pcr_values = TAKE_PTR(pcr_values);
- if (ret_pcr_values_size)
- *ret_pcr_values_size = pcr_values_size;
+ if (ret_n_pcr_values)
+ *ret_n_pcr_values = n_pcr_values;
return 0;
}
@@ -1099,7 +1099,7 @@ static int tpm2_pcr_mask_good(
_cleanup_free_ TPM2B_DIGEST *pcr_values = NULL;
TPML_PCR_SELECTION selection;
- size_t pcr_values_size = 0;
+ size_t n_pcr_values = 0;
int r;
assert(c);
@@ -1110,14 +1110,14 @@ static int tpm2_pcr_mask_good(
tpm2_tpml_pcr_selection_from_mask(mask, bank, &selection);
- r = tpm2_pcr_read(c, &selection, &selection, &pcr_values, &pcr_values_size);
+ r = tpm2_pcr_read(c, &selection, &selection, &pcr_values, &n_pcr_values);
if (r < 0)
return r;
/* If at least one of the selected PCR values is something other than all 0x00 or all 0xFF we are happy. */
unsigned i = 0;
FOREACH_PCR_IN_TPML_PCR_SELECTION(pcr, s, &selection) {
- assert(i < pcr_values_size);
+ assert(i < n_pcr_values);
if (!memeqbyte(0x00, pcr_values[i].buffer, pcr_values[i].size) &&
!memeqbyte(0xFF, pcr_values[i].buffer, pcr_values[i].size))