From 81688a044767faf1fd4ca842dbfea497f1cf4c24 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 27 Oct 2020 11:39:35 -0700 Subject: [PATCH] [clang-tidy] modernize-use-nullptr (#5715) --- include/openthread/coap.h | 2 ++ include/openthread/instance.h | 2 +- script/make-pretty | 1 + src/cli/cli.cpp | 2 +- src/lib/spinel/spinel_buffer.hpp | 4 ++-- tests/unit/test_platform.cpp | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/openthread/coap.h b/include/openthread/coap.h index 9884593fa..a9da2d99e 100644 --- a/include/openthread/coap.h +++ b/include/openthread/coap.h @@ -826,6 +826,7 @@ static inline otError otCoapSendRequest(otInstance * aInstance, otCoapResponseHandler aHandler, void * aContext) { + // NOLINTNEXTLINE(modernize-use-nullptr) return otCoapSendRequestWithParameters(aInstance, aMessage, aMessageInfo, aHandler, aContext, NULL); } @@ -909,6 +910,7 @@ otError otCoapSendResponseWithParameters(otInstance * aInstance, */ static inline otError otCoapSendResponse(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo) { + // NOLINTNEXTLINE(modernize-use-nullptr) return otCoapSendResponseWithParameters(aInstance, aMessage, aMessageInfo, NULL); } diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 6d7c87a53..63b7ed9cd 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (38) +#define OPENTHREAD_API_VERSION (39) /** * @addtogroup api-instance diff --git a/script/make-pretty b/script/make-pretty index 5e4aafa00..28214113f 100755 --- a/script/make-pretty +++ b/script/make-pretty @@ -117,6 +117,7 @@ readonly OT_CLANG_TIDY_BUILD_OPTS=( readonly OT_CLANG_TIDY_CHECKS="\ -*,\ modernize-use-bool-literals,\ +modernize-use-nullptr,\ readability-make-member-function-const,\ " diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index eb60ec810..13e726913 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -3701,7 +3701,7 @@ otError Interpreter::ProcessUnsecurePort(uint8_t aArgsLength, char *aArgs[]) ports = otIp6GetUnsecurePorts(mInstance, &numPorts); - if (ports != NULL) + if (ports != nullptr) { for (uint8_t i = 0; i < numPorts; i++) { diff --git a/src/lib/spinel/spinel_buffer.hpp b/src/lib/spinel/spinel_buffer.hpp index 2c216ce09..c86b67c19 100644 --- a/src/lib/spinel/spinel_buffer.hpp +++ b/src/lib/spinel/spinel_buffer.hpp @@ -92,8 +92,8 @@ public: * */ WritePosition(void) - : mPosition(0) - , mSegmentHead(0) + : mPosition(nullptr) + , mSegmentHead(nullptr) { } diff --git a/tests/unit/test_platform.cpp b/tests/unit/test_platform.cpp index 0e2f8370b..035c2d34b 100644 --- a/tests/unit/test_platform.cpp +++ b/tests/unit/test_platform.cpp @@ -302,7 +302,7 @@ otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) } else { - return (otRadioFrame *)0; + return nullptr; } }