mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01: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:
@@ -56,7 +56,9 @@ class WireDecoder {
|
||||
* Caution: the buffer is only temporarily valid.
|
||||
*/
|
||||
bool Read(const char** buf, size_t len) {
|
||||
if (len > m_allocated) Realloc(len);
|
||||
if (len > m_allocated) {
|
||||
Realloc(len);
|
||||
}
|
||||
*buf = m_buf;
|
||||
m_is.read(m_buf, len);
|
||||
#if 0
|
||||
@@ -78,7 +80,9 @@ class WireDecoder {
|
||||
/* Reads a single byte. */
|
||||
bool Read8(unsigned int* val) {
|
||||
const char* buf;
|
||||
if (!Read(&buf, 1)) return false;
|
||||
if (!Read(&buf, 1)) {
|
||||
return false;
|
||||
}
|
||||
*val = (*reinterpret_cast<const unsigned char*>(buf)) & 0xff;
|
||||
return true;
|
||||
}
|
||||
@@ -86,7 +90,9 @@ class WireDecoder {
|
||||
/* Reads a 16-bit word. */
|
||||
bool Read16(unsigned int* val) {
|
||||
const char* buf;
|
||||
if (!Read(&buf, 2)) return false;
|
||||
if (!Read(&buf, 2)) {
|
||||
return false;
|
||||
}
|
||||
unsigned int v = (*reinterpret_cast<const unsigned char*>(buf)) & 0xff;
|
||||
++buf;
|
||||
v <<= 8;
|
||||
@@ -98,7 +104,9 @@ class WireDecoder {
|
||||
/* Reads a 32-bit word. */
|
||||
bool Read32(uint32_t* val) {
|
||||
const char* buf;
|
||||
if (!Read(&buf, 4)) return false;
|
||||
if (!Read(&buf, 4)) {
|
||||
return false;
|
||||
}
|
||||
unsigned int v = (*reinterpret_cast<const unsigned char*>(buf)) & 0xff;
|
||||
++buf;
|
||||
v <<= 8;
|
||||
|
||||
Reference in New Issue
Block a user