cpplint: add filter whitespace/parens (#29565)

This commit is contained in:
Dean Lee
2023-08-24 05:25:05 +08:00
committed by GitHub
parent 239d6a24be
commit 5480d32bb5
23 changed files with 56 additions and 58 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ int gpio_init(int pin_nr, bool output) {
char pin_dir_path[50];
int pin_dir_path_len = snprintf(pin_dir_path, sizeof(pin_dir_path),
"/sys/class/gpio/gpio%d/direction", pin_nr);
if(pin_dir_path_len <= 0) {
if (pin_dir_path_len <= 0) {
return -1;
}
const char *value = output ? "out" : "in";
@@ -42,7 +42,7 @@ int gpio_set(int pin_nr, bool high) {
char pin_val_path[50];
int pin_val_path_len = snprintf(pin_val_path, sizeof(pin_val_path),
"/sys/class/gpio/gpio%d/value", pin_nr);
if(pin_val_path_len <= 0) {
if (pin_val_path_len <= 0) {
return -1;
}
return util::write_file(pin_val_path, (void*)(high ? "1" : "0"), 1);
+6 -6
View File
@@ -26,23 +26,23 @@ I2CBus::I2CBus(uint8_t bus_id) {
snprintf(bus_name, 20, "/dev/i2c-%d", bus_id);
i2c_fd = HANDLE_EINTR(open(bus_name, O_RDWR));
if(i2c_fd < 0) {
if (i2c_fd < 0) {
throw std::runtime_error("Failed to open I2C bus");
}
}
I2CBus::~I2CBus() {
if(i2c_fd >= 0) { close(i2c_fd); }
if (i2c_fd >= 0) { close(i2c_fd); }
}
int I2CBus::read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len) {
int ret = 0;
ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address));
if(ret < 0) { goto fail; }
if (ret < 0) { goto fail; }
ret = i2c_smbus_read_i2c_block_data(i2c_fd, register_address, len, buffer);
if((ret < 0) || (ret != len)) { goto fail; }
if ((ret < 0) || (ret != len)) { goto fail; }
fail:
return ret;
@@ -52,10 +52,10 @@ int I2CBus::set_register(uint8_t device_address, uint register_address, uint8_t
int ret = 0;
ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address));
if(ret < 0) { goto fail; }
if (ret < 0) { goto fail; }
ret = i2c_smbus_write_byte_data(i2c_fd, register_address, data);
if(ret < 0) { goto fail; }
if (ret < 0) { goto fail; }
fail:
return ret;
+1 -1
View File
@@ -171,7 +171,7 @@ private:
template<typename T>
void update_max_atomic(std::atomic<T>& max, T const& value) {
T prev = max;
while(prev < value && !max.compare_exchange_weak(prev, value)) {}
while (prev < value && !max.compare_exchange_weak(prev, value)) {}
}
class LogState {