mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-30 02:00:35 +08:00
CI: enable clang-tidy bugprone-assignment-in-if-condition (#26580)
* docs: auto-sync metadata [skip ci] Co-Authored-By: PX4 BuildBot <bot@px4.io> CI: enable clang-tidy bugprone-assignment-in-if-condition Signed-off-by: kuralme <kuralme@protonmail.com> initialize and immediate assignments made one line Signed-off-by: kuralme <kuralme@protonmail.com> * two more initialization fix Signed-off-by: kuralme <kuralme@protonmail.com> --------- Signed-off-by: kuralme <kuralme@protonmail.com> Co-authored-by: PX4BuildBot <bot@px4.io>
This commit is contained in:
@@ -170,7 +170,9 @@ int MspV1::Receive(uint8_t *payload, uint8_t *message_id)
|
||||
}
|
||||
|
||||
while (bytes_available > 4) {
|
||||
if ((ret = read(_fd, header, 1)) != 1) {
|
||||
ret = read(_fd, header, 1);
|
||||
|
||||
if (ret != 1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -186,7 +188,9 @@ int MspV1::Receive(uint8_t *payload, uint8_t *message_id)
|
||||
return -EWOULDBLOCK;
|
||||
}
|
||||
|
||||
if ((ret = read(_fd, &header[1], 4)) != 4) {
|
||||
ret = read(_fd, &header[1], 4);
|
||||
|
||||
if (ret != 4) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -198,7 +202,9 @@ int MspV1::Receive(uint8_t *payload, uint8_t *message_id)
|
||||
payload_size = header[3];
|
||||
*message_id = header[4];
|
||||
|
||||
if ((ret = read(_fd, payload, payload_size + MSP_CRC_SIZE)) != payload_size + MSP_CRC_SIZE) {
|
||||
ret = read(_fd, payload, payload_size + MSP_CRC_SIZE);
|
||||
|
||||
if (ret != payload_size + MSP_CRC_SIZE) {
|
||||
if (ret != -EWOULDBLOCK) {
|
||||
has_header = false;
|
||||
}
|
||||
|
||||
+3
-1
@@ -161,7 +161,9 @@ int LedController::update(LedControlData &control_data)
|
||||
if (current_blink_duration > 0) {
|
||||
++num_blinking_leds;
|
||||
|
||||
if ((_states[i].current_blinking_time += blink_delta_t) > current_blink_duration) {
|
||||
_states[i].current_blinking_time += blink_delta_t;
|
||||
|
||||
if (_states[i].current_blinking_time > current_blink_duration) {
|
||||
_states[i].current_blinking_time -= current_blink_duration;
|
||||
|
||||
if (cur_data.blink_times_left == 246) {
|
||||
|
||||
@@ -182,7 +182,9 @@ InputMavlinkCmdMount::~InputMavlinkCmdMount()
|
||||
|
||||
int InputMavlinkCmdMount::initialize()
|
||||
{
|
||||
if ((_vehicle_command_sub = orb_subscribe(ORB_ID(vehicle_command))) < 0) {
|
||||
_vehicle_command_sub = orb_subscribe(ORB_ID(vehicle_command));
|
||||
|
||||
if (_vehicle_command_sub < 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
@@ -438,11 +440,15 @@ int InputMavlinkGimbalV2::initialize()
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if ((_vehicle_command_sub = orb_subscribe(ORB_ID(vehicle_command))) < 0) {
|
||||
_vehicle_command_sub = orb_subscribe(ORB_ID(vehicle_command));
|
||||
|
||||
if (_vehicle_command_sub < 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if ((_gimbal_manager_set_manual_control_sub = orb_subscribe(ORB_ID(gimbal_manager_set_manual_control))) < 0) {
|
||||
_gimbal_manager_set_manual_control_sub = orb_subscribe(ORB_ID(gimbal_manager_set_manual_control));
|
||||
|
||||
if (_gimbal_manager_set_manual_control_sub < 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
|
||||
@@ -1120,7 +1120,9 @@ void SimulatorMavlink::run()
|
||||
|
||||
if (_ip == InternetProtocol::UDP) {
|
||||
|
||||
if ((_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
_fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
if (_fd < 0) {
|
||||
PX4_ERR("Creating UDP socket failed: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
@@ -1153,7 +1155,9 @@ void SimulatorMavlink::run()
|
||||
PX4_INFO("Waiting for simulator to accept connection on TCP port %u", _port);
|
||||
|
||||
while (true) {
|
||||
if ((_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
if (_fd < 0) {
|
||||
PX4_ERR("Creating TCP socket failed: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -851,17 +851,23 @@ bool UxrceddsClient::setBaudrate(int fd, unsigned baud)
|
||||
}
|
||||
|
||||
/* set baud rate */
|
||||
if ((termios_state = cfsetispeed(&uart_config, speed)) < 0) {
|
||||
termios_state = cfsetispeed(&uart_config, speed);
|
||||
|
||||
if (termios_state < 0) {
|
||||
PX4_ERR("ERR: %d (cfsetispeed)", termios_state);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((termios_state = cfsetospeed(&uart_config, speed)) < 0) {
|
||||
termios_state = cfsetospeed(&uart_config, speed);
|
||||
|
||||
if (termios_state < 0) {
|
||||
PX4_ERR("ERR: %d (cfsetospeed)", termios_state);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((termios_state = tcsetattr(fd, TCSANOW, &uart_config)) < 0) {
|
||||
termios_state = tcsetattr(fd, TCSANOW, &uart_config);
|
||||
|
||||
if (termios_state < 0) {
|
||||
PX4_ERR("ERR: %d (tcsetattr)", termios_state);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user