[spinel] remove incorrect static_cast (#8512)

This should not be cast to an unsigned integer. If the
mRadioTimeOffset is negative, the resulting time instance is incorrect
and breaks e.g. CSL over RCP.
This commit is contained in:
Thomas
2022-12-19 14:50:54 -08:00
committed by GitHub
parent 58c9ca84ff
commit 1641eced0d
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -1079,7 +1079,7 @@ private:
uint64_t mTxRadioEndUs;
uint64_t mRadioTimeRecalcStart; ///< When to recalculate RCP time offset.
int64_t mRadioTimeOffset; ///< Time difference with estimated RCP time minus host time.
uint64_t mRadioTimeOffset; ///< Time difference with estimated RCP time minus host time.
MaxPowerTable mMaxPowerTable;
+3 -3
View File
@@ -218,7 +218,7 @@ RadioSpinel<InterfaceType, ProcessContextType>::RadioSpinel(void)
#endif
, mTxRadioEndUs(UINT64_MAX)
, mRadioTimeRecalcStart(UINT64_MAX)
, mRadioTimeOffset(0)
, mRadioTimeOffset(UINT64_MAX)
{
mVersion[0] = '\0';
memset(&mRadioSpinelMetrics, 0, sizeof(mRadioSpinelMetrics));
@@ -2201,7 +2201,7 @@ void RadioSpinel<InterfaceType, ProcessContextType>::CalcRcpTimeOffset(void)
VerifyOrExit(error == OT_ERROR_NONE, mRadioTimeRecalcStart = localRxTimestamp);
mRadioTimeOffset = static_cast<int64_t>(remoteTimestamp - ((localRxTimestamp / 2) + (localTxTimestamp / 2)));
mRadioTimeOffset = (remoteTimestamp - ((localRxTimestamp / 2) + (localTxTimestamp / 2)));
mIsTimeSynced = true;
mRadioTimeRecalcStart = localRxTimestamp + RCP_TIME_OFFSET_CHECK_INTERVAL;
@@ -2213,7 +2213,7 @@ exit:
template <typename InterfaceType, typename ProcessContextType>
uint64_t RadioSpinel<InterfaceType, ProcessContextType>::GetNow(void)
{
return mIsTimeSynced ? (otPlatTimeGet() + static_cast<uint64_t>(mRadioTimeOffset)) : UINT64_MAX;
return (mIsTimeSynced) ? (otPlatTimeGet() + mRadioTimeOffset) : UINT64_MAX;
}
template <typename InterfaceType, typename ProcessContextType>