[PATCH] fwts_tpm: make function args and a variable const
Colin King
colin.king at canonical.com
Sun Apr 11 13:51:01 UTC 2021
From: Colin Ian King <colin.king at canonical.com>
Make read-only function arguments and a variable const
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/lib/include/fwts_tpm.h | 5 +++--
src/lib/src/fwts_tpm.c | 10 +++++++---
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/lib/include/fwts_tpm.h b/src/lib/include/fwts_tpm.h
index 08ed52c1..ca96f971 100644
--- a/src/lib/include/fwts_tpm.h
+++ b/src/lib/include/fwts_tpm.h
@@ -167,8 +167,9 @@ typedef struct {
*/
} __attribute__ ((packed)) fwts_tcg_pcr_event2;
-void fwts_tpm_data_hexdump(fwts_framework *fw, uint8_t *data, size_t size, char *str);
-uint8_t fwts_tpm_get_hash_size(TPM2_ALG_ID hash);
+void fwts_tpm_data_hexdump(fwts_framework *fw, const uint8_t *data,
+ const size_t size, const char *str);
+uint8_t fwts_tpm_get_hash_size(const TPM2_ALG_ID hash);
PRAGMA_POP
diff --git a/src/lib/src/fwts_tpm.c b/src/lib/src/fwts_tpm.c
index c3c88dac..b79c200c 100644
--- a/src/lib/src/fwts_tpm.c
+++ b/src/lib/src/fwts_tpm.c
@@ -24,14 +24,18 @@
* fwts_tpm_data_hexdump
* hex dump of a tpm event log data
*/
-void fwts_tpm_data_hexdump(fwts_framework *fw, uint8_t *data, size_t size, char *str)
+void fwts_tpm_data_hexdump(
+ fwts_framework *fw,
+ const uint8_t *data,
+ const size_t size,
+ const char *str)
{
size_t i;
fwts_log_info_verbatim(fw, "%s: ", str);
for (i = 0; i < size; i += 16) {
char buffer[128];
- size_t left = size - i;
+ const size_t left = size - i;
fwts_dump_raw_data(buffer, sizeof(buffer), data + i, i, left > 16 ? 16 : left);
fwts_log_info_verbatim(fw, "%s", buffer + 2);
@@ -42,7 +46,7 @@ void fwts_tpm_data_hexdump(fwts_framework *fw, uint8_t *data, size_t size, char
* fwts_tpm_evlog_type_to_string
* get hash size
*/
-uint8_t fwts_tpm_get_hash_size (TPM2_ALG_ID hash)
+uint8_t fwts_tpm_get_hash_size(const TPM2_ALG_ID hash)
{
uint8_t sz;
--
2.30.2
More information about the fwts-devel
mailing list