mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -36,7 +36,9 @@ extern "C" {
|
||||
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
if (*status != 0) return HAL_kInvalidHandle;
|
||||
if (*status != 0) {
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
int16_t channel = getPortHandleChannel(portHandle);
|
||||
if (channel == InvalidHandleIndex) {
|
||||
@@ -44,12 +46,15 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
if (!fwd) channel += kNumRelayHeaders; // add 4 to reverse channels
|
||||
if (!fwd) {
|
||||
channel += kNumRelayHeaders; // add 4 to reverse channels
|
||||
}
|
||||
|
||||
auto handle = relayHandles->Allocate(channel, status);
|
||||
|
||||
if (*status != 0)
|
||||
if (*status != 0) {
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
auto port = relayHandles->Get(handle);
|
||||
if (port == nullptr) { // would only occur on thread issue.
|
||||
@@ -77,11 +82,14 @@ HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
|
||||
void HAL_FreeRelayPort(HAL_RelayHandle relayPortHandle) {
|
||||
auto port = relayHandles->Get(relayPortHandle);
|
||||
relayHandles->Free(relayPortHandle);
|
||||
if (port == nullptr) return;
|
||||
if (port->fwd)
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (port->fwd) {
|
||||
SimRelayData[port->channel].initializedForward = false;
|
||||
else
|
||||
} else {
|
||||
SimRelayData[port->channel].initializedReverse = false;
|
||||
}
|
||||
}
|
||||
|
||||
HAL_Bool HAL_CheckRelayChannel(int32_t channel) {
|
||||
@@ -98,10 +106,11 @@ void HAL_SetRelay(HAL_RelayHandle relayPortHandle, HAL_Bool on,
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
if (port->fwd)
|
||||
if (port->fwd) {
|
||||
SimRelayData[port->channel].forward = on;
|
||||
else
|
||||
} else {
|
||||
SimRelayData[port->channel].reverse = on;
|
||||
}
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t* status) {
|
||||
@@ -110,9 +119,10 @@ HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return false;
|
||||
}
|
||||
if (port->fwd)
|
||||
if (port->fwd) {
|
||||
return SimRelayData[port->channel].forward;
|
||||
else
|
||||
} else {
|
||||
return SimRelayData[port->channel].reverse;
|
||||
}
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user