-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Promote warnings to Errors in sockets's extension. #5075
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
82e81d3
to
c3c5bf0
Compare
f88a4f8
to
650aa93
Compare
ext/sockets/conversions.c
Outdated
@@ -241,26 +241,26 @@ static void from_zval_write_aggregation(const zval *container, | |||
zval *elem; | |||
|
|||
if (Z_TYPE_P(container) != IS_ARRAY) { | |||
do_from_zval_err(ctx, "%s", "expected an array here"); | |||
zend_type_error("Expected array"); | |||
return; | |||
} | |||
|
|||
for (descr = descriptors; descr->name != NULL && !ctx->err.has_error; descr++) { | |||
if ((elem = zend_hash_str_find(Z_ARRVAL_P(container), | |||
descr->name, descr->name_size - 1)) != NULL) { | |||
|
|||
if (descr->from_zval == 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.
Convert this to ZEND_ASSERT(descr->from_zval)
, doesn't seem like it can be hit.
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.
It looks like you converted the wrong condition to an assert here...
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.
Uhhhh, what was I thinking >_>
ext/sockets/conversions.c
Outdated
@@ -365,8 +363,7 @@ void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx) | |||
} |
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.
These has_error
checks are no longer going to work after some of your changes.
650aa93
to
9d7c7f4
Compare
9d7c7f4
to
a336c3c
Compare
a336c3c
to
33dbfa2
Compare
Test failures are FPM related ... |
3bffe06
to
5e745c7
Compare
5e745c7
to
99045d8
Compare
9eb8684
to
8a1a9ea
Compare
I ignored a large part of warnings in multicast.c currently. Will maybe tackle them later or in a separate PR. |
@kocsismate I've updated most of the errors to use the new API, mind checking that I'm using the "standard" error format everywhere? |
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 had a first look :) If you address the comments, please check for duplicates, because I saw that most of the messages are repeated (and I didn't comment everywhere).
ext/sockets/sockets.c
Outdated
php_error_docref(NULL, E_WARNING, "Socket of type AF_INET6 requires 3 arguments"); | ||
RETURN_FALSE; | ||
if (ZEND_NUM_ARGS() != 3) { | ||
zend_argument_count_error("Socket of type AF_INET6 requires port to be specified"); |
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 used an argument_value_error
with a message similar to must be specified for the AF_INET6 socket type
in a similar situation
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.
Hum, maybe? It feels like a count error is more appropriate as there is a missing argument, but could change it to a ValueError.
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.
My reasoning is that because this parameter is optional, and since it should be nullable in reality (and it will be when I start fixing optional params with UNKNOWN default values in stubs), we should think about this error that the default value is not appropriate in case of the aforementioned socket type. At least this is what I think 😊
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.
Agree with @kocsismate.
8a1a9ea
to
421fb30
Compare
ext/sockets/sockets.c
Outdated
close(php_sock->bsd_socket); | ||
efree(php_sock); | ||
RETURN_FALSE; | ||
efree(php_sock); |
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.
Indentation
var_dump(socket_set_option($s, IPPROTO_IPV6, IPV6_PKTINFO, [])); | ||
} catch (\ValueError $e) { | ||
echo $e->getMessage() . \PHP_EOL; | ||
} |
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.
Added try but no change in output?
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'll drop it, as I'm using WSL, I get test failures due to the protocols not being available so I've added it to catch the failure on CI, but seems like there is none.
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.
Ah no I remember why, this was when I still had the changes in conversion.c which I decided to drop
Looks fine to me apart from some nits. |
1b6af4a
to
2869ccb
Compare
2869ccb
to
7ff8eaa
Compare
There are a bunch of expected array warnings, a better way is too probably ask for a HashTable param instead of a zval.