-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix UNEXPECTED() paren mistakes. #10364
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
Conversation
This corrects the paren placement to the intended one. As these functions use zend_result, the success value is zero. Therefore this has no functional change. The only difference is that this now hints the compiler optimizer correctly.
Want to use the opportunity to share Coccinelle to PHP once more 😄 The following simple Coccinelle patch should detect misuses of these macros:
I've ran the patch on
Usage: |
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 would not mind much if it was backported like your previous similar, fix even tough indeed the effect is not really the same. Let's see what other think and once you address the comment.
I don't really see a harm in backporting this either. |
Just my opinion, I don't really mind either way. Generally I prefer not backporting things that don't solve observable issues. For older branches this might trigger a release when there doesn't have to be one. It also increases the diff when looking for potential changes. Either is fine for me for this case. |
👍 for integrating Coccinelle, it should also detect issues like #10332 |
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.
As this does not fix a bug (can only improve performance), I targeted master.
And that is appropriate, in my opinion. #10332 fixed an actual bug, though, due to the way we define UNEXPECTED
(double negation of the expression).
Thank you all for the reviews. @TimWolla Oh yeah Coccinelle! I really should learn smpl someday :). I ran your cocci file until it finished and it didn't find any additional cases (well except for the one you already posted). I guess this PR was closed a bit early since I hadn't had the chance to add the zend_gc.c case, so I'll create a PR for that one shortly :) |
This corrects the paren placement to the intended one. As these functions use zend_result, the success value is zero. Therefore this has no functional change. The only difference is that this now hints the compiler optimizer correctly.
As this does not fix a bug (can only improve performance), I targeted master.
I found these by grepping for more of cases like #10332.