From 6c9bba544542f56b1b1a77d82a6dd8df00e40386 Mon Sep 17 00:00:00 2001 From: Ciaran Woodward Date: Tue, 1 Aug 2017 16:37:11 +0100 Subject: [PATCH] [mac] Print warnings on failure, not success (#2049) In Mac::RadioReceive, Mac::RadioTransmit and Mac::RadioSleep, the SuccessOrExit macro was being used in a way which skipped printing an error message upon failure, and printed it for OT_ERROR_NONE. --- src/core/mac/mac.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 6e34303f8..0719d5403 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -1097,9 +1097,13 @@ otError Mac::RadioTransmit(Frame *aSendFrame) SuccessOrExit(error = otPlatRadioTransmit(&GetInstance(), static_cast(aSendFrame))); - otLogWarnMac(GetInstance(), "otPlatRadioTransmit() failed with error %s", otThreadErrorToString(error)); - exit: + + if (error != OT_ERROR_NONE) + { + otLogWarnMac(GetInstance(), "otPlatRadioTransmit() failed with error %s", otThreadErrorToString(error)); + } + return error; } @@ -1119,9 +1123,13 @@ otError Mac::RadioReceive(uint8_t aChannel) SuccessOrExit(error = otPlatRadioReceive(&GetInstance(), aChannel)); - otLogWarnMac(GetInstance(), "otPlatRadioReceive() failed with error %s", otThreadErrorToString(error)); - exit: + + if (error != OT_ERROR_NONE) + { + otLogWarnMac(GetInstance(), "otPlatRadioReceive() failed with error %s", otThreadErrorToString(error)); + } + return error; } @@ -1146,11 +1154,16 @@ otError Mac::RadioSleep(void) } #endif + SuccessOrExit(error = otPlatRadioSleep(&GetInstance())); - otLogWarnMac(GetInstance(), "otPlatRadioSleep() failed with error %s", otThreadErrorToString(error)); - exit: + + if (error != OT_ERROR_NONE) + { + otLogWarnMac(GetInstance(), "otPlatRadioSleep() failed with error %s", otThreadErrorToString(error)); + } + return error; }