From: Gustavo André dos Santos Lopes Date: Fri, 18 Feb 2011 17:53:26 +0000 (+0000) Subject: - Changed return value in userspace stream set_option to "not implemented", X-Git-Tag: php-5.4.0alpha1~191^2~223 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37593312764da0bc0b6cdcc3b6c3c3fb698b204e;p=php - Changed return value in userspace stream set_option to "not implemented", instead of failure. #Currently, there's no way to test this, because the only operations that have #a default implementation, set_chunk_size and set_read_buffer are either not #exposed or, in the 2nd case, completely delegated to the user implementation, #which can only return true/false, not "not implemented" (and not implementing #the set_option method in the userspace stream results in error). --- diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 7380c535e1..44ee715264 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -938,7 +938,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value zval *retval = NULL; int call_result; php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract; - int ret = -1; + int ret = PHP_STREAM_OPTION_RETURN_NOTIMPL; zval *zvalue = NULL; zval **args[3]; @@ -991,10 +991,11 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value } else if (call_result == FAILURE) { if (value == 0) { /* lock support test (TODO: more check) */ - ret = 0; + ret = PHP_STREAM_OPTION_RETURN_OK; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_LOCK " is not implemented!", us->wrapper->classname); + ret = PHP_STREAM_OPTION_RETURN_ERR; } } @@ -1093,16 +1094,15 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value &retval, 3, args, 0, NULL TSRMLS_CC); - do { - if (call_result == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_SET_OPTION " is not implemented!", - us->wrapper->classname); - break; - } - if (retval && zend_is_true(retval)) { - ret = PHP_STREAM_OPTION_RETURN_OK; - } - } while (0); + if (call_result == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_SET_OPTION " is not implemented!", + us->wrapper->classname); + ret = PHP_STREAM_OPTION_RETURN_ERR; + } else if (retval && zend_is_true(retval)) { + ret = PHP_STREAM_OPTION_RETURN_OK; + } else { + ret = PHP_STREAM_OPTION_RETURN_ERR; + } if (zoption) { zval_ptr_dtor(&zoption);