From 2e4b1f78505513c333532755a715bce0f5ad3c99 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 28 May 2024 11:52:04 +0200 Subject: [PATCH] tpm: Do not use fprintf for logging. * tpm2d/intel-tss.h (TSS_Create): Replace fprintf logging by log_error. --- tpm2d/intel-tss.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tpm2d/intel-tss.h b/tpm2d/intel-tss.h index 53da5cee2..1649cca05 100644 --- a/tpm2d/intel-tss.h +++ b/tpm2d/intel-tss.h @@ -300,7 +300,7 @@ TSS_Create(TSS_CONTEXT **tssContext) } else { - fprintf(stderr, "Unknown TPM_INTERFACE_TYPE %s\n", intType); + log_error ("tss: Unknown TPM_INTERFACE_TYPE %s\n", intType); } } @@ -352,15 +352,15 @@ TSS_Hash_Generate(TPMT_HA *digest, ...) rc = TSS_Hash_GetMd(&algo, digest->hashAlg); if (rc) { - fprintf(stderr, "TSS_HASH_GENERATE: Unknown hash %d\n", - digest->hashAlg); + log_error ("TSS_Hash_Generate: Unknown hash %d\n", digest->hashAlg); goto out; } rc = gcry_md_open (&md, algo, 0); if (rc != 0) { - fprintf(stderr, "TSS_Hash_Generate: EVP_MD_CTX_create failed\n"); + log_error ("TSS_Hash_Generate: EVP_MD_CTX_create failed: %s\n", + gpg_strerror (rc)); rc = TPM_RC_FAILURE; goto out; } @@ -374,7 +374,7 @@ TSS_Hash_Generate(TPMT_HA *digest, ...) break; if (length < 0) { - fprintf(stderr, "TSS_Hash_Generate: Length is negative\n"); + log_error ("TSS_Hash_Generate: Length is negative\n"); goto out_free; } if (length != 0) @@ -408,9 +408,8 @@ tpm2_error(TPM_RC rc, const char *reason) { const char *msg; - fprintf(stderr, "%s failed with %d\n", reason, rc); msg = Tss2_RC_Decode(rc); - fprintf(stderr, "%s\n", msg); + log_error ("%s failed with error %d (%s)\n", reason, rc, msg); } static inline int