-
Notifications
You must be signed in to change notification settings - Fork 101
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
Remove the temporary variable in RCUTILS_LOGGING_AUTOINIT #290
Conversation
3bc0f2b
to
e3cef0c
Compare
include/rcutils/logging.h
Outdated
} \ | ||
} | ||
} while (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.
This looks pretty good to me. One thing that I'd prefer to do here is to remove the semicolon from the end of this line, and make the callers of this macro have the semicolon. That will play more nicely with text editors, and also look more like statements inline.
To do this, we'd have to update all of the callers of RCUTILS_LOGGING_AUTOINIT
to have a semicolon on the end. Most of the callers are in this repository, but there is also a caller in rcl and rclpy. We'd need to have separate PRs for that.
@felixendres Are you willing to make those updates? If so, please go ahead and fix up rcutils as suggested, and open PRs to rcl and rclpy as well. If not, that's OK, but please open an issue so we can do this follow-up in the future.
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 totally agree on @clalancette suggestion, in addition to
- No need to prevent uncrustify from making unnecessary indents.
- It is unlikely that user application calls
RCUTILS_LOGGING_AUTOINIT
directly.
include/rcutils/logging.h
Outdated
} \ | ||
} | ||
} while (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.
I totally agree on @clalancette suggestion, in addition to
- No need to prevent uncrustify from making unnecessary indents.
- It is unlikely that user application calls
RCUTILS_LOGGING_AUTOINIT
directly.
I'd prefer to not make the semicolon changes. This issue is actually an extremely minor issue, so let's not sink too much time into it. Apart from the uncrustify comment (which I don't understand, so you be the judge) the current change improves the status quo. The semicolon issue is the same as before (putting one after the macro is superfluous before and after). So I suggest to merge it as is, unless that uncrustify thing is a problem. |
Fix issue ros2#285: Remove the temporary variable in a macro, because the name of the variable may shadow a variable of the macro user. As suggested by @clalancette, also wrapped it into a do-while wrapping. Signed-off-by: Felix Endres <felix-endres-github@256bit.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
All right. The Windows failures are happening on nightlies as well, so this is ready to go. Since I made changes here, I'm going to wait for another review from @ros2/team . |
@felixendres it would good to update the ticket title to express the content of the patch since it will become the squashed commit message. |
Sorry, for the title-change back and forth. I could swear I still saw the old title "Update logging.h", when I changed it... |
No worries, it was probably just cached in your browser. |
Fix issue #285:
Remove the temporary variable in a macro, because the name of the variable may shadow a variable of the macro user.
As suggested by @clalancette, also wrapped it into a do-while wrapping.
Signed-off-by: Felix Endres