keymaster:log: Fix log format strings & remove empty param.

Bug: 279488041
Test: build.py qemu-generic-arm32-test-debug
Test: build.py qemu-generic-arm64-test-debug
Change-Id: I930af5a549ed8336b9fea2504899a0a06ba50adc
diff --git a/atap/trusty_atap_ops.cpp b/atap/trusty_atap_ops.cpp
index b44a855..efab067 100644
--- a/atap/trusty_atap_ops.cpp
+++ b/atap/trusty_atap_ops.cpp
@@ -96,7 +96,7 @@
     if (ss_manager->ReadProductId(product_id) != KM_ERROR_OK) {
         /* If we can't get permanent attributes, set product id to the test
         product id (all zero). */
-        LOG_E("Fail to read product id from storage, set as 0.", 0);
+        LOG_E("Fail to read product id from storage, set as 0.");
         memset(product_id, 0, ATAP_PRODUCT_ID_LEN);
     }
     return ATAP_RESULT_OK;
@@ -137,7 +137,7 @@
     AtapKeyType key_type;
     AtapResult atap_result = get_auth_key_type(&key_type);
     if (atap_result != ATAP_RESULT_OK) {
-        LOG_E("Failed to get key type.", 0);
+        LOG_E("Failed to get key type.");
         return atap_result;
     }
     if (key_type == ATAP_KEY_TYPE_NONE) {
@@ -156,8 +156,7 @@
         return ATAP_RESULT_ERROR_STORAGE;
     }
     if (cert_chain->entry_count > ATAP_CERT_CHAIN_ENTRIES_MAX) {
-        LOG_E("Stored cert chain length is larger than the maximum cert chain length",
-              0);
+        LOG_E("Stored cert chain length is larger than the maximum cert chain length");
         return ATAP_RESULT_ERROR_CRYPTO;
     }
     return ATAP_RESULT_OK;
@@ -223,7 +222,7 @@
     keymaster_error_t result = KM_ERROR_OK;
     AtapResult atap_result = get_auth_key_type(&key_type);
     if (atap_result != ATAP_RESULT_OK) {
-        LOG_E("Failed to get key type", 0);
+        LOG_E("Failed to get key type");
         return atap_result;
     }
     if (key_type == ATAP_KEY_TYPE_NONE) {
@@ -248,19 +247,19 @@
     Unique_PKCS8_PRIV_KEY_INFO pkcs8(d2i_PKCS8_PRIV_KEY_INFO(
             NULL, &pkcs_priv_key_p, key_blob.key_material_size));
     if (!pkcs8.get()) {
-        LOG_E("Error parsing pkcs8 format private key.", 0);
+        LOG_E("Error parsing pkcs8 format private key.");
         return ATAP_RESULT_ERROR_INVALID_INPUT;
     }
     Unique_EVP_PKEY pkey(EVP_PKCS82PKEY(pkcs8.get()));
     if (!pkey.get()) {
-        LOG_E("Error parsing pkcs8 private key to EVP_PKEY.", 0);
+        LOG_E("Error parsing pkcs8 private key to EVP_PKEY.");
         return ATAP_RESULT_ERROR_INVALID_INPUT;
     }
 
     Unique_EVP_MD_CTX mdctx(EVP_MD_CTX_create());
 
     if (!mdctx.get()) {
-        LOG_E("Error creating md ctx.", 0);
+        LOG_E("Error creating md ctx.");
         return ATAP_RESULT_ERROR_OOM;
     }
     EVP_PKEY_CTX* evp_pkey_ctx;
@@ -282,8 +281,7 @@
         return ATAP_RESULT_ERROR_CRYPTO;
     }
     if (local_sig_len > ATAP_SIGNATURE_LEN_MAX) {
-        LOG_E("Signature length larger than the supported maximum signature length.",
-              0);
+        LOG_E("Signature length larger than the supported maximum signature length.");
         return ATAP_RESULT_ERROR_INVALID_INPUT;
     }
     /* Obtain the signature */
diff --git a/ipc/keymaster_ipc.cpp b/ipc/keymaster_ipc.cpp
index 400750d..5a01f5c 100644
--- a/ipc/keymaster_ipc.cpp
+++ b/ipc/keymaster_ipc.cpp
@@ -94,7 +94,7 @@
 
     rc = wait(session, &ev, INFINITE_TIME);
     if (rc < 0) {
-        LOG_E("failed to wait for outgoing queue to free up\n", 0);
+        LOG_E("failed to wait for outgoing queue to free up");
         return rc;
     }
 
@@ -140,7 +140,7 @@
 
         // fatal error
         if (rc < 0) {
-            LOG_E("failed (%d) to send_msg for chan (%d)", rc, chan);
+            LOG_E("failed (%ld) to send_msg for chan (%d)", rc, chan);
             return rc;
         }
         bytes_remaining -= msg_size;
@@ -214,7 +214,7 @@
     err = serialize_response(rsp, out, out_size);
     LOG_D("do_dispatch #1: serialized response, %d bytes", *out_size);
     if (err != NO_ERROR) {
-        LOG_E("Error serializing response: %d", err);
+        LOG_E("Error serializing response: %ld", err);
     }
 
     return err;
@@ -248,7 +248,7 @@
     err = serialize_response(rsp, out, out_size);
     LOG_D("do_dispatch #2: serialized response, %d bytes", *out_size);
     if (err != NO_ERROR) {
-        LOG_E("Error serializing response: %d", err);
+        LOG_E("Error serializing response: %ld", err);
     }
 
     return err;
@@ -275,7 +275,7 @@
     err = serialize_response(rsp, out, out_size);
     LOG_D("do_dispatch #3: serialized response, %d bytes", *out_size);
     if (err != NO_ERROR) {
-        LOG_E("Error serializing response: %d", err);
+        LOG_E("Error serializing response: %ld", err);
     }
 
     return err;
