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:
Peter Johnson
2020-12-28 12:58:06 -08:00
committed by GitHub
parent 0291a3ff56
commit 2aed432b4b
634 changed files with 10716 additions and 3938 deletions

View File

@@ -43,8 +43,12 @@ void InitializeDigitalInternal() {
} // namespace init
namespace detail {
wpi::mutex& UnsafeGetDIOMutex() { return digitalDIOMutex; }
tDIO* UnsafeGetDigialSystem() { return digitalSystem.get(); }
wpi::mutex& UnsafeGetDIOMutex() {
return digitalDIOMutex;
}
tDIO* UnsafeGetDigialSystem() {
return digitalSystem.get();
}
int32_t ComputeDigitalMask(HAL_DigitalHandle handle, int32_t* status) {
auto port = digitalChannelHandles->Get(handle, HAL_HandleEnum::DIO);
if (port == nullptr) {
@@ -69,11 +73,15 @@ void initializeDigital(int32_t* status) {
static std::atomic_bool initialized{false};
static wpi::mutex initializeMutex;
// Initial check, as if it's true initialization has finished
if (initialized) return;
if (initialized) {
return;
}
std::scoped_lock lock(initializeMutex);
// Second check in case another thread was waiting
if (initialized) return;
if (initialized) {
return;
}
digitalSystem.reset(tDIO::create(status));
@@ -89,7 +97,8 @@ void initializeDigital(int32_t* status) {
// Make sure that the 9403 IONode has had a chance to initialize before
// continuing.
while (pwmSystem->readLoopTiming(status) == 0) std::this_thread::yield();
while (pwmSystem->readLoopTiming(status) == 0)
std::this_thread::yield();
if (pwmSystem->readLoopTiming(status) != kExpectedLoopTiming) {
*status = LOOP_TIMING_ERROR; // NOTE: Doesn't display the error
@@ -160,7 +169,9 @@ bool remapDigitalSource(HAL_Handle digitalSourceHandle,
}
}
int32_t remapMXPChannel(int32_t channel) { return channel - 10; }
int32_t remapMXPChannel(int32_t channel) {
return channel - 10;
}
int32_t remapMXPPWMChannel(int32_t channel) {
if (channel < 14) {
@@ -170,7 +181,9 @@ int32_t remapMXPPWMChannel(int32_t channel) {
}
}
int32_t remapSPIChannel(int32_t channel) { return channel - 26; }
int32_t remapSPIChannel(int32_t channel) {
return channel - 26;
}
} // namespace hal