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

@@ -22,7 +22,9 @@ I2C::I2C(Port port, int deviceAddress)
HAL_Report(HALUsageReporting::kResourceType_I2C, deviceAddress);
}
I2C::~I2C() { HAL_CloseI2C(m_port); }
I2C::~I2C() {
HAL_CloseI2C(m_port);
}
bool I2C::Transaction(uint8_t* dataToSend, int sendSize, uint8_t* dataReceived,
int receiveSize) {
@@ -33,7 +35,9 @@ bool I2C::Transaction(uint8_t* dataToSend, int sendSize, uint8_t* dataReceived,
return status < 0;
}
bool I2C::AddressOnly() { return Transaction(nullptr, 0, nullptr, 0); }
bool I2C::AddressOnly() {
return Transaction(nullptr, 0, nullptr, 0);
}
bool I2C::Write(int registerAddress, uint8_t data) {
uint8_t buffer[2];
@@ -83,10 +87,14 @@ bool I2C::VerifySensor(int registerAddress, int count,
i += 4, curRegisterAddress += 4) {
int toRead = count - i < 4 ? count - i : 4;
// Read the chunk of data. Return false if the sensor does not respond.
if (Read(curRegisterAddress, toRead, deviceData)) return false;
if (Read(curRegisterAddress, toRead, deviceData)) {
return false;
}
for (int j = 0; j < toRead; j++) {
if (deviceData[j] != expected[i + j]) return false;
if (deviceData[j] != expected[i + j]) {
return false;
}
}
}
return true;