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

Remove do{ } while(0) wrapper around error macros. #36011

Merged
merged 1 commit into from
Feb 8, 2020

Conversation

madmiraal
Copy link
Contributor

@madmiraal madmiraal commented Feb 8, 2020

As pointed out by @Faless, a do{ } while(0) wrapper around a continue or break just ends the do{ } while(0) loop. The do{ } while(0) loop exists to enable the macro to be used as a function which requires a semicolon.

The alternative approach is to use an if(1) { } else ((void)0) wrapper. Since the macro already has an if(unlikely(m_cond)) { } this patch simply adds the else ((void)0) to this if statement instead.

For consistency all the macros have been updated in the same way, and trailing else warnings corrected. However, the wrappers around ERR_PRINT and WARN_PRINT were removed, because they generated too many ambiguous trailing else warnings. They are also single line macros so a wrapper is not needed.

Fixes #33391 comment.

Bugsquad edit: Fixes #36028.

@madmiraal madmiraal requested a review from neikeq as a code owner February 8, 2020 10:10
@Faless
Copy link
Collaborator

Faless commented Feb 8, 2020

Could you please remove the @mention in the commit message? Otherwise github won't stop bothering me when other people do merges of this in their repositories. 🙄

As pointed out by Faless, a do{ } while(0) wrapper around a continue or
break just ends the do{ } while(0) loop. The do{ } while(0) loop exists
to enable the macro to be used as a function which requires a semicolon.

The alternative approach is to use an if(1) { } else ((void)0) wrapper.
Since the macro already has an if(unlikely(m_cond)) { } this patch simply
adds the else ((void)0) to this if statement instead.

For consistency all the macros have been updated in the same way, and
trailing else warnings corrected. However, the wrappers around ERR_PRINT
and WARN_PRINT were removed, because they generated too many ambiguous
trailing else warnings. They are also single line macros so a wrapper is
not needed.
@madmiraal
Copy link
Contributor Author

@Faless I've dropped the @ in the commit message.

@akien-mga
Copy link
Member

Tested locally and it fixes a crash: #36028.

@akien-mga akien-mga merged commit b2a7c08 into godotengine:master Feb 8, 2020
@akien-mga
Copy link
Member

Thanks!

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.

Project crash almost immediately after running
4 participants