diff --git a/examples/platforms/posix/alarm.c b/examples/platforms/posix/alarm.c index be69b2b7b..ef2ca61d2 100644 --- a/examples/platforms/posix/alarm.c +++ b/examples/platforms/posix/alarm.c @@ -151,7 +151,11 @@ void platformAlarmUpdateTimeout(struct timeval *aTimeout) remaining = 1; } - aTimeout->tv_sec = (time_t)remaining / US_PER_S; +#ifndef _WIN32 + aTimeout->tv_sec = (time_t)remaining / US_PER_S; +#else + aTimeout->tv_sec = (long)remaining / US_PER_S; +#endif aTimeout->tv_usec = remaining % US_PER_S; } } diff --git a/examples/platforms/posix/platform-posix.h b/examples/platforms/posix/platform-posix.h index 94d8e8631..2d797d9eb 100644 --- a/examples/platforms/posix/platform-posix.h +++ b/examples/platforms/posix/platform-posix.h @@ -49,7 +49,7 @@ #include #include #define POLL WSAPoll -#define ssize_t int +#define ssize_t long #include #define localtime _localtime32 // In user mode, define some Linux functions diff --git a/examples/platforms/posix/radio.c b/examples/platforms/posix/radio.c index f4a2f3657..78dc9f9fd 100644 --- a/examples/platforms/posix/radio.c +++ b/examples/platforms/posix/radio.c @@ -446,7 +446,11 @@ void platformRadioInit(void) void platformRadioDeinit(void) { +#ifndef _WIN32 close(sSockFd); +#else + closesocket(sSockFd); +#endif } bool otPlatRadioIsEnabled(otInstance *aInstance) @@ -841,7 +845,7 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) sSrcMatchEnabled = aEnable; } -otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) +otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); @@ -881,7 +885,7 @@ exit: return error; } -otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) +otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); diff --git a/examples/platforms/posix/sim/radio-sim.c b/examples/platforms/posix/sim/radio-sim.c index 0279de4fa..d22b9db51 100644 --- a/examples/platforms/posix/sim/radio-sim.c +++ b/examples/platforms/posix/sim/radio-sim.c @@ -671,7 +671,7 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) sSrcMatchEnabled = aEnable; } -otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) +otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); @@ -711,7 +711,7 @@ exit: return error; } -otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) +otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); diff --git a/src/ncp/spinel_decoder.cpp b/src/ncp/spinel_decoder.cpp index 060a3ac15..5535e687e 100644 --- a/src/ncp/spinel_decoder.cpp +++ b/src/ncp/spinel_decoder.cpp @@ -216,7 +216,7 @@ exit: } // Reads an item of given size and updates the pointer `aPtr`. -otError SpinelDecoder::ReadItem(const uint8_t **aPtr, size_t aSize) +otError SpinelDecoder::ReadItem(const uint8_t **aPtr, uint16_t aSize) { otError error = OT_ERROR_NONE; @@ -303,7 +303,8 @@ otError SpinelDecoder::ReadUtf8(const char *&aUtf8) aUtf8 = reinterpret_cast(&mFrame[mIndex]); - mIndex += (len + sizeof(uint8_t)); // `sizeof(uint8_t)` is added for the terminating null character. + // `sizeof(uint8_t)` is added for the terminating null character. + mIndex += static_cast(len + sizeof(uint8_t)); exit: return error; diff --git a/src/ncp/spinel_decoder.hpp b/src/ncp/spinel_decoder.hpp index 96780cdd5..1fee147ab 100644 --- a/src/ncp/spinel_decoder.hpp +++ b/src/ncp/spinel_decoder.hpp @@ -564,7 +564,7 @@ public: otError ResetToSaved(void); private: - otError ReadItem(const uint8_t **aPtr, size_t aSize); + otError ReadItem(const uint8_t **aPtr, uint16_t aSize); void ClearSavedPosition(void) { mSavedIndex = mLength; } bool IsSavedPositionValid(void) const { return (mSavedIndex < mLength); } diff --git a/src/posix/platform/radio_spinel.cpp b/src/posix/platform/radio_spinel.cpp index 1aacfd8da..989dc05ee 100644 --- a/src/posix/platform/radio_spinel.cpp +++ b/src/posix/platform/radio_spinel.cpp @@ -1467,7 +1467,7 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) OT_UNUSED_VARIABLE(aInstance); } -otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) +otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); return sRadioSpinel.AddSrcMatchShortEntry(aShortAddress); @@ -1486,7 +1486,7 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress return sRadioSpinel.AddSrcMatchExtEntry(addr); } -otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) +otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); return sRadioSpinel.ClearSrcMatchShortEntry(aShortAddress); diff --git a/tests/unit/test_link_quality.cpp b/tests/unit/test_link_quality.cpp index caccb117c..262847b79 100644 --- a/tests/unit/test_link_quality.cpp +++ b/tests/unit/test_link_quality.cpp @@ -142,7 +142,7 @@ int8_t GetRandomRss(void) uint32_t value; value = otPlatRandomGet() % 128; - return static_cast(-value); + return -static_cast(value); } void TestRssAveraging(void)