-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Two enum
s instead of preprocessor macros
#10617
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
@@ -28,6 +28,11 @@ typedef struct _zend_stack { | |||
|
|||
#define STACK_BLOCK_SIZE 16 | |||
|
|||
typedef enum { | |||
ZEND_STACK_APPLY_TOPDOWN, |
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.
Looks correct in general, just curiosity question : what led you to change the original values ?
It seems safe enough doing so, I do not think it will bite later on just curious..
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 reviewed all code locations where they are used, also checked the commit which added them (9c754da), and figured these were arbitrary values with no meaning. I also figured that zero (for which there is no macro) isn't a special case, for example by casting to bool
somewhere or relying on zero-initialization (via memset()
or bss
).
Then I decided to not specifiy any explicit values at all, because that would indicate to the next guy that the values are important, when they really aren't. I decided for simplicity.
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.
sounds fair.
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 reviewed all code locations where they are used, also checked the commit which added them (9c754da), and figured these were arbitrary values with no meaning. I also figured that zero (for which there is no macro) isn't a special case, for example by casting to
bool
somewhere or relying on zero-initialization (viamemset()
orbss
). Then I decided to not specifiy any explicit values at all, because that would indicate to the next guy that the values are important, when they really aren't. I decided for simplicity.
please - add this to commit message. and pretty please, with sugar on top - write BIG commit messages to explain next guy WHY this is done. You do a lot of good work, but not explain what and why was done.
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.
Looks good to me, thank you! Can we enable -Wassign-enum
on Clang (ASAN build on Cirrus)? This would provide a tangible benefit when converting to enums. Maybe there are other useful enum flags, there's a bunch of them for Clang.
To find mistakes with enums. See php#10617 (review)
Though lots of code fails with this warning - and indeed, enums are (ab)used by the JIT and others as bit fields, which is not correct. |
To find mistakes with enums. See php#10617 (review)
To find mistakes with enums. See php#10617 (review)
To find mistakes with enums. See php#10617 (review)
To find mistakes with enums. See php#10617 (review)
To find mistakes with enums. See php#10617 (review)
To find mistakes with enums. See php#10617 (review)
This reverts commit bb07e20.
No description provided.