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

Clean up error_macros.h #33391

Merged
merged 6 commits into from
Feb 5, 2020
Merged

Conversation

madmiraal
Copy link
Contributor

@madmiraal madmiraal commented Nov 6, 2019

This pull request aims to achieve a number of things:

  • Provide a consistent, readable layout to the error_macros.h file.
  • Remove redundant, duplicate macros following Remove implicit dependency on String from error_macros.h. #33382.
  • Add missing 'do' ... 'while(0)' wrappers to macros without them.
  • Remove the trailing semicolons ';' after 'while(0)'
  • Add semicolons to all code segments that were relying on a trailing ';' or '{}' with missing 'do' ... 'while' wrappers.

To make it easier to review and rebase when necessary, the changes are added as separate commits. They can be squashed before merging.

Note: Although the initial commit makes significant changes to error_macros.h, these are limited to code ordering and comments to make it consistent and more readable. It has no impact on any code that uses error_macros.h. This initial commit makes it easier to review the following commits.

@madmiraal
Copy link
Contributor Author

madmiraal commented Nov 7, 2019

Submitted PR #33430 to address the build error raised by the Travis, Linux headless editor build.

@madmiraal madmiraal force-pushed the cleanup-error_macros branch 3 times, most recently from 9908e19 to 9560b56 Compare November 8, 2019 13:09
@madmiraal madmiraal changed the title [WIP] Clean up error_macros.h Clean up error_macros.h Nov 8, 2019
@madmiraal
Copy link
Contributor Author

This PR is now complete and ready for review.

As stated in the initial PR message, The commits can be squashed before merging. They are kept separate to make it easier to review and fix conflicts if a rebase is necessary.

Note: Since it is possible that a PR merged since this was rebased could use one of the removed macros, which would only be picked up by a CI test. It may be wise to rebase onto master again (as part of the final squash) before merging.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #33517.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #33595.

@madmiraal madmiraal force-pushed the cleanup-error_macros branch 2 times, most recently from 4a7fc63 to 3878a3b Compare November 21, 2019 10:00
@madmiraal
Copy link
Contributor Author

Rebased following #33603.

@madmiraal madmiraal force-pushed the cleanup-error_macros branch from 3878a3b to dfc6bbc Compare December 7, 2019 13:35
@madmiraal
Copy link
Contributor Author

Rebased following merge of #33799 and #34079.

@madmiraal madmiraal force-pushed the cleanup-error_macros branch 2 times, most recently from d74f478 to 11286f8 Compare December 22, 2019 11:30
- Add do..while(0) wrapper to ERR_FAIL_NULL macros.
- Add do..while(0) wrapper to ERR_FAIL_COND macros.
- Add do..while(0) wrapper to ERR_CONTINUE macros.
- Add do..while(0) wrapper to ERR_BREAK macros.
- Add do..while(0) wrapper to CRASH_COND macros.
- Add do..while(0) wrapper to ERR_FAIL macros.
- Add do..while(0) wrapper to ERR_PRINT macros.
- Add do..while(0) wrapper to WARN_PRINT macros.
- Add do..while(0) wrapper to WARN_DEPRECATED macros.
- Add do..while(0) wrapper to CRASH_NOW macros.
- Remove trailing semicolons from ERR_FAIL_INDEX macros.
- Remove trailing semicolons from ERR_FAIL_UNSIGNED_INDEX macros.
- Remove trailing semicolons from CRASH_BAD_INDEX macros.
- Remove trailing semicolons from CRASH_BAD_UNSIGNED_INDEX macros.
@madmiraal madmiraal force-pushed the cleanup-error_macros branch from 7bbe6f1 to 6776046 Compare February 5, 2020 13:55
@madmiraal
Copy link
Contributor Author

Rebased following #35359, #35423 and #35521.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look great.

Thanks for going through the tedious work of rebasing it periodically and keep well-scoped commits. Should be good to merge now, I'll just have to handle the build issues due to ERR_PRINTS removal when rebasing vulkan, but that's business as usual :D

@akien-mga akien-mga merged commit 7ada59e into godotengine:master Feb 5, 2020
@akien-mga
Copy link
Member

Thanks!

@madmiraal madmiraal deleted the cleanup-error_macros branch February 5, 2020 14:51
Xrayez added a commit to Xrayez/godot-imagetools that referenced this pull request Feb 5, 2020
Xrayez added a commit to Xrayez/godot-clipper that referenced this pull request Feb 5, 2020
Xrayez added a commit to Xrayez/godot-anl that referenced this pull request Feb 5, 2020
Anutrix added a commit to Anutrix/godot that referenced this pull request Feb 6, 2020
akien-mga added a commit that referenced this pull request Feb 6, 2020
Remove the last ERR_PRINTS that was missed by #33391
@Faless
Copy link
Collaborator

Faless commented Feb 8, 2020

ERR_CONTINUE macro is broken after this.
It cannot be wrapped around do{ } while (0) .

if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing."); \
continue; \
} \
}
} while (0)
Copy link
Collaborator

@Faless Faless Feb 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue will end inner loop, but not the outer one (same below in ERR_CONTINUE_MSG, same in breaks ERR_BREAK and ERR_BREAK_MSG).

Copy link
Contributor Author

@madmiraal madmiraal Feb 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Shall I submit a PR to wrap these in if(1) { } else instead?

EDIT: Actually it's easier to just add a dangling else to the existing if (unlikely(m_cond))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: Actually it's easier to just add a dangling else to the existing if (unlikely(m_cond))

But code such as this would still be valid then?

ERR_CONTINUE(x != 0) // No semicolon
z()

Maybe add a trailing do {} while(0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But code such as this would still be valid then?

Actually the compiler warns about the dangling else; so it probably needs to be if(unlikely(m_cond)) { } else ((void)0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants