mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +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:
@@ -21,7 +21,9 @@ namespace cs {
|
||||
static wpi::StringRef GetUsbNameFromFile(int vendor, int product,
|
||||
wpi::SmallVectorImpl<char>& buf) {
|
||||
int fd = open("/var/lib/usbutils/usb.ids", O_RDONLY);
|
||||
if (fd < 0) return wpi::StringRef{};
|
||||
if (fd < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
wpi::raw_svector_ostream os{buf};
|
||||
wpi::raw_fd_istream is{fd, true};
|
||||
@@ -37,9 +39,13 @@ static wpi::StringRef GetUsbNameFromFile(int vendor, int product,
|
||||
bool foundVendor = false;
|
||||
for (;;) {
|
||||
auto line = is.getline(lineBuf, 4096);
|
||||
if (is.has_error()) break;
|
||||
if (is.has_error()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (line.empty()) continue;
|
||||
if (line.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// look for vendor at start of line
|
||||
if (line.startswith(vendorStr)) {
|
||||
@@ -63,14 +69,16 @@ static wpi::StringRef GetUsbNameFromFile(int vendor, int product,
|
||||
}
|
||||
}
|
||||
|
||||
return wpi::StringRef{};
|
||||
return {};
|
||||
}
|
||||
|
||||
wpi::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
wpi::SmallVectorImpl<char>& buf) {
|
||||
// try reading usb.ids
|
||||
wpi::StringRef rv = GetUsbNameFromFile(vendor, product, buf);
|
||||
if (!rv.empty()) return rv;
|
||||
if (!rv.empty()) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Fall back to internal database
|
||||
wpi::raw_svector_ostream os{buf};
|
||||
|
||||
Reference in New Issue
Block a user