Warning in DynamixelSDK: Suggest Parentheses Around Assignment

Hi everyone,

I’m working with the DynamixelSDK for turtlebot3 simulation on ROS2 Humble, and I encountered the following warning when compiling:

From what I understand, this warning occurs because an assignment (=) is being used in a return statement without parentheses, which might be misinterpreted as a condition.

Would wrapping the assignment in parentheses like this be the correct fix?

return (error[0] = error_list_[id][0]);

Or is there a better way to handle this to avoid any unintended behavior?

Hello, Johanes_PS

Thank you for bringing this up!

We’ve confirmed the issue and updated the source code in the DYNAMIXEL SDK repository.
The function was revised as follows:

bool GroupSyncRead::getError(uint8_t id, uint8_t* error)
{
  if (ph_->getProtocolVersion() == 1.0 || !last_result_ || error_list_.find(id) == error_list_.end())
    return false;

  error[0] = error_list_[id][0];
  return true;
}

This update is now reflected in the latest humble and main branches.
If you pull the latest version, the fix will be applied.

Thanks again for your report!
If you have any further questions or issues, feel free to reach out.

1 Like