mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user