From d35a9cb8b8b451e3423f19b8b4d9df4163950218 Mon Sep 17 00:00:00 2001 From: Damian Krolik Date: Fri, 24 Jun 2022 14:28:51 +0200 Subject: [PATCH] [logging] Use CHIP_ERROR_FORMAT in more places We have two alternative ways of logging an error code: - using CHIP_ERROR_FORMAT which resolves either to %s or %u - using %s + ErrorStr() Both methods are supposed to have the same effect, but the former generates slightly smaller code. Signed-off-by: Damian Krolik --- src/app/DeviceProxy.cpp | 1 - src/app/EventManagement.cpp | 3 +-- src/app/MessageDef/StatusIB.cpp | 1 - src/app/OperationalDeviceProxy.cpp | 1 - src/app/WriteClient.cpp | 2 +- src/app/server/CommissioningWindowManager.cpp | 2 +- src/app/server/Dnssd.cpp | 26 +++++++++---------- src/app/server/OnboardingCodesUtil.cpp | 19 +++++++------- src/app/server/Server.cpp | 7 +++-- .../server/java/AndroidAppServerWrapper.cpp | 2 +- .../util/ember-compatibility-functions.cpp | 2 +- src/ble/BleError.cpp | 2 -- .../internal/GenericPlatformManagerImpl.ipp | 15 ++++++----- .../GenericPlatformManagerImpl_FreeRTOS.ipp | 2 +- src/inet/InetError.cpp | 2 -- src/lib/asn1/ASN1Error.cpp | 1 - src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp | 4 +-- src/lib/dnssd/Discovery_ImplPlatform.cpp | 9 +++---- src/lib/dnssd/minimal_mdns/Server.cpp | 4 +-- src/messaging/ExchangeMgr.cpp | 16 +++++++----- src/platform/Zephyr/BLEManagerImpl.cpp | 6 ++--- .../Zephyr/ConfigurationManagerImpl.cpp | 2 +- src/platform/Zephyr/NFCManagerImpl.cpp | 2 +- src/protocols/bdx/BdxTransferSession.cpp | 2 +- src/protocols/bdx/TransferFacilitator.cpp | 2 +- src/protocols/secure_channel/CASEServer.cpp | 2 +- src/protocols/secure_channel/CASESession.cpp | 3 ++- .../secure_channel/MessageCounterManager.cpp | 7 ++--- src/protocols/secure_channel/PASESession.cpp | 6 ++--- src/protocols/secure_channel/PairingSession.h | 2 +- .../UserDirectedCommissioningClient.cpp | 4 +-- src/system/SystemLayer.cpp | 2 +- src/system/SystemLayerImplSelect.cpp | 2 +- src/system/WakeEvent.cpp | 5 ++-- src/test_driver/nrfconnect/main/runner.cpp | 1 - src/transport/SessionManager.cpp | 2 +- src/transport/raw/BLE.cpp | 8 +++--- src/transport/raw/UDP.cpp | 6 ++--- 38 files changed, 90 insertions(+), 95 deletions(-) diff --git a/src/app/DeviceProxy.cpp b/src/app/DeviceProxy.cpp index b3618742a55961..fef30c4433347c 100644 --- a/src/app/DeviceProxy.cpp +++ b/src/app/DeviceProxy.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include using namespace chip::Callback; diff --git a/src/app/EventManagement.cpp b/src/app/EventManagement.cpp index f8bddaa83bdaf8..6aa5c79a442c09 100644 --- a/src/app/EventManagement.cpp +++ b/src/app/EventManagement.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include using namespace chip::TLV; @@ -468,7 +467,7 @@ CHIP_ERROR EventManagement::LogEventPrivate(EventLoggingDelegate * apDelegate, c exit: if (err != CHIP_NO_ERROR) { - ChipLogError(EventLogging, "Log event with error %s", ErrorStr(err)); + ChipLogError(EventLogging, "Log event with error %" CHIP_ERROR_FORMAT, err.Format()); writer = checkpoint; } else if (opts.mPriority >= CHIP_CONFIG_EVENT_GLOBAL_PRIORITY) diff --git a/src/app/MessageDef/StatusIB.cpp b/src/app/MessageDef/StatusIB.cpp index 38b961beafc5c8..19957a312183a7 100644 --- a/src/app/MessageDef/StatusIB.cpp +++ b/src/app/MessageDef/StatusIB.cpp @@ -31,7 +31,6 @@ #include #include -#include using namespace chip; using namespace chip::TLV; diff --git a/src/app/OperationalDeviceProxy.cpp b/src/app/OperationalDeviceProxy.cpp index 8193d8c78286fd..fad25a669a0fba 100644 --- a/src/app/OperationalDeviceProxy.cpp +++ b/src/app/OperationalDeviceProxy.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/src/app/WriteClient.cpp b/src/app/WriteClient.cpp index 1e4eb11c598574..106e99633b9db8 100644 --- a/src/app/WriteClient.cpp +++ b/src/app/WriteClient.cpp @@ -394,7 +394,7 @@ CHIP_ERROR WriteClient::SendWriteRequest(const SessionHandle & session, System:: exit: if (err != CHIP_NO_ERROR) { - ChipLogError(DataManagement, "Write client failed to SendWriteRequest: %s", ErrorStr(err)); + ChipLogError(DataManagement, "Write client failed to SendWriteRequest: %" CHIP_ERROR_FORMAT, err.Format()); } else { diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 0996e4fa80fd41..0ad4a5b1ab5b1d 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -115,7 +115,7 @@ void CommissioningWindowManager::OnSessionEstablishmentError(CHIP_ERROR err) void CommissioningWindowManager::HandleFailedAttempt(CHIP_ERROR err) { mFailedCommissioningAttempts++; - ChipLogError(AppServer, "Commissioning failed (attempt %d): %s", mFailedCommissioningAttempts, ErrorStr(err)); + ChipLogError(AppServer, "Commissioning failed (attempt %d): %" CHIP_ERROR_FORMAT, mFailedCommissioningAttempts, err.Format()); #if CONFIG_NETWORK_LAYER_BLE mServer->GetBleLayerObject()->CloseAllBleConnections(); #endif diff --git a/src/app/server/Dnssd.cpp b/src/app/server/Dnssd.cpp index 85301c60eb17ea..f9d466f92e0270 100644 --- a/src/app/server/Dnssd.cpp +++ b/src/app/server/Dnssd.cpp @@ -132,35 +132,35 @@ bool DnssdServer::OnExpiration(System::Clock::Timestamp expirationMs) CHIP_ERROR err = Dnssd::ServiceAdvertiser::Instance().Init(chip::DeviceLayer::UDPEndPointManager()); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to initialize advertiser: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to initialize advertiser: %" CHIP_ERROR_FORMAT, err.Format()); } // reset advertising err = Dnssd::ServiceAdvertiser::Instance().RemoveServices(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to remove advertised services: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to remove advertised services: %" CHIP_ERROR_FORMAT, err.Format()); } // restart operational (if needed) err = AdvertiseOperational(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise operational node: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise operational node: %" CHIP_ERROR_FORMAT, err.Format()); } #if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY err = AdvertiseCommissioner(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise commissioner: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise commissioner: %" CHIP_ERROR_FORMAT, err.Format()); } #endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY err = Dnssd::ServiceAdvertiser::Instance().FinalizeServiceUpdate(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to finalize service update: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to finalize service update: %" CHIP_ERROR_FORMAT, err.Format()); } return true; @@ -183,7 +183,7 @@ void DnssdServer::OnDiscoveryExpiration(System::Layer * aSystemLayer, void * aAp CHIP_ERROR err = AdvertiseCommissionableNode(chip::Dnssd::CommissioningMode::kDisabled); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise extended commissionable node: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise extended commissionable node: %" CHIP_ERROR_FORMAT, err.Format()); } // set timeout ScheduleExtendedDiscoveryExpiration(); @@ -433,19 +433,19 @@ void DnssdServer::StartServer(Dnssd::CommissioningMode mode) CHIP_ERROR err = Dnssd::ServiceAdvertiser::Instance().Init(chip::DeviceLayer::UDPEndPointManager()); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to initialize advertiser: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to initialize advertiser: %" CHIP_ERROR_FORMAT, err.Format()); } err = Dnssd::ServiceAdvertiser::Instance().RemoveServices(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to remove advertised services: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to remove advertised services: %" CHIP_ERROR_FORMAT, err.Format()); } err = AdvertiseOperational(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise operational node: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise operational node: %" CHIP_ERROR_FORMAT, err.Format()); } if (mode != chip::Dnssd::CommissioningMode::kDisabled) @@ -453,7 +453,7 @@ void DnssdServer::StartServer(Dnssd::CommissioningMode mode) err = AdvertiseCommissionableNode(mode); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise commissionable node: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise commissionable node: %" CHIP_ERROR_FORMAT, err.Format()); } // If any fabrics exist, the commissioning window must have been opened by the administrator @@ -469,7 +469,7 @@ void DnssdServer::StartServer(Dnssd::CommissioningMode mode) err = AdvertiseCommissionableNode(mode); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise extended commissionable node: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise extended commissionable node: %" CHIP_ERROR_FORMAT, err.Format()); } // set timeout ScheduleExtendedDiscoveryExpiration(); @@ -480,14 +480,14 @@ void DnssdServer::StartServer(Dnssd::CommissioningMode mode) err = AdvertiseCommissioner(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise commissioner: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise commissioner: %" CHIP_ERROR_FORMAT, err.Format()); } #endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY err = Dnssd::ServiceAdvertiser::Instance().FinalizeServiceUpdate(); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to finalize service update: %s", chip::ErrorStr(err)); + ChipLogError(Discovery, "Failed to finalize service update: %" CHIP_ERROR_FORMAT, err.Format()); } } diff --git a/src/app/server/OnboardingCodesUtil.cpp b/src/app/server/OnboardingCodesUtil.cpp index d5578b8fd9e63f..261db799345899 100644 --- a/src/app/server/OnboardingCodesUtil.cpp +++ b/src/app/server/OnboardingCodesUtil.cpp @@ -43,7 +43,7 @@ void PrintOnboardingCodes(chip::RendezvousInformationFlags aRendezvousFlags) CHIP_ERROR err = GetPayloadContents(payload, aRendezvousFlags); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "GetPayloadContents() failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "GetPayloadContents() failed: %" CHIP_ERROR_FORMAT, err.Format()); } PrintOnboardingCodes(payload); @@ -105,7 +105,7 @@ CHIP_ERROR GetPayloadContents(chip::PayloadContents & aPayload, chip::Rendezvous err = GetCommissionableDataProvider()->GetSetupPasscode(aPayload.setUpPINCode); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "GetCommissionableDataProvider()->GetSetupPasscode() failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "GetCommissionableDataProvider()->GetSetupPasscode() failed: %" CHIP_ERROR_FORMAT, err.Format()); #if defined(CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE) && CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE ChipLogProgress(AppServer, "*** Using default EXAMPLE passcode %u ***", static_cast(CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE)); @@ -118,21 +118,22 @@ CHIP_ERROR GetPayloadContents(chip::PayloadContents & aPayload, chip::Rendezvous err = GetCommissionableDataProvider()->GetSetupDiscriminator(aPayload.discriminator); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "GetCommissionableDataProvider()->GetSetupDiscriminator() failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "GetCommissionableDataProvider()->GetSetupDiscriminator() failed: %" CHIP_ERROR_FORMAT, + err.Format()); return err; } err = chip::DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(aPayload.vendorID); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "GetDeviceInstanceInfoProvider()->GetVendorId() failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "GetDeviceInstanceInfoProvider()->GetVendorId() failed: %" CHIP_ERROR_FORMAT, err.Format()); return err; } err = chip::DeviceLayer::GetDeviceInstanceInfoProvider()->GetProductId(aPayload.productID); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "GetDeviceInstanceInfoProvider()->GetProductId() failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "GetDeviceInstanceInfoProvider()->GetProductId() failed: %" CHIP_ERROR_FORMAT, err.Format()); return err; } @@ -146,7 +147,7 @@ CHIP_ERROR GetQRCode(chip::MutableCharSpan & aQRCode, chip::RendezvousInformatio CHIP_ERROR err = GetPayloadContents(payload, aRendezvousFlags); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "GetPayloadContents() failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "GetPayloadContents() failed: %" CHIP_ERROR_FORMAT, err.Format()); return err; } @@ -158,7 +159,7 @@ CHIP_ERROR GetQRCode(chip::MutableCharSpan & aQRCode, const chip::PayloadContent CHIP_ERROR err = chip::QRCodeBasicSetupPayloadGenerator(payload).payloadBase38Representation(aQRCode); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "Generating QR Code failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "Generating QR Code failed: %" CHIP_ERROR_FORMAT, err.Format()); return err; } @@ -186,7 +187,7 @@ CHIP_ERROR GetManualPairingCode(chip::MutableCharSpan & aManualPairingCode, chip CHIP_ERROR err = GetPayloadContents(payload, aRendezvousFlags); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "GetPayloadContents() failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "GetPayloadContents() failed: %" CHIP_ERROR_FORMAT, err.Format()); return err; } return GetManualPairingCode(aManualPairingCode, payload); @@ -197,7 +198,7 @@ CHIP_ERROR GetManualPairingCode(chip::MutableCharSpan & aManualPairingCode, cons CHIP_ERROR err = chip::ManualSetupPayloadGenerator(payload).payloadDecimalStringRepresentation(aManualPairingCode); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "Generating Manual Pairing Code failed: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "Generating Manual Pairing Code failed: %" CHIP_ERROR_FORMAT, err.Format()); return err; } diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 7cb04efb05b8b3..0db0f9675a3403 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -306,7 +305,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) exit: if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "ERROR setting up transport: %s", ErrorStr(err)); + ChipLogError(AppServer, "ERROR setting up transport: %" CHIP_ERROR_FORMAT, err.Format()); } else { @@ -436,7 +435,7 @@ CHIP_ERROR Server::SendUserDirectedCommissioningRequest(chip::Transport::PeerAdd err = app::DnssdServer::Instance().GetCommissionableInstanceName(nameBuffer, sizeof(nameBuffer)); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "Failed to get mdns instance name error: %s", ErrorStr(err)); + ChipLogError(AppServer, "Failed to get mdns instance name error: %" CHIP_ERROR_FORMAT, err.Format()); return err; } ChipLogDetail(AppServer, "instanceName=%s", nameBuffer); @@ -455,7 +454,7 @@ CHIP_ERROR Server::SendUserDirectedCommissioningRequest(chip::Transport::PeerAdd } else { - ChipLogError(AppServer, "Send UDC request failed, err: %s\n", chip::ErrorStr(err)); + ChipLogError(AppServer, "Send UDC request failed, err: %" CHIP_ERROR_FORMAT, err.Format()); } return err; } diff --git a/src/app/server/java/AndroidAppServerWrapper.cpp b/src/app/server/java/AndroidAppServerWrapper.cpp index cd3a224e48a6e8..58eaa76bcbb7fb 100644 --- a/src/app/server/java/AndroidAppServerWrapper.cpp +++ b/src/app/server/java/AndroidAppServerWrapper.cpp @@ -64,7 +64,7 @@ CHIP_ERROR ChipAndroidAppInit(void) exit: if (err != CHIP_NO_ERROR) { - ChipLogProgress(NotSpecified, "Failed to run ChipAndroidAppInit: %s ", ErrorStr(err)); + ChipLogProgress(NotSpecified, "Failed to run ChipAndroidAppInit: %" CHIP_ERROR_FORMAT, err.Format()); return err; } return err; diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 6e0e721a6fae6f..d90c97a50b6f8e 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -1026,7 +1026,7 @@ CHIP_ERROR WriteSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, uint16_t dataLen = 0; if ((preparationError = prepareWriteData(attributeMetadata, aReader, dataLen)) != CHIP_NO_ERROR) { - ChipLogDetail(Zcl, "Failed to prepare data to write: %s", ErrorStr(preparationError)); + ChipLogDetail(Zcl, "Failed to prepare data to write: %" CHIP_ERROR_FORMAT, preparationError.Format()); return apWriteHandler->AddStatus(aPath, Protocols::InteractionModel::Status::InvalidValue); } diff --git a/src/ble/BleError.cpp b/src/ble/BleError.cpp index 6d3def17625a79..641efc24e574b6 100644 --- a/src/ble/BleError.cpp +++ b/src/ble/BleError.cpp @@ -30,8 +30,6 @@ #include #include -#include - namespace chip { namespace Ble { diff --git a/src/include/platform/internal/GenericPlatformManagerImpl.ipp b/src/include/platform/internal/GenericPlatformManagerImpl.ipp index 66233710a595b2..7b05b670ff4578 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl.ipp @@ -61,7 +61,7 @@ CHIP_ERROR GenericPlatformManagerImpl::_InitChipStack() err = InitEntropy(); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Entropy initialization failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Entropy initialization failed: %" CHIP_ERROR_FORMAT, err.Format()); } SuccessOrExit(err); @@ -69,7 +69,7 @@ CHIP_ERROR GenericPlatformManagerImpl::_InitChipStack() err = SystemLayer().Init(); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "SystemLayer initialization failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "SystemLayer initialization failed: %" CHIP_ERROR_FORMAT, err.Format()); } SuccessOrExit(err); @@ -77,7 +77,7 @@ CHIP_ERROR GenericPlatformManagerImpl::_InitChipStack() err = ConfigurationMgr().Init(); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Configuration Manager initialization failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Configuration Manager initialization failed: %" CHIP_ERROR_FORMAT, err.Format()); } SuccessOrExit(err); @@ -85,7 +85,7 @@ CHIP_ERROR GenericPlatformManagerImpl::_InitChipStack() err = UDPEndPointManager()->Init(SystemLayer()); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "UDP initialization failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "UDP initialization failed: %" CHIP_ERROR_FORMAT, err.Format()); } SuccessOrExit(err); @@ -96,7 +96,7 @@ CHIP_ERROR GenericPlatformManagerImpl::_InitChipStack() err = BLEMgr().Init(); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "BLEManager initialization failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "BLEManager initialization failed: %" CHIP_ERROR_FORMAT, err.Format()); } SuccessOrExit(err); #endif @@ -105,14 +105,15 @@ CHIP_ERROR GenericPlatformManagerImpl::_InitChipStack() err = ConnectivityMgr().Init(); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Connectivity Manager initialization failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Connectivity Manager initialization failed: %" CHIP_ERROR_FORMAT, err.Format()); } SuccessOrExit(err); // Initialize the NFC Manager. #if CHIP_DEVICE_CONFIG_ENABLE_NFC err = NFCMgr().Init(); - VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "NFC Manager initialization failed: %s", ErrorStr(err))); + VerifyOrExit(err == CHIP_NO_ERROR, + ChipLogError(DeviceLayer, "NFC Manager initialization failed: %" CHIP_ERROR_FORMAT, err.Format())); #endif // TODO Initialize CHIP Event Logging. diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp index b69448724b9002..da0dbd3051f5ac 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp @@ -175,7 +175,7 @@ void GenericPlatformManagerImpl_FreeRTOS::_RunEventLoop(void) err = static_cast(DeviceLayer::SystemLayer()).HandlePlatformTimer(); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Error handling CHIP timers: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Error handling CHIP timers: %" CHIP_ERROR_FORMAT, err.Format()); } // When processing the event queue below, do not wait if the queue is empty. Instead diff --git a/src/inet/InetError.cpp b/src/inet/InetError.cpp index 3e24232dc8b9e2..9d4ea8d28ac133 100644 --- a/src/inet/InetError.cpp +++ b/src/inet/InetError.cpp @@ -26,8 +26,6 @@ #include #include -#include - extern void FormatError(char * buf, uint16_t bufSize, const char * subsys, int32_t err, const char * desc); namespace chip { diff --git a/src/lib/asn1/ASN1Error.cpp b/src/lib/asn1/ASN1Error.cpp index 02bbbfa8b9eea1..96e788eaa8d520 100644 --- a/src/lib/asn1/ASN1Error.cpp +++ b/src/lib/asn1/ASN1Error.cpp @@ -25,7 +25,6 @@ #include #include -#include namespace chip { namespace ASN1 { diff --git a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp index b419027ab48e1a..b37d824ece968b 100644 --- a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp +++ b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp @@ -323,7 +323,7 @@ void AdvertiserMinMdns::OnQuery(const QueryData & data) CHIP_ERROR err = mResponseSender.Respond(mMessageId, data, mCurrentSource, defaultResponseConfiguration); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to reply to query: %s", ErrorStr(err)); + ChipLogError(Discovery, "Failed to reply to query: %" CHIP_ERROR_FORMAT, err.Format()); } } @@ -936,7 +936,7 @@ void AdvertiserMinMdns::AdvertiseRecords(BroadcastAdvertiseType type) CHIP_ERROR err = mResponseSender.Respond(0, queryData, &packetInfo, responseConfiguration); if (err != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to advertise records: %s", ErrorStr(err)); + ChipLogError(Discovery, "Failed to advertise records: %" CHIP_ERROR_FORMAT, err.Format()); } } diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index 1be6d969787869..2f30c678372da5 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -375,13 +374,13 @@ void DiscoveryImplPlatform::HandleDnssdInit(void * context, CHIP_ERROR initError CHIP_ERROR error = chip::DeviceLayer::PlatformMgr().PostEvent(&event); if (error != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Posting DNS-SD platform initialized event failed with %s", chip::ErrorStr(error)); + ChipLogError(Discovery, "Posting DNS-SD platform initialized event failed with %" CHIP_ERROR_FORMAT, error.Format()); } #endif } else { - ChipLogError(Discovery, "DNS-SD initialization failed with %s", chip::ErrorStr(initError)); + ChipLogError(Discovery, "DNS-SD initialization failed with %" CHIP_ERROR_FORMAT, initError.Format()); publisher->mDnssdInitialized = false; } } @@ -410,7 +409,7 @@ void DiscoveryImplPlatform::HandleDnssdError(void * context, CHIP_ERROR error) } else { - ChipLogError(Discovery, "DNS-SD error: %s", chip::ErrorStr(error)); + ChipLogError(Discovery, "DNS-SD error: %" CHIP_ERROR_FORMAT, error.Format()); } } @@ -441,7 +440,7 @@ void DiscoveryImplPlatform::HandleDnssdPublish(void * context, const char * type } else { - ChipLogError(Discovery, "mDNS service published error: %s", chip::ErrorStr(error)); + ChipLogError(Discovery, "mDNS service published error: %" CHIP_ERROR_FORMAT, error.Format()); } } diff --git a/src/lib/dnssd/minimal_mdns/Server.cpp b/src/lib/dnssd/minimal_mdns/Server.cpp index 578e0e383641cf..1dc54bfa81e6d3 100644 --- a/src/lib/dnssd/minimal_mdns/Server.cpp +++ b/src/lib/dnssd/minimal_mdns/Server.cpp @@ -240,8 +240,8 @@ CHIP_ERROR ServerBase::Listen(chip::Inet::EndPointManagerIsEncryptionRequired() != packetHeader.IsEncrypted()) { - ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %s", ErrorStr(CHIP_ERROR_INVALID_MESSAGE_TYPE)); + ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %" CHIP_ERROR_FORMAT, + CHIP_ERROR_INVALID_MESSAGE_TYPE.Format()); ec->Close(); SendStandaloneAckIfNeeded(packetHeader, payloadHeader, session, msgFlags, std::move(msgBuf)); return; @@ -322,7 +324,7 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const if (err != CHIP_NO_ERROR) { // Using same error message for all errors to reduce code size. - ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %s", ErrorStr(err)); + ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %" CHIP_ERROR_FORMAT, err.Format()); } return; } @@ -348,7 +350,7 @@ void ExchangeManager::SendStandaloneAckIfNeeded(const PacketHeader & packetHeade if (ec == nullptr) { // Using same error message for all errors to reduce code size. - ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %s", ErrorStr(CHIP_ERROR_NO_MEMORY)); + ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %" CHIP_ERROR_FORMAT, CHIP_ERROR_NO_MEMORY.Format()); return; } @@ -360,7 +362,7 @@ void ExchangeManager::SendStandaloneAckIfNeeded(const PacketHeader & packetHeade if (err != CHIP_NO_ERROR) { // Using same error message for all errors to reduce code size. - ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %s", ErrorStr(err)); + ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %" CHIP_ERROR_FORMAT, err.Format()); } // The exchange should be closed inside HandleMessage function. So don't bother close it here. diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index 872178cd5ba20e..2e7f44e50fe88f 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -236,7 +236,7 @@ void BLEManagerImpl::DriveBLEState() exit: if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %" CHIP_ERROR_FORMAT, err.Format()); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; } } @@ -670,7 +670,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %" CHIP_ERROR_FORMAT, err.Format()); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -729,7 +729,7 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU exit: if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %" CHIP_ERROR_FORMAT, err.Format()); } return err == CHIP_NO_ERROR; diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp index a822ada93440b4..c073ddf9577c08 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp +++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp @@ -188,7 +188,7 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) const CHIP_ERROR err = PersistedStorage::KeyValueStoreMgrImpl().DoFactoryReset(); if (err != CHIP_NO_ERROR) - ChipLogError(DeviceLayer, "Factory reset failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Factory reset failed: %" CHIP_ERROR_FORMAT, err.Format()); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD ThreadStackMgr().ErasePersistentInfo(); diff --git a/src/platform/Zephyr/NFCManagerImpl.cpp b/src/platform/Zephyr/NFCManagerImpl.cpp index d1a89be3e3fdf8..53856af6b153b5 100644 --- a/src/platform/Zephyr/NFCManagerImpl.cpp +++ b/src/platform/Zephyr/NFCManagerImpl.cpp @@ -81,7 +81,7 @@ CHIP_ERROR NFCManagerImpl::_StartTagEmulation(const char * payload, size_t paylo exit: if (error != CHIP_NO_ERROR) - ChipLogError(DeviceLayer, "Starting NFC Tag emulation failed: %s", chip::ErrorStr(error)); + ChipLogError(DeviceLayer, "Starting NFC Tag emulation failed: %" CHIP_ERROR_FORMAT, error.Format()); return error; } diff --git a/src/protocols/bdx/BdxTransferSession.cpp b/src/protocols/bdx/BdxTransferSession.cpp index 391511c52e0bd7..f6c54985ab5cd1 100644 --- a/src/protocols/bdx/BdxTransferSession.cpp +++ b/src/protocols/bdx/BdxTransferSession.cpp @@ -881,7 +881,7 @@ void TransferSession::PrepareStatusReport(StatusCode code) mPendingMsgHandle = bbuf.Finalize(); if (mPendingMsgHandle.IsNull()) { - ChipLogError(BDX, "%s: error preparing message: %s", __FUNCTION__, ErrorStr(CHIP_ERROR_NO_MEMORY)); + ChipLogError(BDX, "%s: error preparing message: %" CHIP_ERROR_FORMAT, __FUNCTION__, CHIP_ERROR_NO_MEMORY.Format()); mPendingOutput = OutputEventType::kInternalError; } else diff --git a/src/protocols/bdx/TransferFacilitator.cpp b/src/protocols/bdx/TransferFacilitator.cpp index 5a9ce8ef66b92f..597bdc43e4990c 100644 --- a/src/protocols/bdx/TransferFacilitator.cpp +++ b/src/protocols/bdx/TransferFacilitator.cpp @@ -46,7 +46,7 @@ CHIP_ERROR TransferFacilitator::OnMessageReceived(chip::Messaging::ExchangeConte mTransfer.HandleMessageReceived(payloadHeader, std::move(payload), System::SystemClock().GetMonotonicTimestamp()); if (err != CHIP_NO_ERROR) { - ChipLogError(BDX, "failed to handle message: %s", ErrorStr(err)); + ChipLogError(BDX, "failed to handle message: %" CHIP_ERROR_FORMAT, err.Format()); } // Almost every BDX message will follow up with a response on the exchange. Even messages that might signify the end of a diff --git a/src/protocols/secure_channel/CASEServer.cpp b/src/protocols/secure_channel/CASEServer.cpp index b36d5c1f004eea..2a6a7783d6bf16 100644 --- a/src/protocols/secure_channel/CASEServer.cpp +++ b/src/protocols/secure_channel/CASEServer.cpp @@ -155,7 +155,7 @@ void CASEServer::PrepareForSessionEstablishment(const ScopedNodeId & previouslyE void CASEServer::OnSessionEstablishmentError(CHIP_ERROR err) { - ChipLogError(Inet, "CASE Session establishment failed: %s", ErrorStr(err)); + ChipLogError(Inet, "CASE Session establishment failed: %" CHIP_ERROR_FORMAT, err.Format()); // // We're not allowed to call methods that will eventually result in calling SessionManager::AllocateSecureSession diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 61a658f318620f..d7b18d003daf86 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -1604,7 +1604,8 @@ CHIP_ERROR CASESession::OnFailureStatusReport(Protocols::SecureChannel::GeneralS break; }; mState = State::kInitialized; - ChipLogError(SecureChannel, "Received error (protocol code %d) during pairing process. %s", protocolCode, ErrorStr(err)); + ChipLogError(SecureChannel, "Received error (protocol code %d) during pairing process: %" CHIP_ERROR_FORMAT, protocolCode, + err.Format()); return err; } diff --git a/src/protocols/secure_channel/MessageCounterManager.cpp b/src/protocols/secure_channel/MessageCounterManager.cpp index 8cf5f7077262a0..6903f5b199b8d4 100644 --- a/src/protocols/secure_channel/MessageCounterManager.cpp +++ b/src/protocols/secure_channel/MessageCounterManager.cpp @@ -219,7 +219,8 @@ CHIP_ERROR MessageCounterManager::SendMsgCounterSyncReq(const SessionHandle & se exchangeContext->Close(); } state->GetSessionMessageCounter().GetPeerMessageCounter().SyncFailed(); - ChipLogError(SecureChannel, "Failed to send message counter synchronization request with error:%s", ErrorStr(err)); + ChipLogError(SecureChannel, "Failed to send message counter synchronization request with error:%" CHIP_ERROR_FORMAT, + err.Format()); } return err; @@ -263,7 +264,7 @@ CHIP_ERROR MessageCounterManager::HandleMsgCounterSyncReq(Messaging::ExchangeCon exit: if (err != CHIP_NO_ERROR) { - ChipLogError(SecureChannel, "Failed to handle MsgCounterSyncReq message with error:%s", ErrorStr(err)); + ChipLogError(SecureChannel, "Failed to handle MsgCounterSyncReq message with error:%" CHIP_ERROR_FORMAT, err.Format()); } return err; @@ -303,7 +304,7 @@ CHIP_ERROR MessageCounterManager::HandleMsgCounterSyncResp(Messaging::ExchangeCo exit: if (err != CHIP_NO_ERROR) { - ChipLogError(SecureChannel, "Failed to handle MsgCounterSyncResp message with error:%s", ErrorStr(err)); + ChipLogError(SecureChannel, "Failed to handle MsgCounterSyncResp message with error:%" CHIP_ERROR_FORMAT, err.Format()); } return err; diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp index ae213a2792ec0f..cbe4988aff45f7 100644 --- a/src/protocols/secure_channel/PASESession.cpp +++ b/src/protocols/secure_channel/PASESession.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -758,7 +757,8 @@ CHIP_ERROR PASESession::OnFailureStatusReport(Protocols::SecureChannel::GeneralS err = CHIP_ERROR_INTERNAL; break; }; - ChipLogError(SecureChannel, "Received error (protocol code %d) during PASE process. %s", protocolCode, ErrorStr(err)); + ChipLogError(SecureChannel, "Received error (protocol code %d) during PASE process: %" CHIP_ERROR_FORMAT, protocolCode, + err.Format()); return err; } @@ -852,7 +852,7 @@ CHIP_ERROR PASESession::OnMessageReceived(ExchangeContext * exchange, const Payl // exchange will handle that. DiscardExchange(); Clear(); - ChipLogError(SecureChannel, "Failed during PASE session setup. %s", ErrorStr(err)); + ChipLogError(SecureChannel, "Failed during PASE session setup: %" CHIP_ERROR_FORMAT, err.Format()); // Do this last in case the delegate frees us. mDelegate->OnSessionEstablishmentError(err); } diff --git a/src/protocols/secure_channel/PairingSession.h b/src/protocols/secure_channel/PairingSession.h index e13d89dced4983..f8a707aa3af2d1 100644 --- a/src/protocols/secure_channel/PairingSession.h +++ b/src/protocols/secure_channel/PairingSession.h @@ -151,7 +151,7 @@ class DLL_EXPORT PairingSession : public SessionDelegate CHIP_ERROR err = exchangeCtxt->SendMessage(Protocols::SecureChannel::MsgType::StatusReport, std::move(msg)); if (err != CHIP_NO_ERROR) { - ChipLogError(SecureChannel, "Failed to send status report message. %s", ErrorStr(err)); + ChipLogError(SecureChannel, "Failed to send status report message: %" CHIP_ERROR_FORMAT, err.Format()); } } diff --git a/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp b/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp index 3376cbc3c3f579..ac3c017da0577e 100644 --- a/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp +++ b/src/protocols/user_directed_commissioning/UserDirectedCommissioningClient.cpp @@ -47,12 +47,12 @@ CHIP_ERROR UserDirectedCommissioningClient::SendUDCMessage(TransportMgrBase * tr err = transportMgr->SendMessage(peerAddress, payload.CloneData()); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "UDC SendMessage failed, err: %s\n", chip::ErrorStr(err)); + ChipLogError(AppServer, "UDC SendMessage failed: %" CHIP_ERROR_FORMAT, err.Format()); return err; } sleep(1); } - ChipLogProgress(Inet, "UDC msg send status %s", ErrorStr(err)); + ChipLogProgress(Inet, "UDC msg send status %" CHIP_ERROR_FORMAT, err.Format()); return err; } diff --git a/src/system/SystemLayer.cpp b/src/system/SystemLayer.cpp index cb4330e194c5ec..fe1090b765f1b5 100644 --- a/src/system/SystemLayer.cpp +++ b/src/system/SystemLayer.cpp @@ -26,7 +26,7 @@ CHIP_ERROR Layer::ScheduleLambdaBridge(LambdaBridge && bridge) CHIP_ERROR lReturn = PlatformEventing::ScheduleLambdaBridge(*this, std::move(bridge)); if (lReturn != CHIP_NO_ERROR) { - ChipLogError(chipSystemLayer, "Failed to queue CHIP System Layer lambda event: %s", ErrorStr(lReturn)); + ChipLogError(chipSystemLayer, "Failed to queue CHIP System Layer lambda event: %" CHIP_ERROR_FORMAT, lReturn.Format()); } return lReturn; } diff --git a/src/system/SystemLayerImplSelect.cpp b/src/system/SystemLayerImplSelect.cpp index 8cd3e6992e2f7b..96e0907402925e 100644 --- a/src/system/SystemLayerImplSelect.cpp +++ b/src/system/SystemLayerImplSelect.cpp @@ -380,7 +380,7 @@ void LayerImplSelect::HandleEvents() if (!IsSelectResultValid()) { - ChipLogError(DeviceLayer, "select failed: %s\n", ErrorStr(CHIP_ERROR_POSIX(errno))); + ChipLogError(DeviceLayer, "Select failed: %" CHIP_ERROR_FORMAT, CHIP_ERROR_POSIX(errno).Format()); return; } diff --git a/src/system/WakeEvent.cpp b/src/system/WakeEvent.cpp index a670cc687cff3c..ab115025006d03 100644 --- a/src/system/WakeEvent.cpp +++ b/src/system/WakeEvent.cpp @@ -101,7 +101,8 @@ void WakeEvent::Confirm() const res = ::read(mReadFD, buffer, sizeof(buffer)); if (res < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { - ChipLogError(chipSystemLayer, "System wake event confirm failed: %s", ErrorStr(CHIP_ERROR_POSIX(errno))); + ChipLogError(chipSystemLayer, "System wake event confirm failed: %" CHIP_ERROR_FORMAT, + CHIP_ERROR_POSIX(errno).Format()); return; } } while (res == sizeof(buffer)); @@ -149,7 +150,7 @@ void WakeEvent::Confirm() const if (::read(mReadFD, &value, sizeof(value)) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { - ChipLogError(chipSystemLayer, "System wake event confirm failed: %s", ErrorStr(CHIP_ERROR_POSIX(errno))); + ChipLogError(chipSystemLayer, "System wake event confirm failed: %" CHIP_ERROR_FORMAT, CHIP_ERROR_POSIX(errno).Format()); } } diff --git a/src/test_driver/nrfconnect/main/runner.cpp b/src/test_driver/nrfconnect/main/runner.cpp index dc2f697a020a61..b7654f70a1f514 100644 --- a/src/test_driver/nrfconnect/main/runner.cpp +++ b/src/test_driver/nrfconnect/main/runner.cpp @@ -16,7 +16,6 @@ */ #include -#include #include #include diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index b60457fd5586aa..a7933d64952113 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -65,7 +65,7 @@ uint32_t EncryptedPacketBufferHandle::GetMessageCounter() const return header.GetMessageCounter(); } - ChipLogError(Inet, "Failed to decode EncryptedPacketBufferHandle header with error: %s", ErrorStr(err)); + ChipLogError(Inet, "Failed to decode EncryptedPacketBufferHandle header with error: %" CHIP_ERROR_FORMAT, err.Format()); return 0; } diff --git a/src/transport/raw/BLE.cpp b/src/transport/raw/BLE.cpp index d1581b4d97db26..7e40857f62325c 100644 --- a/src/transport/raw/BLE.cpp +++ b/src/transport/raw/BLE.cpp @@ -150,14 +150,14 @@ void BLEBase::OnBleConnectionComplete(Ble::BLEEndPoint * endPoint) mBleEndPoint->Close(); mBleEndPoint = nullptr; } - ChipLogError(Inet, "Failed to setup BLE endPoint: %s", ErrorStr(err)); + ChipLogError(Inet, "Failed to setup BLE endPoint: %" CHIP_ERROR_FORMAT, err.Format()); } } void BLEBase::OnBleConnectionError(CHIP_ERROR err) { ClearPendingPackets(); - ChipLogDetail(Inet, "BleConnection Error: %s", ErrorStr(err)); + ChipLogDetail(Inet, "BleConnection Error: %" CHIP_ERROR_FORMAT, err.Format()); } void BLEBase::OnEndPointMessageReceived(BLEEndPoint * endPoint, PacketBufferHandle && buffer) @@ -171,7 +171,7 @@ void BLEBase::OnEndPointConnectComplete(BLEEndPoint * endPoint, CHIP_ERROR err) if (err != CHIP_NO_ERROR) { - ChipLogError(Inet, "Failed to establish BLE connection: %s", ErrorStr(err)); + ChipLogError(Inet, "Failed to establish BLE connection: %" CHIP_ERROR_FORMAT, err.Format()); OnEndPointConnectionClosed(endPoint, err); return; } @@ -183,7 +183,7 @@ void BLEBase::OnEndPointConnectComplete(BLEEndPoint * endPoint, CHIP_ERROR err) err = endPoint->Send(std::move(mPendingPackets[i])); if (err != CHIP_NO_ERROR) { - ChipLogError(Inet, "Deferred sending failed: %s", ErrorStr(err)); + ChipLogError(Inet, "Deferred sending failed: %" CHIP_ERROR_FORMAT, err.Format()); } } } diff --git a/src/transport/raw/UDP.cpp b/src/transport/raw/UDP.cpp index fb21d390082c80..57b1d3c615bffc 100644 --- a/src/transport/raw/UDP.cpp +++ b/src/transport/raw/UDP.cpp @@ -68,7 +68,7 @@ CHIP_ERROR UDP::Init(UdpListenParameters & params) exit: if (err != CHIP_NO_ERROR) { - ChipLogProgress(Inet, "Failed to initialize Udp transport: %s", ErrorStr(err)); + ChipLogProgress(Inet, "Failed to initialize Udp transport: %" CHIP_ERROR_FORMAT, err.Format()); if (mUDPEndPoint) { mUDPEndPoint->Free(); @@ -123,13 +123,13 @@ void UDP::OnUdpReceive(Inet::UDPEndPoint * endPoint, System::PacketBufferHandle if (err != CHIP_NO_ERROR) { - ChipLogError(Inet, "Failed to receive UDP message: %s", ErrorStr(err)); + ChipLogError(Inet, "Failed to receive UDP message: %" CHIP_ERROR_FORMAT, err.Format()); } } void UDP::OnUdpError(Inet::UDPEndPoint * endPoint, CHIP_ERROR err, const Inet::IPPacketInfo * pktInfo) { - ChipLogError(Inet, "Failed to receive UDP message: %s", ErrorStr(err)); + ChipLogError(Inet, "Failed to receive UDP message: %" CHIP_ERROR_FORMAT, err.Format()); } CHIP_ERROR UDP::MulticastGroupJoinLeave(const Transport::PeerAddress & address, bool join)