From 5d4d74b1b5546778b52de9b6ea0b376344c21290 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Fri, 9 Nov 2018 01:00:49 +0800 Subject: [PATCH] [style] use debug.hpp instead of assert.h in core (#3276) --- src/cli/cli_instance.cpp | 38 +++++++++++++++++++++----------------- src/core/crypto/ecdsa.cpp | 3 +-- src/core/utils/heap.cpp | 2 +- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/cli/cli_instance.cpp b/src/cli/cli_instance.cpp index 558abc40a..c3f19ecb0 100644 --- a/src/cli/cli_instance.cpp +++ b/src/cli/cli_instance.cpp @@ -33,13 +33,14 @@ #include "openthread-core-config.h" -#include #include #include -#include "utils/wrap_string.h" #include "cli.hpp" +#include "common/debug.hpp" +#include "utils/wrap_string.h" + namespace ot { namespace Cli { @@ -52,9 +53,8 @@ void Interpreter::CacheInstances() otDeviceList *aDeviceList = otEnumerateDevices(mApiInstance); assert(aDeviceList); - mInstancesLength = aDeviceList->aDevicesLength > MAX_CLI_OT_INSTANCES ? - MAX_CLI_OT_INSTANCES : - (uint8_t)aDeviceList->aDevicesLength; + mInstancesLength = aDeviceList->aDevicesLength > MAX_CLI_OT_INSTANCES ? MAX_CLI_OT_INSTANCES + : (uint8_t)aDeviceList->aDevicesLength; for (uint8_t i = 0; i < mInstancesLength; i++) { @@ -66,12 +66,17 @@ void Interpreter::CacheInstances() otFreeMemory(aDeviceList); - if (mInstancesLength > 0) { mInstance = mInstances[0].mInstance; } + if (mInstancesLength > 0) + { + mInstance = mInstances[0].mInstance; + } } } #define GUID_FORMAT "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}" -#define GUID_ARG(guid) guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7] +#define GUID_ARG(guid) \ + guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], \ + guid.Data4[5], guid.Data4[6], guid.Data4[7] void Interpreter::ProcessInstanceList(int argc, char *argv[]) { @@ -79,17 +84,16 @@ void Interpreter::ProcessInstanceList(int argc, char *argv[]) for (uint8_t i = 0; i < mInstancesLength; i++) { - GUID aDeviceGuid = otGetDeviceGuid(mInstances[i].mInstance); + GUID aDeviceGuid = otGetDeviceGuid(mInstances[i].mInstance); uint32_t aCompartment = otGetCompartmentId(mInstances[i].mInstance); - mServer->OutputFormat("[%d] " GUID_FORMAT " (Compartment %u)\r\n", - i, GUID_ARG(aDeviceGuid), aCompartment); + mServer->OutputFormat("[%d] " GUID_FORMAT " (Compartment %u)\r\n", i, GUID_ARG(aDeviceGuid), aCompartment); } } void Interpreter::ProcessInstance(int argc, char *argv[]) { otError error = OT_ERROR_NONE; - long value; + long value; if (argc == 0) { @@ -99,10 +103,10 @@ void Interpreter::ProcessInstance(int argc, char *argv[]) } else { - GUID aDeviceGuid = otGetDeviceGuid(mInstance); + GUID aDeviceGuid = otGetDeviceGuid(mInstance); uint32_t aCompartment = otGetCompartmentId(mInstance); - mServer->OutputFormat("[%d] " GUID_FORMAT " (Compartment %u)\r\n", - mInstanceIndex, GUID_ARG(aDeviceGuid), aCompartment); + mServer->OutputFormat("[%d] " GUID_FORMAT " (Compartment %u)\r\n", mInstanceIndex, GUID_ARG(aDeviceGuid), + aCompartment); } } else @@ -111,7 +115,7 @@ void Interpreter::ProcessInstance(int argc, char *argv[]) VerifyOrExit(value >= 0 && value < mInstancesLength, error = OT_ERROR_INVALID_ARGS); mInstanceIndex = (uint8_t)value; - mInstance = mInstances[mInstanceIndex].mInstance; + mInstance = mInstances[mInstanceIndex].mInstance; } exit: @@ -119,5 +123,5 @@ exit: } #endif -} // namespace Cli -} // namespace ot +} // namespace Cli +} // namespace ot diff --git a/src/core/crypto/ecdsa.cpp b/src/core/crypto/ecdsa.cpp index 575afc67b..eac09cf70 100644 --- a/src/core/crypto/ecdsa.cpp +++ b/src/core/crypto/ecdsa.cpp @@ -33,12 +33,11 @@ #include "ecdsa.hpp" -#include - #include #include #include "common/code_utils.hpp" +#include "common/debug.hpp" #include "common/random.hpp" namespace ot { diff --git a/src/core/utils/heap.cpp b/src/core/utils/heap.cpp index e226e333d..e3bd2014c 100644 --- a/src/core/utils/heap.cpp +++ b/src/core/utils/heap.cpp @@ -34,10 +34,10 @@ #include "heap.hpp" -#include #include #include "common/code_utils.hpp" +#include "common/debug.hpp" namespace ot { namespace Utils {