mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[wakeup-tx-scheduler] fix potential integer conversion warnings (#11842)
This commit resolves compiler warnings/errors related to potential integer overflows and unsafe narrowing conversions. - The type of `mTxRequestAheadTimeUs` is changed from `uint16_t` to `uint32_t` to avoid potential overflow when calculating the TX time. - A `ClampToUint16()` utility is now used before setting the rendezvous time. This safely converts the calculated `rendezvousTimeUs` to a 16-bit integer, preventing a narrowing conversion warning.
This commit is contained in:
@@ -110,7 +110,8 @@ Mac::TxFrame *WakeupTxScheduler::PrepareWakeupFrame(Mac::TxFrames &aTxFrames)
|
||||
// the "free space" between the "n+1"-th and "n+2"-th wake-up frame.
|
||||
rendezvousTimeUs = mIntervalUs;
|
||||
rendezvousTimeUs += (mIntervalUs - (kWakeupFrameLength + kParentRequestLength) * kOctetDuration) / 2;
|
||||
frame->GetRendezvousTimeIe()->SetRendezvousTime(rendezvousTimeUs / kUsPerTenSymbols);
|
||||
|
||||
frame->GetRendezvousTimeIe()->SetRendezvousTime(ClampToUint16(rendezvousTimeUs / kUsPerTenSymbols));
|
||||
|
||||
connectionIe = frame->GetConnectionIe();
|
||||
connectionIe->SetRetryInterval(kConnectionRetryInterval);
|
||||
|
||||
@@ -119,7 +119,7 @@ private:
|
||||
Mac::ExtAddress mWedAddress;
|
||||
TimeMicro mTxTimeUs; // Point in time when the next TX occurs.
|
||||
TimeMicro mTxEndTimeUs; // Point in time when the wake-up sequence is over.
|
||||
uint16_t mTxRequestAheadTimeUs; // How much ahead the TX MAC operation needs to be requested.
|
||||
uint32_t mTxRequestAheadTimeUs; // How much ahead the TX MAC operation needs to be requested.
|
||||
uint16_t mIntervalUs; // Interval between consecutive wake-up frames.
|
||||
WakeupTimer mTimer;
|
||||
bool mIsRunning;
|
||||
|
||||
Reference in New Issue
Block a user