-
Notifications
You must be signed in to change notification settings - Fork 525
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
Fixes for new warnings/behaviours in GCC7+/cppcheck. #480
Conversation
About improving code quality, it would be nice to make the time related functions Also, we could align the current Regarding time functions, maybe we could try to use 64 bit variables even if I know that the major use case is on small microcontrollers so the time is not always an epoch time. |
PR is up for noetic-devel branch PR testing here: ros/rosdistro#24473 The tests will continue to fail until the Python 3 situation in Note also that the travis build will also have to be updated; there's no base VM for focal, so it should probably be switched to use the docker service, see: https://docs.travis-ci.com/user/docker/ (though that would be blocked on having the official ROS Noetic docker image— osrf/docker_images#395) |
a4a935b
to
d068dff
Compare
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.
Although I approve Python 3 support in general; I wonder why is it included in this PR (targeting C++warnings).
@@ -545,7 +538,7 @@ def run(self): | |||
else: | |||
rospy.loginfo("wrong checksum for topic id and msg") | |||
|
|||
except IOError as exc: | |||
except ImportError as exc: |
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.
What could possibly raise an ImportError
that is caught here?
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 agree, this makes no sense. Reverting.
uint8_t message_in[INPUT_SIZE]; | ||
uint8_t message_out[OUTPUT_SIZE]; | ||
uint8_t message_in[INPUT_SIZE] = {0}; | ||
uint8_t message_out[OUTPUT_SIZE] = {0}; | ||
|
||
Publisher * publishers[MAX_PUBLISHERS]; | ||
Subscriber_ * subscribers[MAX_SUBSCRIBERS]; |
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.
For the sake of consistency, publishers
and subscribers
should be initialized with = {nullptr}
.
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.
Done.
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.
Fixed. I wonder why cppcheck complained about all the other ones and not these.
try: | ||
sent = self.socket.send(data[totalsent:]) | ||
except BrokenPipeError: | ||
sent = 0 |
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.
Why not raise RuntimeError(...)
here?
The message "RosSerialServer.write() socket connection broken" below seems inappopriate for the case in which a BrokenPipeError
was not caught, but zero bytes were sent anyway.
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.
Hmm, yeah I wasn't sure what to do here. From https://stackoverflow.com/a/34920917/109517, it seems like socket.send
can legitimately return zero in at least some non-error scenarios. I suppose the risk is that it would hard loop on this, especially if you had a non-blocking socket, but that's not the case here with a dedicated writer thread. Have updated it to ignore the 0 scenario and instead throw from inside the except
.
@stertingen Without proper Python 3 support landing for Noetic, the tests using |
Notably: - Add missing member initializations. - Add missing override specifiers. - Hacky cast for the 16 bit AVR float logic.
Publisher * publishers[MAX_PUBLISHERS]; | ||
Subscriber_ * subscribers[MAX_SUBSCRIBERS]; | ||
Publisher * publishers[MAX_PUBLISHERS] = {nullptr}; | ||
Subscriber_ * subscribers[MAX_SUBSCRIBERS] {nullptr}; |
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.
Subscriber_ * subscribers[MAX_SUBSCRIBERS] {nullptr}; | |
Subscriber_ * subscribers[MAX_SUBSCRIBERS] = {nullptr}; |
Closed in favour of #508. |
A bunch of stuff that came up when testing with the GCC9-based toolchain that will ship in Ubuntu Focal:
There are a few more member initializations to add in NodeHandle. Will get to those before merging.
Also, I believe this will break Bionic, and it's a pretty breaking change regardless, so this probably merits cutting a
noetic-devel
branch for it.