-
-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to clang-format #410
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for me as soon as the tests pass!
1a3b383
to
bba0984
Compare
@julianoes We mention astyle here: https://docs.dronecore.io/en/contributing/code_style.html Obviously we're now using clang.
I will have to remove astyle from the dependencies - e.g. : https://docs.dronecore.io/en/contributing/build.html#linux |
core/mavlink_parameters.cpp
Outdated
@@ -111,7 +111,7 @@ MAVLinkParameters::do_work() | |||
_state = State::SET_PARAM_BUSY; | |||
|
|||
char param_id[PARAM_ID_LEN] = {}; | |||
STRNCPY(param_id, set_param_work->param_name.c_str(), sizeof(param_id)); | |||
STRNCPY(param_id, set_param_work->param_name.c_str(), sizeof(param_id)-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get that :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, forget it, that's in the commit description 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GCC 8 doesn't like the fact that we could potentially copy 17 chars without null termination into param_id
. At that point param_id
would not be null terminated. That's how I understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just thinking, why don't we a hire a local std::string
for doing this. Applicable elsewhere in such scenarios as well. Makes sense ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shakthi-prashanth-m I don't think I understand what you mean.
Yes, we are switching.
The settings are defined in .clang-format (added in 7269ce5)
Yes, the usage is the same.
Yes, that's still the same.
Correct. Developers need to have For Ubuntu 16.04: (https://github.com/dronecore/DroneCore/blob/switch-to-clang-format/docker/Dockerfile-Ubuntu-16.04#L37-L42)
Ubuntu 18.04: (https://github.com/dronecore/DroneCore/blob/switch-to-clang-format/docker/Dockerfile-Ubuntu-18.04#L21)
Fedora 28: (https://github.com/dronecore/DroneCore/blob/switch-to-clang-format/docker/Dockerfile-Fedora-28#L14)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many new changes 👍 Code looks clean now :-)
plugins/telemetry/telemetry_impl.cpp
Outdated
_ground_speed_ned_rate_hz(0.0), | ||
_position_rate_hz(-1.0) | ||
TelemetryImpl::TelemetryImpl(System &system) | ||
: PluginImplBase(system), _position_mutex(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some places like these (constructor member initialization), I feel old style is better readable. But, thats unavoidable I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I was going to look at the changes and figure out how to prevent some of them.
0282e81
to
a8013ca
Compare
This is an attempt to come up with the config for clang-format 6 which matches our current format as close as possible. Some options for clang-format 7 are currently commented out.
The destination needs to be 1 char longer than the num of chars that are copied in order to make sure the resulting string at the destination is null-terminated.
This means that we can generate the binaries for multiple distro versions.
We switched from astyle to clang-format. Even though we tried to match the previous style as much as possible, there are still a few changes needed.
a8013ca
to
6db58c5
Compare
@shakthi-prashanth-m @JonasVautherin I changed some of the clang-format options to match the previous style closer. Have another look please if you see anything too ugly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Switch to clang-format
While the clang-format style tries to reflect the previous astyle style
as close as possible, there is, unfortuntately, still a considerable diff.
Fixes #358.