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

@@ -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;