[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:
Abtin Keshavarzian
2025-08-22 11:16:58 -07:00
committed by GitHub
parent c5f66c9e02
commit 258f467250
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -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);
+1 -1
View File
@@ -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;