@@ -404,7 +404,7 @@
         }
     } else if (device->ConfigureCalled()) {
         if (device->get_configure_error() != KM_ERROR_OK) {
-            LOG_E("Previous configure command failed\n", 0);
+            LOG_E("Previous configure command failed\n");
             return ERR_NOT_CONFIGURED;
         } else if (cmd_is_from_bootloader(msg->cmd)) {
             LOG_E("Bootloader command %d not allowed after configure command\n",
@@ -624,7 +624,7 @@
 
     case KM_DESTROY_ATTESTATION_IDS:
         // TODO(swillden): Implement this.
-        LOG_E("Destroy attestation IDs is unimplemented.", 0);
+        LOG_E("Destroy attestation IDs is unimplemented.");
         return ERR_NOT_IMPLEMENTED;
 
     case KM_EARLY_BOOT_ENDED:
@@ -687,7 +687,7 @@
                                               uuid_t* uuid,
                                               bool secure) {
     if (!keymaster_port_accessible(uuid, secure)) {
-        LOG_E("access denied for client uuid", 0);
+        LOG_E("access denied for client uuid");
         return NULL;
     }
 
@@ -745,13 +745,13 @@
 
     // fatal error
     if (rc < 0) {
-        LOG_E("failed to read msg (%d)", rc, chan);
+        LOG_E("failed to read msg (%d)", rc);
         return rc;
     }
     LOG_D("Read %d-byte message", rc);
 
     if (((unsigned long)rc) < sizeof(keymaster_message)) {
-        LOG_E("invalid message of size (%d)", rc, chan);
+        LOG_E("invalid message of size (%d)", rc);
         return ERR_NOT_VALID;
     }
 
@@ -795,7 +795,7 @@
         long rc = handle_msg(ctx);
         if (rc != NO_ERROR) {
             /* report an error and close channel */
-            LOG_E("failed (%d) to handle event on channel %d", rc, ev->handle);
+            LOG_E("failed (%ld) to handle event on channel %d", rc, ev->handle);
             keymaster_ctx_close(ctx);
             return;
         }
@@ -856,7 +856,7 @@
 
     if (ev->event == IPC_HANDLE_POLL_NONE) {
         /* not really an event, do nothing */
-        LOG_E("got an empty event", 0);
+        LOG_E("got an empty event");
         return;
     }
 
@@ -927,20 +927,20 @@
 
     TrustyLogger::initialize();
 
-    LOG_I("Initializing", 0);
+    LOG_I("Initializing");
 
     // Run the BoringSSL self-tests
     if (!BORINGSSL_self_test()) {
-        LOG_E("BoringSSL self-test: FAILED", 0);
+        LOG_E("BoringSSL self-test: FAILED");
         return ERR_GENERIC;
     } else {
-        LOG_I("BoringSSL self-test: PASSED", 0);
+        LOG_I("BoringSSL self-test: PASSED");
     }
 
     keymaster_srv_ctx ctx;
     rc = keymaster_ipc_init(&ctx);
     if (rc < 0) {
-        LOG_E("failed (%d) to initialize keymaster", rc);
+        LOG_E("failed (%ld) to initialize keymaster", rc);
         return rc;
     }
 
@@ -952,7 +952,7 @@
 
         rc = wait_any(&event, INFINITE_TIME);
         if (rc < 0) {
-            LOG_E("wait_any failed (%d)", rc);
+            LOG_E("wait_any failed (%ld)", rc);
             break;
         }
 
diff --git a/openssl_keymaster_enforcement.cpp b/openssl_keymaster_enforcement.cpp
index ed9ed72..f24a9f8 100644
--- a/openssl_keymaster_enforcement.cpp
+++ b/openssl_keymaster_enforcement.cpp
@@ -18,6 +18,7 @@
 #include "openssl_keymaster_enforcement.h"
 
 #include <assert.h>
+#include <inttypes.h>
 #include <utility>
 
 #include <openssl/cmac.h>
@@ -248,12 +249,12 @@
     hwkey_close(hwkey_session);
 
     if (rc < 0) {
-        LOG_E("Getting KAK failed.\n", 0);
+        LOG_E("Getting KAK failed.\n");
         return KM_ERROR_SECURE_HW_COMMUNICATION_FAILED;
     }
 
     if (keySize != kKeyAgreementKeySize) {
-        LOG_E("KAK has the wrong size: %zu != %zu.\n", keySize,
+        LOG_E("KAK has the wrong size: %" PRIu32 " != %zu.\n", keySize,
               kKeyAgreementKeySize);
         return KM_ERROR_SECURE_HW_COMMUNICATION_FAILED;
     }
diff --git a/secure_storage_manager.cpp b/secure_storage_manager.cpp
index 2dac754..41d63c3 100644
--- a/secure_storage_manager.cpp
+++ b/secure_storage_manager.cpp
@@ -108,7 +108,7 @@
     if (instance.session_handle_ != STORAGE_INVALID_SESSION) {
         int rc = storage_end_transaction(instance.session_handle_, false);
         if (rc < 0) {
-            LOG_E("Error: existing session is stale.", 0);
+            LOG_E("Error: existing session is stale.");
             storage_close_session(instance.session_handle_);
             instance.session_handle_ = STORAGE_INVALID_SESSION;
         }
@@ -123,7 +123,7 @@
     if (translate_format && instance.legacy_format) {
         keymaster_error_t err = instance.TranslateLegacyFormat();
         if (err != KM_ERROR_OK) {
-            LOG_E("Failed to translate legacy file format!", 0);
+            LOG_E("Failed to translate legacy file format!");
             instance.CloseSession();
             return nullptr;
         } else {
@@ -485,7 +485,7 @@
     UniquePtr<KeymasterAttributes> km_attributes(km_attributes_p);
 #ifndef KEYMASTER_DEBUG
     if (km_attributes->has_product_id) {
-        LOG_E("Error: Product ID already set!\n", 0);
+        LOG_E("Error: Product ID already set!\n");
         return KM_ERROR_INVALID_ARGUMENT;
     }
 #endif /* KEYMASTER_DEBUG */
@@ -532,7 +532,7 @@
     }
     UniquePtr<AttestationIds> attestation_ids(attestation_ids_p);
     if (request.brand.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: Brand ID too large: %d", request.brand.buffer_size());
+        LOG_E("Error: Brand ID too large: %zu", request.brand.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.brand.buffer_size() > 0) {
         attestation_ids->has_brand = true;
@@ -542,7 +542,7 @@
     }
 
     if (request.device.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: Device ID too large: %d", request.device.buffer_size());
+        LOG_E("Error: Device ID too large: %zu", request.device.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.device.buffer_size() > 0) {
         attestation_ids->has_device = true;
@@ -552,7 +552,8 @@
     }
 
     if (request.product.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: Product ID too large: %d", request.product.buffer_size());
+        LOG_E("Error: Product ID too large: %zu",
+              request.product.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.product.buffer_size() > 0) {
         attestation_ids->has_product = true;
@@ -562,7 +563,7 @@
     }
 
     if (request.serial.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: Serial number too large: %d",
+        LOG_E("Error: Serial number too large: %zu",
               request.serial.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.serial.buffer_size() > 0) {
@@ -573,7 +574,7 @@
     }
 
     if (request.imei.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: IMEI ID too large: %d", request.imei.buffer_size());
+        LOG_E("Error: IMEI ID too large: %zu", request.imei.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.imei.buffer_size() > 0) {
         attestation_ids->has_imei = true;
@@ -583,7 +584,7 @@
     }
 
     if (request.meid.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: MEID ID too large: %d", request.meid.buffer_size());
+        LOG_E("Error: MEID ID too large: %zu", request.meid.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.meid.buffer_size() > 0) {
         attestation_ids->has_meid = true;
@@ -593,7 +594,7 @@
     }
 
     if (request.manufacturer.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: Manufacturer ID too large: %d",
+        LOG_E("Error: Manufacturer ID too large: %zu",
               request.manufacturer.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.manufacturer.buffer_size() > 0) {
@@ -605,7 +606,7 @@
     }
 
     if (request.model.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: Model ID too large: %d", request.model.buffer_size());
+        LOG_E("Error: Model ID too large: %zu", request.model.buffer_size());
         return {KM_ERROR_INVALID_ARGUMENT, nullptr};
     } else if (request.model.buffer_size() > 0) {
         attestation_ids->has_model = true;
@@ -623,7 +624,7 @@
         return result.error;
     }
     if (request.second_imei.buffer_size() > kAttestationIdLengthMax) {
-        LOG_E("Error: Second IMEI ID too large: %d",
+        LOG_E("Error: Second IMEI ID too large: %zu",
               request.second_imei.buffer_size());
         return KM_ERROR_INVALID_ARGUMENT;
     } else if (request.second_imei.buffer_size() > 0) {
@@ -700,7 +701,7 @@
     }
     int rc = storage_end_transaction(session_handle_, true);
     if (rc < 0) {
-        LOG_E("Error: failed to commit transaction while deleting keys.", 0);
+        LOG_E("Error: failed to commit transaction while deleting keys.");
         CloseSession();
         return KM_ERROR_SECURE_HW_COMMUNICATION_FAILED;
     }
@@ -974,8 +975,7 @@
     rc = storage_end_transaction(session_handle_, STORAGE_OP_COMPLETE);
     if (rc < 0) {
         LOG_E("Error: failed to commit write transaction to translate file"
-              " format.\n",
-              0);
+              " format.\n");
         return KM_ERROR_SECURE_HW_COMMUNICATION_FAILED;
     }
     return KM_ERROR_OK;
diff --git a/trusty_aes_key.cpp b/trusty_aes_key.cpp
index 916bd5e..ffab35e 100644
--- a/trusty_aes_key.cpp
+++ b/trusty_aes_key.cpp
@@ -73,13 +73,13 @@
     // block mode tag effectively achieves that.
     //
     if (key_description.find(TAG_BLOCK_MODE) != -1) {
-        LOG_E("HWWSK: unsupported tag (%u)", TAG_BLOCK_MODE);
+        LOG_E("HWWSK: unsupported tag");
         return KM_ERROR_UNSUPPORTED_TAG;
     }
 
     // Get requested key size
     if (!key_description.GetTagValue(TAG_KEY_SIZE, &key_size)) {
-        LOG_E("HWWSK: missing key size tag", 0);
+        LOG_E("HWWSK: missing key size tag");
         return KM_ERROR_UNSUPPORTED_KEY_SIZE;
     }
 
diff --git a/trusty_keymaster.cpp b/trusty_keymaster.cpp
index 1e06a3b..1c87ed6 100644
--- a/trusty_keymaster.cpp
+++ b/trusty_keymaster.cpp
@@ -203,7 +203,7 @@
 
     keymaster_error_t err = ss_manager->DeleteCertChainFromStorage(key_slot);
     if (err != KM_ERROR_OK) {
-        LOG_E("Failed to delete cert chain.\n", 0);
+        LOG_E("Failed to delete cert chain.\n");
         response->error = err;
         return;
     }
@@ -211,12 +211,12 @@
     uint32_t cert_chain_length = 0;
     err = ss_manager->ReadCertChainLength(key_slot, &cert_chain_length);
     if (err != KM_ERROR_OK) {
-        LOG_E("Failed to read cert chain length.\n", 0);
+        LOG_E("Failed to read cert chain length.\n");
         response->error = err;
         return;
     }
     if (cert_chain_length != 0) {
-        LOG_E("Cert chain could not be deleted.\n", 0);
+        LOG_E("Cert chain could not be deleted.\n");
         response->error = err;
         return;
     }
@@ -258,7 +258,7 @@
     uint32_t cert_chain_length = 0;
     if (ss_manager->ReadCertChainLength(key_slot, &cert_chain_length) !=
         KM_ERROR_OK) {
-        LOG_E("Failed to read cert chain length, initialize to 0.\n", 0);
+        LOG_E("Failed to read cert chain length, initialize to 0.\n");
         cert_chain_length = 0;
     }
     response->error = ss_manager->WriteCertToStorage(key_slot, cert, cert_size,
@@ -350,7 +350,7 @@
 #else
     response->error = KM_ERROR_INVALID_INPUT_LENGTH;
     if (ca_response_.available_read() != ca_response_.buffer_size()) {
-        LOG_E("Did not receive full CA Response message: %d / %d\n",
+        LOG_E("Did not receive full CA Response message: %zu / %zu\n",
               ca_response_.available_read(), ca_response_.buffer_size());
         return;
     }
diff --git a/trusty_keymaster.h b/trusty_keymaster.h
index bb7351c..14d92f6 100644
--- a/trusty_keymaster.h
+++ b/trusty_keymaster.h
@@ -38,7 +38,7 @@
                     size_t operation_table_size)
             : AndroidKeymaster(context, operation_table_size),
               context_(context) {
-        LOG_D("Creating TrustyKeymaster", 0);
+        LOG_D("Creating TrustyKeymaster");
     }
 
     // Replace GetVersion2 handler from AndroidKeymaster.  It's not virtual, but
diff --git a/trusty_keymaster_context.cpp b/trusty_keymaster_context.cpp
index 6c1f984..70ac6d8 100644
--- a/trusty_keymaster_context.cpp
+++ b/trusty_keymaster_context.cpp
@@ -106,7 +106,7 @@
           secure_deletion_secret_storage_(*this /* random_source */),
           rng_initialized_(false),
           calls_since_reseed_(0) {
-    LOG_D("Creating TrustyKeymaster", 0);
+    LOG_D("Creating TrustyKeymaster");
     rsa_factory_.reset(new (std::nothrow) RsaKeyFactory(*this /* blob_maker */,
                                                         *this /* context */));
     tdes_factory_.reset(new (std::nothrow) TripleDesKeyFactory(
@@ -373,7 +373,7 @@
         EncryptedKey* info) const {
     long rc = hwkey_open();
     if (rc < 0) {
-        LOG_S("Error failing to open a connection to hwkey: %d", rc);
+        LOG_S("Error failing to open a connection to hwkey: %ld", rc);
         return KM_ERROR_UNKNOWN_ERROR;
     }
 
@@ -390,7 +390,7 @@
     };
     rc = hwkey_derive_versioned(session, &opt);
     if (rc < 0) {
-        LOG_S("Error deriving versioned master key: %d", rc);
+        LOG_S("Error deriving versioned master key: %ld", rc);
         hwkey_close(session);
         return KM_ERROR_UNKNOWN_ERROR;
     }
@@ -488,7 +488,7 @@
     bool request_secure_deletion =
             request_rollback_resistance || request_usage_limit;
 
-    LOG_D("Getting secure deletion data", 0);
+    LOG_D("Getting secure deletion data");
     std::optional<SecureDeletionData> sdd;
     if (kUseSecureDeletion) {
         sdd = secure_deletion_secret_storage_.CreateDataForNewKey(
@@ -501,9 +501,9 @@
               sdd->factory_reset_secret.buffer_size(),
               sdd->secure_deletion_secret.buffer_size(), sdd->key_slot);
     } else if (!kUseSecureDeletion) {
-        LOG_I("Not using secure deletion", 0);
+        LOG_I("Not using secure deletion");
     } else {
-        LOG_W("Failed to get secure deletion data. storageproxy not up?", 0);
+        LOG_W("Failed to get secure deletion data. storageproxy not up?");
     }
 
     uint32_t key_slot = sdd ? sdd->key_slot : 0;
@@ -545,7 +545,7 @@
     UniquePtr<Key> key;
     keymaster_error_t error =
             ParseKeyBlob(key_to_upgrade, upgrade_params, &key);
-    LOG_I("Upgrading key blob", 1);
+    LOG_I("Upgrading key blob");
     if (error != KM_ERROR_OK) {
         return error;
     }
@@ -590,8 +590,7 @@
     }
     if (!has_secure_deletion &&
         upgrade_params.Contains(TAG_ROLLBACK_RESISTANCE)) {
-        LOG_D("Upgrading non rollback-protected key, adding rollback protection",
-              0);
+        LOG_D("Upgrading non rollback-protected key, adding rollback protection");
         has_secure_deletion = true;
     }
 
@@ -649,7 +648,7 @@
                                  blob.size() - kKeystoreKeyBlobPrefixSize));
 
     case 1:
-        LOG_E("Software key blobs are not supported.", 0);
+        LOG_E("Software key blobs are not supported.");
         return KM_ERROR_INVALID_KEY_BLOB;
 
     default:
@@ -740,7 +739,7 @@
         const KeymasterKeyBlob& blob) const {
     KmErrorOr<DeserializedKey> deserialized_key = DeserializeKeyBlob(blob);
     if (deserialized_key) {
-        LOG_D("Deserialized blob with format: %d",
+        LOG_D("Deserialized blob with format: %u",
               deserialized_key->encrypted_key.format);
         secure_deletion_secret_storage_.DeleteKey(deserialized_key->key_slot);
     }
@@ -768,12 +767,12 @@
 
 bool TrustyKeymasterContext::ShouldReseedRng() const {
     if (!rng_initialized_) {
-        LOG_I("RNG not initalized, reseed", 0);
+        LOG_I("RNG not initialized, reseed");
         return true;
     }
 
     if (++calls_since_reseed_ % kCallsBetweenRngReseeds == 0) {
-        LOG_I("Periodic reseed", 0);
+        LOG_I("Periodic reseed");
         return true;
     }
     return false;
@@ -783,7 +782,7 @@
     uint8_t rand_seed[kRngReseedSize];
     memset(rand_seed, 0, kRngReseedSize);
     if (trusty_rng_hw_rand(rand_seed, kRngReseedSize) != 0) {
-        LOG_E("Failed to get bytes from HW RNG", 0);
+        LOG_E("Failed to get bytes from HW RNG");
         return false;
     }
     LOG_I("Reseeding with %d bytes from HW RNG", kRngReseedSize);
@@ -802,7 +801,7 @@
 keymaster_error_t TrustyKeymasterContext::DeriveMasterKey(
         KeymasterKeyBlob* master_key,
         const EncryptedKey& enc_key) const {
-    LOG_D("Deriving master key", 0);
+    LOG_D("Deriving master key");
 
     long rc = hwkey_open();
     if (rc < 0) {
@@ -812,7 +811,7 @@
     hwkey_session_t session = (hwkey_session_t)rc;
 
     if (!master_key->Reset(kAesKeySize)) {
-        LOG_S("Could not allocate memory for master key buffer", 0);
+        LOG_S("Could not allocate memory for master key buffer");
         hwkey_close(session);
         return KM_ERROR_MEMORY_ALLOCATION_FAILED;
     }
@@ -822,7 +821,7 @@
         rc = hwkey_derive(session, &kdf_version, kMasterKeyDerivationData,
                           master_key->writable_data(), kAesKeySize);
         if (rc < 0) {
-            LOG_S("Error deriving legacy master key: %d", rc);
+            LOG_S("Error deriving legacy master key: %ld", rc);
             hwkey_close(session);
             return KM_ERROR_UNKNOWN_ERROR;
         }
@@ -839,14 +838,14 @@
         };
         rc = hwkey_derive_versioned(session, &opt);
         if (rc < 0) {
-            LOG_S("Error deriving versioned master key: %d", rc);
+            LOG_S("Error deriving versioned master key: %ld", rc);
             hwkey_close(session);
             return KM_ERROR_UNKNOWN_ERROR;
         }
     }
 
     hwkey_close(session);
-    LOG_D("Key derivation complete", 0);
+    LOG_D("Key derivation complete");
     return KM_ERROR_OK;
 }
 
@@ -956,7 +955,7 @@
         AuthorizationSet* values_to_attest) const {
     SecureStorageManager* ss_manager = SecureStorageManager::get_instance();
     if (ss_manager == nullptr) {
-        LOG_E("Failed to open secure storage session.", 0);
+        LOG_E("Failed to open secure storage session.");
         return KM_ERROR_SECURE_HW_COMMUNICATION_FAILED;
     }
 
@@ -1020,7 +1019,7 @@
                 bool second_imei_mismatch =
                         !validate_second_imei(entry.blob, imei_numeric);
                 if (second_imei_mismatch) {
-                    LOG_E("Mismatch in second IMEI.", 0);
+                    LOG_E("Mismatch in second IMEI.");
                 }
                 found_mismatch |= second_imei_mismatch;
                 values_to_attest->push_back(entry);
@@ -1105,15 +1104,14 @@
 
     SecureStorageManager* ss_manager = SecureStorageManager::get_instance();
     if (ss_manager == nullptr) {
-        LOG_E("Failed to open secure storage session.", 0);
+        LOG_E("Failed to open secure storage session.");
         *error = KM_ERROR_SECURE_HW_COMMUNICATION_FAILED;
         return {};
     }
     auto result = ss_manager->ReadKeyFromStorage(key_slot, error);
 #if KEYMASTER_SOFT_ATTESTATION_FALLBACK
     if (*error != KM_ERROR_OK) {
-        LOG_I("Failed to read attestation key from RPMB, falling back to test key",
-              0);
+        LOG_I("Failed to read attestation key from RPMB, falling back to test key");
         auto key = getAttestationKey(algorithm, error);
         if (*error != KM_ERROR_OK) {
             LOG_D("Software attestation key missing: %d", *error);
@@ -1146,15 +1144,14 @@
     CertificateChain chain;
     SecureStorageManager* ss_manager = SecureStorageManager::get_instance();
     if (ss_manager == nullptr) {
-        LOG_E("Failed to open secure storage session.", 0);
+        LOG_E("Failed to open secure storage session.");
         *error = KM_ERROR_SECURE_HW_COMMUNICATION_FAILED;
     } else {
         *error = ss_manager->ReadCertChainFromStorage(key_slot, &chain);
     }
 #if KEYMASTER_SOFT_ATTESTATION_FALLBACK
     if ((*error != KM_ERROR_OK) || (chain.entry_count == 0)) {
-        LOG_I("Failed to read attestation chain from RPMB, falling back to test chain",
-              0);
+        LOG_I("Failed to read attestation chain from RPMB, falling back to test chain");
         chain = getAttestationChain(algorithm, error);
     }
 #endif
@@ -1262,7 +1259,7 @@
         AuthorizationSet* wrapped_key_params,
         keymaster_key_format_t* wrapped_key_format,
         KeymasterKeyBlob* wrapped_key_material) const {
-    LOG_D("UnwrapKey:0", 0);
+    LOG_D("UnwrapKey:0");
 
     keymaster_error_t error = KM_ERROR_OK;
 
@@ -1270,13 +1267,13 @@
         return KM_ERROR_UNEXPECTED_NULL_POINTER;
     }
 
-    LOG_D("UnwrapKey:1", 0);
+    LOG_D("UnwrapKey:1");
     // Step 1 from IKeymasterDevice.hal file spec
     // Parse wrapping key
     UniquePtr<Key> wrapping_key;
     error = ParseKeyBlob(wrapping_key_blob, wrapping_key_params, &wrapping_key);
     if (error != KM_ERROR_OK) {
-        LOG_E("Failed to parse wrapping key", 0);
+        LOG_E("Failed to parse wrapping key");
         return error;
     }
 
@@ -1285,32 +1282,32 @@
 
     // Check Wrapping Key Purpose
     if (!wrapping_key_auths.Contains(TAG_PURPOSE, KM_PURPOSE_WRAP)) {
-        LOG_E("Wrapping key did not have KM_PURPOSE_WRAP", 0);
+        LOG_E("Wrapping key did not have KM_PURPOSE_WRAP");
         return KM_ERROR_INCOMPATIBLE_PURPOSE;
     }
 
     // Check Padding mode is RSA_OAEP and digest is SHA_2_256 (spec
     // mandated)
     if (!wrapping_key_auths.Contains(TAG_DIGEST, KM_DIGEST_SHA_2_256)) {
-        LOG_E("Wrapping key lacks authorization for SHA2-256", 0);
+        LOG_E("Wrapping key lacks authorization for SHA2-256");
         return KM_ERROR_INCOMPATIBLE_DIGEST;
     }
     if (!wrapping_key_auths.Contains(TAG_PADDING, KM_PAD_RSA_OAEP)) {
-        LOG_E("Wrapping key lacks authorization for padding OAEP", 0);
+        LOG_E("Wrapping key lacks authorization for padding OAEP");
         return KM_ERROR_INCOMPATIBLE_PADDING_MODE;
     }
 
     // Check that that was also the padding mode and digest specified
     if (!wrapping_key_params.Contains(TAG_DIGEST, KM_DIGEST_SHA_2_256)) {
-        LOG_E("Wrapping key must use SHA2-256", 0);
+        LOG_E("Wrapping key must use SHA2-256");
         return KM_ERROR_INCOMPATIBLE_DIGEST;
     }
     if (!wrapping_key_params.Contains(TAG_PADDING, KM_PAD_RSA_OAEP)) {
-        LOG_E("Wrapping key must use OAEP padding", 0);
+        LOG_E("Wrapping key must use OAEP padding");
         return KM_ERROR_INCOMPATIBLE_PADDING_MODE;
     }
 
-    LOG_D("UnwrapKey:2", 0);
+    LOG_D("UnwrapKey:2");
     // Step 2 from IKeymasterDevice.hal spec
     // Parse wrapped key
     KeymasterBlob iv;
@@ -1364,7 +1361,7 @@
             output.available_read(),
     };
 
-    LOG_D("UnwrapKey:3", 0);
+    LOG_D("UnwrapKey:3");
     // Step 3 of IKeymasterDevice.hal
     // XOR the transit key with the masking key
     if (transport_key.key_material_size != masking_key.key_material_size) {
@@ -1374,7 +1371,7 @@
         transport_key.writable_data()[i] ^= masking_key.key_material[i];
     }
 
-    LOG_D("UnwrapKey:4", 0);
+    LOG_D("UnwrapKey:4");
     // Step 4 of IKeymasterDevice.hal
     // transit_key_authorizations is defined by spec
     // TODO the mac len is NOT in the spec, but probably should be
@@ -1493,7 +1490,7 @@
         return KM_ERROR_MEMORY_ALLOCATION_FAILED;
     }
 
-    LOG_D("UnwrapKey:Done", 0);
+    LOG_D("UnwrapKey:Done");
     return error;
 }
 
diff --git a/trusty_keymaster_enforcement.cpp b/trusty_keymaster_enforcement.cpp
index 2c14e38..6dc4f4b 100644
--- a/trusty_keymaster_enforcement.cpp
+++ b/trusty_keymaster_enforcement.cpp
@@ -19,6 +19,8 @@
 #include <openssl/hmac.h>
 #include <trusty/time.h>
 
+#include <inttypes.h>
+
 #include <hardware/hw_auth_token.h>
 #include <keymaster/android_keymaster_utils.h>
 #include <keymaster/km_openssl/openssl_err.h>
@@ -80,7 +82,8 @@
     int64_t secure_time_ns = 0;
     rv = trusty_gettime(0, &secure_time_ns);
     if (rv || secure_time_ns < 0) {
-        LOG_S("Error getting time. Error: %d, time: %lld", rv, secure_time_ns);
+        LOG_S("Error getting time. Error: %d, time: %" PRId64, rv,
+              secure_time_ns);
         secure_time_ns =
                 0xFFFFFFFFFFFFFFFFL;  // UINT64_MAX isn't defined (b/22120972)
     }
diff --git a/trusty_remote_provisioning_context.cpp b/trusty_remote_provisioning_context.cpp
index 3cf69a2..9a05bb6 100644
--- a/trusty_remote_provisioning_context.cpp
+++ b/trusty_remote_provisioning_context.cpp
@@ -54,7 +54,7 @@
         size_t num_bytes) const {
     long rc = hwkey_open();
     if (rc < 0) {
-        LOG_S("Couldn't open hwkey session: %d", rc);
+        LOG_S("Couldn't open hwkey session: %ld", rc);
         return {};
     }
 
@@ -66,7 +66,7 @@
                       hw_backed_key.data(), kMacKeyLength);
 
     if (rc < 0) {
-        LOG_S("Error deriving master key: %d", rc);
+        LOG_S("Error deriving master key: %ld", rc);
         return {};
     }
 
@@ -88,13 +88,13 @@
 keymaster_error_t ReadAttestationIds(AttestationIds* ids) {
     SecureStorageManager* ss_manager = SecureStorageManager::get_instance();
     if (ss_manager == nullptr) {
-        LOG_E("Failed to open secure storage session.", 0);
+        LOG_E("Failed to open secure storage session.");
         return KM_ERROR_SECURE_HW_BUSY;
     }
 
     auto err = ss_manager->ReadAttestationIds(ids);
     if (err != KM_ERROR_OK) {
-        LOG_E("Failed to read attestation IDs", 0);
+        LOG_E("Failed to read attestation IDs");
         return err;
     }
     return KM_ERROR_OK;
@@ -250,8 +250,7 @@
 void TrustyRemoteProvisioningContext::SetBootParams(
         const BootParams* bootParams) {
     if (bootParamsSet_) {
-        LOG_E("Boot parameters are already set in the remote provisioning context",
-              0);
+        LOG_E("Boot parameters are already set in the remote provisioning context");
     }
     bootParamsSet_ = true;
     bootParams_ = bootParams;
diff --git a/trusty_secure_deletion_secret_storage.cpp b/trusty_secure_deletion_secret_storage.cpp
index 2c03459..561a5e1 100644
--- a/trusty_secure_deletion_secret_storage.cpp
+++ b/trusty_secure_deletion_secret_storage.cpp
@@ -16,6 +16,8 @@
 
 #include "trusty_secure_deletion_secret_storage.h"
 
+#include <inttypes.h>
+
 #include <array>
 #include <optional>
 #include <vector>
@@ -101,7 +103,7 @@
             return;
         }
 
-        LOG_D("Closing file handle %llu", *fileHandle_);
+        LOG_D("Closing file handle %" PRIu64, *fileHandle_);
         storage_close_file(*fileHandle_);
         fileHandle_ = std::nullopt;
     }
@@ -122,8 +124,7 @@
 
         Buffer buf(bytesToRead);
         if (buf.buffer_size() < bytesToRead) {
-            LOG_E("Error memory allocation failed trying to allocate ReadBlock buffer.",
-                  0);
+            LOG_E("Error memory allocation failed trying to allocate ReadBlock buffer.");
             return std::nullopt;
         }
 
@@ -133,13 +134,14 @@
             LOG_E("Error %zd reading file", bytesRead);
             return std::nullopt;
         } else if (static_cast<size_t>(bytesRead) < bytesToRead) {
-            LOG_E("Error attempt to read %llu bytes returned only %zd bytes",
+            LOG_E("Error attempt to read %" PRIu64
+                  " bytes returned only %zd bytes",
                   bytesToRead, bytesRead);
             return std::nullopt;
         }
 
         if (!buf.advance_write(bytesRead)) {
-            LOG_E("Failed to update buffer write position. Code error.", 0);
+            LOG_E("Failed to update buffer write position. Code error.");
             return std::nullopt;
         }
         return buf;
@@ -154,20 +156,20 @@
      */
     bool WriteBlock(storage_off_t pos, const uint8_t* data, size_t size) const {
         if (!fileHandle_) {
-            LOG_E("Attempt to write to invalid file handle", 0);
+            LOG_E("Attempt to write to invalid file handle");
             return false;
         }
 
         storage_off_t end;
         if (__builtin_add_overflow(pos, size, &end) || end > fileSize_) {
-            LOG_E("Attempt to write past EOF", 0);
+            LOG_E("Attempt to write past EOF");
             return false;
         }
 
         ssize_t bytesWritten =
                 storage_write(*fileHandle_, pos, data, size, 0 /* opflags */);
         if (bytesWritten < 0) {
-            LOG_E("Error %zd writing rollback record at offset %llu",
+            LOG_E("Error %zd writing rollback record at offset %" PRIu64,
                   bytesWritten, pos);
             return false;
         } else if (static_cast<size_t>(bytesWritten) < size) {
@@ -185,14 +187,14 @@
      */
     int Resize(storage_off_t newSize) {
         if (!fileHandle_) {
-            LOG_E("Attempt to resize invalid file handle", 0);
+            LOG_E("Attempt to resize invalid file handle");
             return -ERR_NOT_VALID;
         }
 
         int rc = storage_set_file_size(*fileHandle_, newSize, 0 /* opflags */);
         if (rc) {
-            LOG_E("Error %d resizing file from %llu to %llu", rc, fileSize_,
-                  newSize);
+            LOG_E("Error %d resizing file from %" PRIu64 " to %" PRIu64, rc,
+                  fileSize_, newSize);
             return rc;
         }
 
@@ -229,7 +231,7 @@
     }
     ~StorageSession() {
         if (session_ != STORAGE_INVALID_SESSION) {
-            LOG_D("Closing storage session %llu", session_);
+            LOG_D("Closing storage session %" PRIu32, session_);
             storage_close_session(session_);
         }
     }
@@ -262,7 +264,7 @@
             return std::nullopt;
         }
         storage_session_t session = static_cast<storage_session_t>(rc);
-        LOG_D("Opened storage session %llu", session);
+        LOG_D("Opened storage session %" PRIu32, session);
         return StorageSession(session);
     }
 
@@ -279,7 +281,7 @@
             LOG_E("Error %d opening file %s", err, fileName);
             return std::nullopt;
         }
-        LOG_D("Opened file %s with handle %llu", fileName, fileHandle);
+        LOG_D("Opened file %s with handle %" PRIu64, fileName, fileHandle);
 
         storage_off_t fileSize;
         err = storage_get_file_size(fileHandle, &fileSize);
@@ -341,7 +343,7 @@
                   storage_off_t begin,
                   storage_off_t end) {
     if (begin % kSecretSize != 0) {
-        LOG_S("zero_entries called with invalid offset %llu", begin);
+        LOG_S("zero_entries called with invalid offset %" PRIu64, begin);
         return false;
     }
 
@@ -351,7 +353,7 @@
                                          0x00, 0x00, 0x00, 0x00,  //
                                          0x00, 0x00, 0x00, 0x00};
         if (!file.WriteBlock(pos, zero_buf, sizeof(zero_buf))) {
-            LOG_E("Failed to zero secret at offset %llu", pos);
+            LOG_E("Failed to zero secret at offset %" PRIu64, pos);
             return false;
         }
     }
@@ -373,7 +375,7 @@
     for (storage_off_t filePos = 0; filePos < end; filePos += kBlockSize) {
         std::optional<Buffer> block = file.ReadBlock(filePos, kBlockSize);
         if (!block) {
-            LOG_E("Failed to read block of secrets", 0);
+            LOG_E("Failed to read block of secrets");
             return std::nullopt;
         }
 
@@ -421,28 +423,28 @@
         return true;
     }
 
-    LOG_D("Trying to open a session to read factory reset secret", 0);
+    LOG_D("Trying to open a session to read factory reset secret");
     std::optional<StorageSession> session =
             StorageSession::CreateSession(wait_for_port);
     if (!session) {
         return false;
     }
 
-    LOG_D("Trying to open secure secrets file", 0);
+    LOG_D("Trying to open secure secrets file");
     std::optional<StorageFile> file =
             session->OpenFile(kSecureDeletionSecretFileName);
     if (!file) {
         // This shouldn't be possible, unless maybe the session just went away?
-        LOG_E("Can't open secure secrets file.", 0);
+        LOG_E("Can't open secure secrets file.");
         return false;
     }
 
     if (file->size() > 0) {
-        LOG_D("Opened non-empty secure secrets file.", 0);
+        LOG_D("Opened non-empty secure secrets file.");
         std::optional<Buffer> block = file->ReadBlock(kFactoryResetSecretPos,
                                                       kFactoryResetSecretSize);
         if (!block) {
-            LOG_E("Failed to read factory reset secret", 0);
+            LOG_E("Failed to read factory reset secret");
             return false;
         }
 
@@ -452,43 +454,44 @@
     }
 
     // The file was just created.  Need to create the factory reset secret.
-    LOG_I("Created new secure secrets file, size %llu", file->size());
+    LOG_I("Created new secure secrets file, size %" PRIu64, file->size());
     if (file->Resize(kBlockSize) != NO_ERROR) {
-        LOG_E("Failed to grow new file from 0 to %llu bytes", kBlockSize);
+        LOG_E("Failed to grow new file from 0 to %" PRIu64 " bytes",
+              kBlockSize);
         return false;
     }
-    LOG_D("Resized secure secrets file to size %llu", file->size());
+    LOG_D("Resized secure secrets file to size %" PRIu64, file->size());
 
     static_assert(kBlockSize >= kFactoryResetSecretSize);
     Buffer buf(kFactoryResetSecretSize);
     keymaster_error_t error =
             random_.GenerateRandom(buf.peek_write(), buf.available_write());
     if (error != KM_ERROR_OK || !buf.advance_write(kFactoryResetSecretSize)) {
-        LOG_E("Failed to generate %zu random bytes for factory reset secret",
+        LOG_E("Failed to generate %" PRIu64
+              " random bytes for factory reset secret",
               kFactoryResetSecretSize);
         return false;
     }
 
     if (!file->WriteBlock(kFactoryResetSecretPos, buf.peek_read(),
                           buf.available_read())) {
-        LOG_E("Failed to write factory reset secret", 0);
+        LOG_E("Failed to write factory reset secret");
         return false;
     }
-    LOG_D("Wrote new factory reset secret.", 0);
+    LOG_D("Wrote new factory reset secret.");
 
     if (!zero_entries(*file, kFirstSecureDeletionSecretPos /* begin */,
                       kBlockSize /* end */)) {
-        LOG_E("Failed to zero secure deletion secret entries in first block",
-              0);
+        LOG_E("Failed to zero secure deletion secret entries in first block");
         return false;
     }
-    LOG_D("Zeroed secrets.", 0);
+    LOG_D("Zeroed secrets.");
 
     if (!session->EndTransaction(true /* commit */)) {
-        LOG_E("Failed to commit transaction creating secure secrets file", 0);
+        LOG_E("Failed to commit transaction creating secure secrets file");
         return false;
     }
-    LOG_D("Committed new secrets file.", 0);
+    LOG_D("Committed new secrets file.");
 
     LOG_I("Got factory reset secret of size %zu", buf.buffer_size());
     factory_reset_secret_ = std::move(buf);
@@ -501,7 +504,7 @@
     if (!LoadOrCreateFactoryResetSecret(false /* wait_for_port */) ||
         !factory_reset_secret_) {
         // Unable to get factory reset secret from secure storage.
-        LOG_I("Unable to get factory reset secret", 0);
+        LOG_I("Unable to get factory reset secret");
         return std::nullopt;
     }
 
@@ -509,7 +512,7 @@
     retval.factory_reset_secret.Reinitialize(*factory_reset_secret_);
 
     if (!secure_deletion) {
-        LOG_D("Secure deletion not requested.", 0);
+        LOG_D("Secure deletion not requested.");
         return retval;
     }
 
@@ -523,7 +526,7 @@
             retval.secure_deletion_secret.available_write());
     if (error != KM_ERROR_OK) {
         // Ths really shouldn't be possible.  Perhaps we should abort()?
-        LOG_E("Failed to create secure deletion secret", 0);
+        LOG_E("Failed to create secure deletion secret");
         return std::nullopt;
     }
     retval.secure_deletion_secret.peek_write()[0] |= kInUseFlag;
@@ -536,22 +539,22 @@
             StorageSession::CreateSession();  // Will block
 
     if (!session) {
-        LOG_E("Failed to open session in CreateDateForNewKey", 0);
+        LOG_E("Failed to open session in CreateDateForNewKey");
         return retval;
     }
-    LOG_D("Opened session to store secure deletion secret.", 0);
+    LOG_D("Opened session to store secure deletion secret.");
 
     std::optional<StorageFile> file =
             session->OpenFile(kSecureDeletionSecretFileName);
     if (!file) {
-        LOG_E("Failed to open file in CreateDateForNewKey", 0);
+        LOG_E("Failed to open file in CreateDateForNewKey");
         return retval;
     }
-    LOG_D("Opened file to store secure deletion secret.", 0);
+    LOG_D("Opened file to store secure deletion secret.");
 
     std::optional<uint32_t> keySlot = find_empty_slot(*file, is_upgrade);
     if (!keySlot) {
-        LOG_E("Error while searching for key slot", 0);
+        LOG_E("Error while searching for key slot");
         return retval;
     }
 
@@ -561,23 +564,23 @@
                 (is_upgrade && file->size() < kMaxSecretFileSizeForUpgrades);
 
         if (!can_resize) {
-            LOG_E("Didn't find a slot and can't grow the file larger than %llu",
+            LOG_E("Didn't find a slot and can't grow the file larger than %" PRIu64,
                   file->size());
             return retval;
         }
 
         storage_off_t old_size = file->size();
-        LOG_D("Attempting to resize file from %llu to %llu", file->size(),
-              file->size() + kBlockSize);
+        LOG_D("Attempting to resize file from %" PRIu64 " to %" PRIu64,
+              file->size(), file->size() + kBlockSize);
         int rc = file->Resize(old_size + kBlockSize);
         if (rc != NO_ERROR) {
             LOG_E("Failed (%d) to grow file to make room for a key slot", rc);
             return retval;
         }
-        LOG_D("Resized file to %llu", file->size());
+        LOG_D("Resized file to %" PRIu64, file->size());
 
         if (!zero_entries(*file, old_size, file->size())) {
-            LOG_E("Error zeroing space in extended file", 0);
+            LOG_E("Error zeroing space in extended file");
             return retval;
         }
 
@@ -597,7 +600,7 @@
               *keySlot);
         return retval;
     }
-    LOG_D("Committed new secret.", 0);
+    LOG_D("Committed new secret.");
 
     sds_cleanup.disarm();  // Secure deletion secret written; no need to wipe.
     retval.key_slot = *keySlot;
@@ -620,7 +623,7 @@
 
     bool secureDeletionSecretRequested = (key_slot != 0);
     if (!secureDeletionSecretRequested) {
-        LOG_D("Secure deletion not requested.", 0);
+        LOG_D("Secure deletion not requested.");
         return retval;
     }
 
@@ -630,21 +633,21 @@
         std::optional<StorageSession> session =
                 StorageSession::CreateSession();  // Will block
         if (!session) {
-            LOG_E("Failed to open session to get secure deletion data.", 0);
+            LOG_E("Failed to open session to get secure deletion data.");
             continue;
         }
 
         std::optional<StorageFile> file =
                 session->OpenFile(kSecureDeletionSecretFileName);
         if (!file) {
-            LOG_E("Failed to open file to get secure deletion data.", 0);
+            LOG_E("Failed to open file to get secure deletion data.");
             continue;
         }
 
         storage_off_t keySlotBegin = retval.key_slot * kSecretSize;
         storage_off_t keySlotEnd = keySlotBegin + kSecretSize;
         if (keySlotEnd > file->size()) {
-            LOG_E("Invalid key slot %u would read past end of file of size %llu",
+            LOG_E("Invalid key slot %u would read past end of file of size %" PRIu64,
                   retval.key_slot, file->size());
             return retval;  // Empty secure_deletion_secret, key decryption will
                             // fail.
@@ -668,7 +671,7 @@
 
 void TrustySecureDeletionSecretStorage::DeleteKey(uint32_t key_slot) const {
     if (key_slot == 0) {
-        LOG_D("key_slot == 0, nothing to delete", 0);
+        LOG_D("key_slot == 0, nothing to delete");
         return;
     }
 
@@ -676,15 +679,14 @@
         std::optional<StorageSession> session =
                 StorageSession::CreateSession();  // Will block
         if (!session) {
-            LOG_E("Failed to open session to retrieve secure deletion data.",
-                  0);
+            LOG_E("Failed to open session to retrieve secure deletion data.");
             continue;
         }
 
         std::optional<StorageFile> file =
                 session->OpenFile(kSecureDeletionSecretFileName);
         if (!file) {
-            LOG_E("Failed to open file to retrieve secure deletion data.", 0);
+            LOG_E("Failed to open file to retrieve secure deletion data.");
             continue;
         }
 
@@ -700,15 +702,15 @@
         if (!zero_entries(*file, key_slot_begin, key_slot_end)) {
             continue;
         }
-        LOG_D("Deleted secure key slot %u, zeroing %llu to %llu", key_slot,
-              key_slot_begin, key_slot_end);
+        LOG_D("Deleted secure key slot %u, zeroing %" PRIu64 " to %" PRIu64,
+              key_slot, key_slot_begin, key_slot_end);
 
         if (!session->EndTransaction(true /* commit */)) {
             LOG_E("Failed to commit transaction deleting key at slot %u",
                   key_slot);
             continue;
         }
-        LOG_D("Committed deletion", 0);
+        LOG_D("Committed deletion");
 
         return;
     }
@@ -719,25 +721,25 @@
         std::optional<StorageSession> session =
                 StorageSession::CreateSession();  // Will block
         if (!session) {
-            LOG_E("Failed to open session to delete secrets file.", 0);
+            LOG_E("Failed to open session to delete secrets file.");
             continue;
         }
-        LOG_D("Opened session to delete secrets file.", 0);
+        LOG_D("Opened session to delete secrets file.");
 
         auto error = session->DeleteFile(kSecureDeletionSecretFileName);
         if (error == StorageSession::Error::OK) {
-            LOG_D("Deleted secrets file", 0);
+            LOG_D("Deleted secrets file");
 
             if (!session->EndTransaction(true /* commit */)) {
-                LOG_E("Failed to commit deletion of secrets file.", 0);
+                LOG_E("Failed to commit deletion of secrets file.");
             }
-            LOG_D("Committed deletion of secrets file.", 0);
+            LOG_D("Committed deletion of secrets file.");
         } else if (error == StorageSession::Error::NOT_FOUND) {
             // File does not exist, may as well abandon the session.
-            LOG_D("No secrets file existed.", 0);
+            LOG_D("No secrets file existed.");
         } else {
             // Assuming transient error. Log and retry.
-            LOG_E("Failed to delete secrets file", 0);
+            LOG_E("Failed to delete secrets file");
             continue;
         }