From 700883ba05724a9dd14fa6d5a2eded658cf0496c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 21 Sep 2016 14:31:35 +0200 Subject: [PATCH] cppcheck & 7.1RC tests --- .travis.yml | 10 ++++++++++ scripts/gen_travis_yml.php | 4 +++- src/php_http_client_curl_user.c | 2 +- src/php_http_info.c | 5 +++-- src/php_http_querystring.c | 21 ++++++++++----------- travis/pecl | 2 +- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78dbc23..d371e67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,23 +10,32 @@ addons: - zlib1g-dev - libidn11-dev - libevent-dev + - cppcheck env: - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes # once with gcov - CFLAGS="-O0 -g --coverage" CXXFLAGS="-O0 -g --coverage" PHP=master enable_json=yes enable_hash=yes enable_iconv=yes @@ -39,6 +48,7 @@ before_script: script: - make -f travis/pecl/Makefile test + - make -f travis/pecl/Makefile cppcheck after_failure: - test -e tests/helper/server.log && cat tests/helper/server.log diff --git a/scripts/gen_travis_yml.php b/scripts/gen_travis_yml.php index 213c5f4..852fce9 100755 --- a/scripts/gen_travis_yml.php +++ b/scripts/gen_travis_yml.php @@ -11,13 +11,14 @@ addons: - zlib1g-dev - libidn11-dev - libevent-dev + - cppcheck env: ["7.0", "master"], + "PHP" => ["7.0", "7.1", "master"], "enable_debug", "enable_maintainer_zts", "enable_json", @@ -40,6 +41,7 @@ before_script: script: - make -f travis/pecl/Makefile test + - make -f travis/pecl/Makefile cppcheck after_failure: - test -e tests/helper/server.log && cat tests/helper/server.log diff --git a/src/php_http_client_curl_user.c b/src/php_http_client_curl_user.c index d345e27..a0449a2 100644 --- a/src/php_http_client_curl_user.c +++ b/src/php_http_client_curl_user.c @@ -59,7 +59,7 @@ static void php_http_client_curl_user_timer(CURLM *multi, long timeout_ms, void if (timeout_ms <= 0) { php_http_client_curl_loop(context->client, CURL_SOCKET_TIMEOUT, 0); - } else if (timeout_ms > 0) { + } else { zval args[1], *ztimeout = &args[0]; ZVAL_LONG(ztimeout, timeout_ms); diff --git a/src/php_http_info.c b/src/php_http_info.c index cbaee88..1470f97 100644 --- a/src/php_http_info.c +++ b/src/php_http_info.c @@ -74,11 +74,12 @@ void php_http_info_to_string(php_http_info_t *info, char **str, size_t *len, con info->http.info.request.method&&!strcasecmp(info->http.info.request.method,"CONNECT")?( info->http.info.request.url?php_http_url_authority_to_string(info->http.info.request.url, &(tmp), NULL):"0"):( info->http.info.request.url?php_http_url_to_string(info->http.info.request.url, &(tmp), NULL, 0):"/"), - info->http.version.major||info->http.version.major?info->http.version.major:1, + info->http.version.major||info->http.version.minor?info->http.version.major:1, info->http.version.major||info->http.version.minor?info->http.version.minor:1, eol); } else if (info->type == PHP_HTTP_RESPONSE){ - *len = spprintf(str, 0, "HTTP/%u.%u %d%s%s%s", info->http.version.major||info->http.version.major?info->http.version.major:1, + *len = spprintf(str, 0, "HTTP/%u.%u %d%s%s%s", + info->http.version.major||info->http.version.minor?info->http.version.major:1, info->http.version.major||info->http.version.minor?info->http.version.minor:1, info->http.info.response.code?info->http.info.response.code:200, info->http.info.response.status&&*info->http.info.response.status ? " ":"", diff --git a/src/php_http_querystring.c b/src/php_http_querystring.c index dfda3d5..01d95f9 100644 --- a/src/php_http_querystring.c +++ b/src/php_http_querystring.c @@ -160,7 +160,7 @@ static int apply_querystring(zval *val) zval *zvalue; if ((zvalue = zend_hash_str_find(Z_ARRVAL_P(val), ZEND_STRL("value")))) { - zval tmp; + zval tmp = {0}; ZVAL_COPY(&tmp, zvalue); zval_dtor(val); @@ -289,25 +289,24 @@ ZEND_RESULT_CODE php_http_querystring_update(zval *qarray, zval *params, zval *o /* * update */ - zval equal, tmp, *entry = &tmp; + zval equal, tmp, *entry = NULL; ZVAL_UNDEF(&tmp); /* recursive */ if (Z_TYPE_P(params_entry) == IS_ARRAY || Z_TYPE_P(params_entry) == IS_OBJECT) { - ZVAL_DUP(entry, qarray_entry); - convert_to_array(entry); - php_http_querystring_update(entry, params_entry, NULL); + ZVAL_DUP(&tmp, qarray_entry); + convert_to_array(&tmp); + php_http_querystring_update(&tmp, params_entry, NULL); + entry = &tmp; } else if ((FAILURE == is_identical_function(&equal, qarray_entry, params_entry)) || Z_TYPE(equal) != IS_TRUE) { Z_TRY_ADDREF_P(params_entry); entry = params_entry; } - if (entry) { - if (key.key) { - zend_hash_update(Z_ARRVAL_P(qarray), key.key, entry); - } else { - zend_hash_index_update(Z_ARRVAL_P(qarray), key.h, entry); - } + if (key.key) { + zend_hash_update(Z_ARRVAL_P(qarray), key.key, entry ? entry : &tmp); + } else { + zend_hash_index_update(Z_ARRVAL_P(qarray), key.h, entry ? entry : &tmp); } } else { zval entry, *entry_ptr = &entry; diff --git a/travis/pecl b/travis/pecl index 2d06b8b..a2206d5 160000 --- a/travis/pecl +++ b/travis/pecl @@ -1 +1 @@ -Subproject commit 2d06b8b6eba14eb26f4e6b5d0eac19569ef1611c +Subproject commit a2206d5f2eaf963d37ff568dd17cd6435f00f809 -- 2.30.2