mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Fix clang-tidy warnings (#4359)
The warnings included recommendations of braces for if statement readability, a recommendation for default initialization of an int array, and include-what-you-use (indirectly through clang-tidy reporting undefined symbols).
This commit is contained in:
@@ -121,8 +121,9 @@ static void writeRegister(Register reg, uint8_t data) {
|
||||
// Execute and wait until it's done (up to a millisecond)
|
||||
initialTime = HAL_GetFPGATime(&status);
|
||||
while (accel->readSTAT(&status) & 1) {
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000)
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Send a stop transmit/receive message with the data
|
||||
@@ -133,8 +134,9 @@ static void writeRegister(Register reg, uint8_t data) {
|
||||
// Execute and wait until it's done (up to a millisecond)
|
||||
initialTime = HAL_GetFPGATime(&status);
|
||||
while (accel->readSTAT(&status) & 1) {
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000)
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,8 +153,9 @@ static uint8_t readRegister(Register reg) {
|
||||
// Execute and wait until it's done (up to a millisecond)
|
||||
initialTime = HAL_GetFPGATime(&status);
|
||||
while (accel->readSTAT(&status) & 1) {
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000)
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Receive a message with the data and stop
|
||||
@@ -163,8 +166,9 @@ static uint8_t readRegister(Register reg) {
|
||||
// Execute and wait until it's done (up to a millisecond)
|
||||
initialTime = HAL_GetFPGATime(&status);
|
||||
while (accel->readSTAT(&status) & 1) {
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000)
|
||||
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return accel->readDATI(&status);
|
||||
|
||||
@@ -23,8 +23,9 @@ HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle,
|
||||
return false;
|
||||
}
|
||||
for (int32_t i = 0; i < kNumAccumulators; i++) {
|
||||
if (port->channel == kAccumulatorChannels[i])
|
||||
if (port->channel == kAccumulatorChannels[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,8 +133,9 @@ HAL_Bool HAL_CheckDIOChannel(int32_t channel) {
|
||||
void HAL_FreeDIOPort(HAL_DigitalHandle dioPortHandle) {
|
||||
auto port = digitalChannelHandles->Get(dioPortHandle, HAL_HandleEnum::DIO);
|
||||
// no status, so no need to check for a proper free.
|
||||
if (port == nullptr)
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
digitalChannelHandles->Free(dioPortHandle, HAL_HandleEnum::DIO);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
|
||||
@@ -130,8 +130,9 @@ void HAL_FreeDMA(HAL_DMAHandle handle) {
|
||||
auto dma = dmaHandles->Get(handle);
|
||||
dmaHandles->Free(handle);
|
||||
|
||||
if (!dma)
|
||||
if (!dma) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
if (dma->manager) {
|
||||
|
||||
@@ -98,8 +98,9 @@ void initializeDigital(int32_t* status) {
|
||||
|
||||
// Make sure that the 9403 IONode has had a chance to initialize before
|
||||
// continuing.
|
||||
while (pwmSystem->readLoopTiming(status) == 0)
|
||||
while (pwmSystem->readLoopTiming(status) == 0) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
|
||||
if (pwmSystem->readLoopTiming(status) != kExpectedLoopTiming) {
|
||||
*status = LOOP_TIMING_ERROR; // NOTE: Doesn't display the error
|
||||
|
||||
@@ -113,8 +113,9 @@ static void notifierThreadMain() {
|
||||
if (!notifierRunning) {
|
||||
break;
|
||||
}
|
||||
if (triggeredMask == 0)
|
||||
if (triggeredMask == 0) {
|
||||
continue;
|
||||
}
|
||||
alarmCallback();
|
||||
}
|
||||
}
|
||||
@@ -195,8 +196,9 @@ void HAL_SetNotifierName(HAL_NotifierHandle notifierHandle, const char* name,
|
||||
|
||||
void HAL_StopNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
|
||||
auto notifier = notifierHandles->Get(notifierHandle);
|
||||
if (!notifier)
|
||||
if (!notifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
std::scoped_lock lock(notifier->mutex);
|
||||
@@ -209,8 +211,9 @@ void HAL_StopNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
|
||||
|
||||
void HAL_CleanNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
|
||||
auto notifier = notifierHandles->Free(notifierHandle);
|
||||
if (!notifier)
|
||||
if (!notifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Just in case HAL_StopNotifier() wasn't called...
|
||||
{
|
||||
@@ -244,8 +247,9 @@ void HAL_CleanNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
|
||||
void HAL_UpdateNotifierAlarm(HAL_NotifierHandle notifierHandle,
|
||||
uint64_t triggerTime, int32_t* status) {
|
||||
auto notifier = notifierHandles->Get(notifierHandle);
|
||||
if (!notifier)
|
||||
if (!notifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
std::scoped_lock lock(notifier->mutex);
|
||||
@@ -270,8 +274,9 @@ void HAL_UpdateNotifierAlarm(HAL_NotifierHandle notifierHandle,
|
||||
void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
|
||||
int32_t* status) {
|
||||
auto notifier = notifierHandles->Get(notifierHandle);
|
||||
if (!notifier)
|
||||
if (!notifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
std::scoped_lock lock(notifier->mutex);
|
||||
@@ -282,8 +287,9 @@ void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
|
||||
uint64_t HAL_WaitForNotifierAlarm(HAL_NotifierHandle notifierHandle,
|
||||
int32_t* status) {
|
||||
auto notifier = notifierHandles->Get(notifierHandle);
|
||||
if (!notifier)
|
||||
if (!notifier) {
|
||||
return 0;
|
||||
}
|
||||
std::unique_lock lock(notifier->mutex);
|
||||
notifier->cond.wait(lock, [&] {
|
||||
return !notifier->active || notifier->triggeredTime != UINT64_MAX;
|
||||
|
||||
@@ -236,8 +236,9 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t module,
|
||||
|
||||
void HAL_FreeREVPH(HAL_REVPHHandle handle) {
|
||||
auto hph = REVPHHandles->Get(handle);
|
||||
if (hph == nullptr)
|
||||
if (hph == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
HAL_CleanCAN(hph->hcan);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user