Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1627d319 authored by Jorge E. Moreira's avatar Jorge E. Moreira Committed by Myles Watson
Browse files

test_vendor: Use kInvalidTaskId in the controller

Test: make test-vendor

Change-Id: I6eefd385ecb992f854544ca92c5a8559b6f281f0
parent 27b7af10
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ using TaskCallback = std::function<void(void)>;
using ReadCallback = std::function<void(int)>;
using CriticalCallback = std::function<void(void)>;
using AsyncTaskId = uint16_t;
constexpr uint16_t kInvalidTaskId = 0;

// Manages tasks that should be done in the future. It can watch file
// descriptors to call a given callback when it is certain that a block will not
+0 −1
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ namespace test_vendor_lib {
// at a given time
static const uint16_t kMaxTaskId =
    -1; /* 2^16 - 1, permisible ids are {1..2^16-1}*/
static const uint16_t kInvalidTaskId = 0;
static inline AsyncTaskId NextAsyncTaskId(const AsyncTaskId id) {
  return (id == kMaxTaskId) ? 1 : id + 1;
}
+3 −3
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ void DualModeController::HandleTimerTick() {
void DualModeController::SetTimerPeriod(std::chrono::milliseconds new_period) {
  timer_period_ = new_period;

  if (timer_tick_task_ == 0)
  if (timer_tick_task_ == kInvalidTaskId)
    return;

  // Restart the timer with the new period
@@ -261,7 +261,7 @@ void DualModeController::StartTimer() {
void DualModeController::StopTimer() {
  LOG_ERROR(LOG_TAG, "StopTimer");
  cancel_task_(timer_tick_task_);
  timer_tick_task_ = 0;
  timer_tick_task_ = kInvalidTaskId;
}

void DualModeController::TestChannelClear(
@@ -302,7 +302,7 @@ void DualModeController::TestChannelClearEventDelay(
void DualModeController::HciReset(UNUSED_ATTR const vector<uint8_t>& args) {
  LogCommand("Reset");
  state_ = kStandby;
  if (timer_tick_task_ != 0) {
  if (timer_tick_task_ != kInvalidTaskId) {
    LOG_INFO(LOG_TAG, "The timer was already running!");
    StopTimer();
  }