-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-2111: Replace zend_parse_parameters calls with macros #1338
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
Z_PARAM_OPTIONAL | ||
Z_PARAM_STRING_OR_NULL(uri_string, uri_string_len) | ||
Z_PARAM_ARRAY_EX(options, 1, 1) | ||
Z_PARAM_ARRAY_EX(driverOptions, 1, 1) |
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.
Noted that Z_PARAM_ARRAY_EX
's second and third arguments correspond to check_null
and separate
, respectively (see: lxr).
PHONGO_PARSE_PARAMETERS_START(1, 3) | ||
Z_PARAM_ZVAL(mode) | ||
Z_PARAM_OPTIONAL | ||
Z_PARAM_ARRAY_EX(tagSets, 1, 1) |
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.
Noted this applies separate
for the parsed zval. I believe the Manager and ReadPreference constructors were the only place where this was necessary.
@@ -145,7 +144,7 @@ static PHP_METHOD(WriteConcern, __construct) | |||
|
|||
switch (ZEND_NUM_ARGS()) { | |||
case 3: | |||
if (Z_TYPE_P(journal) != IS_NULL) { | |||
if (journal && Z_TYPE_P(journal) != IS_NULL) { |
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.
Why was this change necessary? Did zend_parse_parameters
previously always initialize zval *journal
or what this a long-standing bug?
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.
Without the additional check I was presented with a compiler warning about journal
potentially being uninitialised. Looking through the sources, we can see that zend_parse_arg_zval_deref
will always assign the arg
pointer to *dest
if check_null
is false (as is the case for journal
). I'm not entirely sure what arg
would be for optional arguments that weren't provided, or why this wasn't an issue before, especially considering that the call stack always ends up in the above zend_parse_arg_zval_deref
function. I lack the internals knowledge to figure that one out, hence the simple NULL
check.
fd7a261
to
4958e36
Compare
PHPC-2111