Skip to content
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

Merged
merged 2 commits into from
Jun 19, 2019

Conversation

emersonknapp
Copy link
Contributor

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
Copy link
Contributor

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.

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Member

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)) \
}

Copy link
Member

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.

Copy link
Contributor Author

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.

@emersonknapp
Copy link
Contributor Author

emersonknapp commented Jun 12, 2019

Running just a linux build with the updated uncrusify, without this change, as a sanity check to see what the complaint is, and that it's not just my dev environment.

Build Status

@emersonknapp emersonknapp changed the title Disable uncrustify indentation check for deeply indented macros Disable uncrustify indentation check for macros that use windows __pragma Jun 13, 2019
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
@emersonknapp
Copy link
Contributor Author

emersonknapp commented Jun 19, 2019

Running CI for just this change, since it should work fine with either uncrustify version and therefore could land first

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Member

@jacobperron jacobperron left a 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?

Copy link
Contributor

@clalancette clalancette left a 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.

@jacobperron jacobperron merged commit 7350a3b into ros2:master Jun 19, 2019
@emersonknapp emersonknapp deleted the latest-uncrustify branch June 19, 2019 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants