From patchwork Sun Apr 11 13:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1464859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FJCvH2tyHz9sX1 for ; Sun, 11 Apr 2021 23:51:06 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lVaUR-00041Q-8s; Sun, 11 Apr 2021 13:51:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lVaUQ-00041C-0r for fwts-devel@lists.ubuntu.com; Sun, 11 Apr 2021 13:51:02 +0000 Received: from cpc154979-craw9-2-0-cust193.16-3.cable.virginm.net ([80.193.200.194] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lVaUP-0002vW-Nv; Sun, 11 Apr 2021 13:51:01 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] fwts_tpm: make function args and a variable const Date: Sun, 11 Apr 2021 14:51:01 +0100 Message-Id: <20210411135101.1204045-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King Make read-only function arguments and a variable const Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- 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;