-
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
Disable uncrustify indentation check for macros that use windows __pragma
#164
Conversation
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
@@ -195,6 +195,7 @@ typedef _Atomic (uintmax_t) atomic_uintmax_t; | |||
/* | |||
* 7.17.7 Operations on atomic types. (pruned modified for Windows' crappy C compiler) | |||
*/ | |||
// *INDENT-OFF* // uncrustify doesn't like the extra indentations in macros |
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.
Can you explain a bit more about what the new uncrustify doesn't like? I'm a bit confused as to why uncrustify doesn't like the below macros, but is happy with https://github.com/ros2/rcl/blob/master/rcl/src/rcl/logging_rosout.c#L45 , for instance.
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'm a bit confused as to why uncrustify doesn't like the below macros, but is happy with https://github.com/ros2/rcl/blob/master/rcl/src/rcl/logging_rosout.c#L45 , for instance.
I'm not yet sure why that file passes the test but this one doesn't. This is from the latest test run that @emersonknapp started without this fix, and it fails like so:
--- include/rcutils/stdatomic_helper/win32/stdatomic.h
35: +++ include/rcutils/stdatomic_helper/win32/stdatomic.h.uncrustify
35: @@ -205,19 +205,19 @@
35: - switch (sizeof(out)) { \
35: - case sizeof(uint64_t): \
35: - out = _InterlockedCompareExchange64((LONGLONG *) object, desired, *expected); \
35: - break; \
35: - case sizeof(uint32_t): \
35: - out = _InterlockedCompareExchange((LONG *) object, desired, *expected); \
35: - break; \
35: - case sizeof(uint16_t): \
35: - out = _InterlockedCompareExchange16((SHORT *) object, desired, *expected); \
35: - break; \
35: - case sizeof(uint8_t): \
35: - out = _InterlockedCompareExchange8((char *) object, desired, *expected); \
35: - break; \
35: - default: \
35: - RCUTILS_LOG_ERROR_NAMED( \
35: - _RCUTILS_PACKAGE_NAME, "Unsupported integer type in atomic_compare_exchange_strong"); \
35: - exit(-1); \
35: - break; \
35: - } \
35: + switch (sizeof(out)) { \
35: + case sizeof(uint64_t): \
35: + out = _InterlockedCompareExchange64((LONGLONG *) object, desired, *expected); \
35: + break; \
35: + case sizeof(uint32_t): \
35: + out = _InterlockedCompareExchange((LONG *) object, desired, *expected); \
35: + break; \
35: + case sizeof(uint16_t): \
35: + out = _InterlockedCompareExchange16((SHORT *) object, desired, *expected); \
35: + break; \
35: + case sizeof(uint8_t): \
35: + out = _InterlockedCompareExchange8((char *) object, desired, *expected); \
35: + break; \
35: + default: \
35: + RCUTILS_LOG_ERROR_NAMED( \
35: + _RCUTILS_PACKAGE_NAME, "Unsupported integer type in atomic_compare_exchange_strong"); \
35: + exit(-1); \
35: + break; \
35: + } \
...
1 files with code style divergence
...
10/11 Test #35: uncrustify .......................***Failed 1.55 sec
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.
@clalancette it seems to be the Windows __pragma
operator that is throwing uncrustify off. When I remove them or replace with regular function calls, uncrustify does not fail.
This seems as if it's a regression from the older version, probably related to the addition of some explicit __pragma
support a few months ago - uncrustify/uncrustify#2136 - see the final comment
I'm not entirely confident (but possibly just because I'm not familiar with this corner of the code) that this won't introduce corner cases
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've opened this issue uncrustify/uncrustify#2314
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.
@clalancette do you have thoughts on what our next steps are for this? I perceive the following options
- Leave
INDENT-OFF
in this file, leaving a note that it's a known uncrustify issue for Windows macros - Revert
uncrustify_vendor
to version it was before and cherry-pick the needed fix as a patch from Fix cast-align warnings in md5.cpp on armhf uncrustify/uncrustify#2308
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.
@jacobperron do you know who could make a call on this? this is a prereq for the green armhf build
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.
Possible third option: What if we try wrapping the definition of the macro in braces? Maybe it will satisfy uncrustify in the meantime? E.g.
{ \
__pragma(warning(push)) \
__pragma(warning(disable: 4244)) \
__pragma(warning(disable: 4047)) \
__pragma(warning(disable: 4024)) \
do { \
switch (sizeof(out)) { \
case sizeof(uint64_t): \
out = _InterlockedCompareExchange64((LONGLONG *) object, desired, *expected); \
break; \
case sizeof(uint32_t): \
out = _InterlockedCompareExchange((LONG *) object, desired, *expected); \
break; \
case sizeof(uint16_t): \
out = _InterlockedCompareExchange16((SHORT *) object, desired, *expected); \
break; \
case sizeof(uint8_t): \
out = _InterlockedCompareExchange8((char *) object, desired, *expected); \
break; \
default: \
RCUTILS_LOG_ERROR_NAMED( \
_RCUTILS_PACKAGE_NAME, "Unsupported integer type in atomic_compare_exchange_strong"); \
exit(-1); \
break; \
} \
} while (0); \
__pragma(warning(pop)) \
}
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.
Otherwise, I'd also vote for option 1: leaving INDENT-OFF
with a TODO to remove it once we switch to a version containing the patch.
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.
Unfortunately no dice with brace wrapping, everything after the __pragma still gets flattened.
That being the situation, I think we're left with the TODO note - I've updated it to reflect this.
__pragma
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
7cc1cf3
to
4f89291
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.
Okay with me. I'd like a second opinion though. @clalancette, thoughts?
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.
Sorry for being quiet here. I'm fine with disabling uncrustify here for now, until the upstream bug is fixed.
Connects to ament/uncrustify_vendor#5