From 958872648ac2bef66268c600a86c67ad15920a84 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Thu, 10 Apr 2025 11:10:21 +0200 Subject: [PATCH] net: openthread: Fix ignored return values in platform diag module Verify return values for otPlatRadio* functions and log the error accordingly. For otPlatRadioTransmit() case, just log the error and let the entire TX procedure proceed on the next timeout. Signed-off-by: Robert Lubos --- modules/openthread/platform/diag.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/openthread/platform/diag.c b/modules/openthread/platform/diag.c index 79f4e38984a..3bd4b549536 100644 --- a/modules/openthread/platform/diag.c +++ b/modules/openthread/platform/diag.c @@ -90,10 +90,16 @@ otError otPlatDiagProcess(otInstance *aInstance, uint8_t aArgsLength, char *aArg void otPlatDiagModeSet(bool aMode) { + otError error; + sDiagMode = aMode; if (!sDiagMode) { - otPlatRadioSleep(NULL); + error = otPlatRadioSleep(NULL); + if (error != OT_ERROR_NONE) { + otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM, + "%s failed (%d)", "otPlatRadioSleep", error); + } } } @@ -345,6 +351,7 @@ static otError startModCarrier(otInstance *aInstance, uint8_t aArgsLength, char void otPlatDiagAlarmCallback(otInstance *aInstance) { uint32_t now; + otError error; otRadioFrame *txPacket; const uint16_t diag_packet_len = 30; @@ -370,7 +377,11 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) txPacket->mPsdu[i] = i; } - otPlatRadioTransmit(aInstance, txPacket); + error = otPlatRadioTransmit(aInstance, txPacket); + if (error != OT_ERROR_NONE) { + otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM, + "%s failed (%d)", "otPlatRadioTransmit", error); + } if (sTxCount != -1) { sTxCount--; @@ -405,8 +416,11 @@ static otError processTransmit(otInstance *aInstance, uint8_t aArgsLength, char otPlatAlarmMilliStop(aInstance); diag_output("diagnostic message transmission is stopped\r\n"); sTransmitMode = DIAG_TRANSMIT_MODE_IDLE; - otPlatRadioReceive(aInstance, sChannel); - + error = otPlatRadioReceive(aInstance, sChannel); + if (error != OT_ERROR_NONE) { + otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM, + "%s failed (%d)", "otPlatRadioReceive", error); + } } else if (strcmp(aArgs[0], "start") == 0) { if (sTransmitMode != DIAG_TRANSMIT_MODE_IDLE) { return OT_ERROR_INVALID_STATE;