diff --git a/ext/standard/array.c b/ext/standard/array.c index 213402c7819a..6219c8f9eb4d 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -557,7 +557,7 @@ static bucket_compare_func_t php_get_data_compare_func_unstable(zend_long sort_t PHPAPI zend_long php_count_recursive(HashTable *ht) /* {{{ */ { - zend_long cnt = 0; + zend_long cnt; zval *element; #ifdef ZEND_CHECK_STACK_LIMIT diff --git a/ext/standard/dns.c b/ext/standard/dns.c index b3fcc1d236af..8aad30e468f6 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -822,7 +822,7 @@ PHP_FUNCTION(dns_get_record) HEADER *hp; querybuf answer = {0}; uint8_t *cp = NULL, *end = NULL; - int n, qd, an, ns = 0, ar = 0; + int n, qd, an, ns, ar; int type, first_query = 1, store_results = 1; bool raw = 0; diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 5c9e5c6076a8..bc0cc1cb8a05 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -112,7 +112,7 @@ PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value) FILE *fp; char *buf; int pclose_return; - char *b, *d=NULL; + char *b; php_stream *stream; size_t buflen, bufl = 0; #if PHP_SIGCHILD @@ -184,9 +184,6 @@ PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value) signal(SIGCHLD, sig_handler); } #endif - if (d) { - efree(d); - } return pclose_return; err: pclose_return = -1; diff --git a/ext/standard/file.c b/ext/standard/file.c index b52e5ba9525f..0f799759451b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -479,7 +479,6 @@ PHP_FUNCTION(file_put_contents) } mode[0] = 'c'; } - mode[2] = '\0'; stream = php_stream_open_wrapper_ex(filename, mode, ((flags & PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); if (stream == NULL) { diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 13478b6f5c31..66ceacc601ec 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -536,7 +536,6 @@ PHP_FUNCTION(chown) #ifdef HAVE_LCHOWN PHP_FUNCTION(lchown) { - RETVAL_TRUE; php_do_chown(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } #endif diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index cf529e40085b..17521d4c9fa5 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -545,7 +545,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa /* Append */ memcpy(tmp_line, "APPE", sizeof("APPE")); } - php_stream_printf(stream, "%s %s\r\n", tmp_line, (resource->path != NULL ? ZSTR_VAL(resource->path) : "/")); + php_stream_printf(stream, "%s %s\r\n", tmp_line, ZSTR_VAL(resource->path)); /* open the data channel */ if (hoststart == NULL) { @@ -734,7 +734,7 @@ static php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const ch goto opendir_errexit; } - php_stream_printf(stream, "NLST %s\r\n", (resource->path != NULL ? ZSTR_VAL(resource->path) : "/")); + php_stream_printf(stream, "NLST %s\r\n", ZSTR_VAL(resource->path)); result = GET_FTP_RESULT(stream); if (result != 150 && result != 125) { @@ -800,7 +800,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, const char *url, } ssb->sb.st_mode = 0644; /* FTP won't give us a valid mode, so approximate one based on being readable */ - php_stream_printf(stream, "CWD %s\r\n", (resource->path != NULL ? ZSTR_VAL(resource->path) : "/")); /* If we can CWD to it, it's a directory (maybe a link, but we can't tell) */ + php_stream_printf(stream, "CWD %s\r\n", ZSTR_VAL(resource->path)); /* If we can CWD to it, it's a directory (maybe a link, but we can't tell) */ result = GET_FTP_RESULT(stream); if (result < 200 || result > 299) { ssb->sb.st_mode |= S_IFREG; @@ -816,7 +816,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, const char *url, goto stat_errexit; } - php_stream_printf(stream, "SIZE %s\r\n", (resource->path != NULL ? ZSTR_VAL(resource->path) : "/")); + php_stream_printf(stream, "SIZE %s\r\n", ZSTR_VAL(resource->path)); result = GET_FTP_RESULT(stream); if (result < 200 || result > 299) { /* Failure either means it doesn't exist @@ -831,7 +831,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, const char *url, ssb->sb.st_size = atoi(tmp_line + 4); } - php_stream_printf(stream, "MDTM %s\r\n", (resource->path != NULL ? ZSTR_VAL(resource->path) : "/")); + php_stream_printf(stream, "MDTM %s\r\n", ZSTR_VAL(resource->path)); result = GET_FTP_RESULT(stream); if (result == 213) { char *p = tmp_line + 4; @@ -920,12 +920,6 @@ static int php_stream_ftp_unlink(php_stream_wrapper *wrapper, const char *url, i goto unlink_errexit; } - if (resource->path == NULL) { - php_stream_wrapper_warn(wrapper, context, options, InvalidPath, - "Invalid path provided in %s", url); - goto unlink_errexit; - } - /* Attempt to delete the file */ php_stream_printf(stream, "DELE %s\r\n", ZSTR_VAL(resource->path)); @@ -1051,12 +1045,6 @@ static int php_stream_ftp_mkdir(php_stream_wrapper *wrapper, const char *url, in goto mkdir_errexit; } - if (resource->path == NULL) { - php_stream_wrapper_warn(wrapper, context, options, InvalidPath, - "Invalid path provided in %s", url); - goto mkdir_errexit; - } - if (!recursive) { php_stream_printf(stream, "MKD %s\r\n", ZSTR_VAL(resource->path)); result = GET_FTP_RESULT(stream); @@ -1140,12 +1128,6 @@ static int php_stream_ftp_rmdir(php_stream_wrapper *wrapper, const char *url, in goto rmdir_errexit; } - if (resource->path == NULL) { - php_stream_wrapper_warn(wrapper, context, options, InvalidPath, - "Invalid path provided in %s", url); - goto rmdir_errexit; - } - php_stream_printf(stream, "RMD %s\r\n", ZSTR_VAL(resource->path)); result = GET_FTP_RESULT(stream); diff --git a/ext/standard/http.c b/ext/standard/http.c index eee1018672bd..57942bb312d6 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -145,9 +145,6 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, if (ZSTR_VAL(key)[0] == '\0' && type != NULL) { const char *tmp; zend_unmangle_property_name_ex(key, &tmp, &prop_name, &prop_len); - } else { - prop_name = ZSTR_VAL(key); - prop_len = ZSTR_LEN(key); } } else { prop_name = NULL; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 4a0f95062bcd..a699c1ea99ea 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -157,7 +157,7 @@ static bool php_stream_http_response_header_trim(char *http_header_line, size_t *http_header_line_length) { char *http_header_line_end = http_header_line + *http_header_line_length - 1; - while (http_header_line_end >= http_header_line && + while (http_header_line_end >= http_header_line && (*http_header_line_end == '\n' || *http_header_line_end == '\r')) { http_header_line_end--; } @@ -985,7 +985,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, } else { last_line = false; } - + if (last_header_line_str != NULL) { /* Parse last header line. */ last_header_line_str = php_stream_http_response_headers_parse(wrapper, stream, @@ -1072,8 +1072,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, } } s[1] = '\0'; - if (resource->path && - ZSTR_VAL(resource->path)[0] == '/' && + if (ZSTR_VAL(resource->path)[0] == '/' && ZSTR_VAL(resource->path)[1] == '\0') { spprintf(&loc_path, 0, "%s%s", ZSTR_VAL(resource->path), header_info.location); } else { diff --git a/ext/standard/image.c b/ext/standard/image.c index 7ce6767126bf..041cde9f0f6f 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -229,8 +229,6 @@ static struct php_gfxinfo *php_handle_swc(php_stream * stream) php_swf_get_bits (b, 5, bits)) / 20; result->height = (php_swf_get_bits (b, 5 + (3 * bits), bits) - php_swf_get_bits (b, 5 + (2 * bits), bits)) / 20; - } else { - result = NULL; } efree (b); diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 1da93228f71f..dff50340abcd 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -1287,11 +1287,7 @@ PHP_FUNCTION(unpack) x = php_pack_reverse_int64(x); } - if (type == 'q') { - v = (int64_t) x; - } else { - v = x; - } + v = x; ZVAL_LONG(&val, v); break; diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c index 66ba0da5f158..10a787bbd178 100644 --- a/ext/standard/pageinfo.c +++ b/ext/standard/pageinfo.c @@ -44,9 +44,7 @@ /* {{{ php_statpage */ PHPAPI void php_statpage(void) { - zend_stat_t *pstat = NULL; - - pstat = sapi_get_stat(); + zend_stat_t *pstat = sapi_get_stat(); if (BG(page_uid)==-1 || BG(page_gid)==-1) { if(pstat) { diff --git a/ext/standard/password.c b/ext/standard/password.c index a28ceb7e0ced..c88c9e3e5ff1 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -46,7 +46,7 @@ void php_password_algo_unregister(const char *ident) { static int php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */ { - size_t pos = 0; + size_t pos; zend_string *buffer; if ((int) str_len < 0) { return FAILURE; @@ -101,7 +101,7 @@ static zend_string* php_password_make_salt(size_t length) /* {{{ */ } /* }}} */ -static zend_string* php_password_get_salt(zval *unused_, size_t required_salt_len, HashTable *options) { +static zend_string* php_password_get_salt(size_t required_salt_len, HashTable *options) { if (options && zend_hash_str_exists(options, "salt", sizeof("salt") - 1)) { php_error_docref(NULL, E_WARNING, "The \"salt\" option has been ignored, since providing a custom salt is no longer supported"); } @@ -194,7 +194,7 @@ static zend_string* php_password_bcrypt_hash(const zend_string *password, zend_a } hash_format_len = snprintf(hash_format, sizeof(hash_format), "$2y$%02" ZEND_LONG_FMT_SPEC "$", cost); - if (!(salt = php_password_get_salt(NULL, Z_UL(22), options))) { + if (!(salt = php_password_get_salt(Z_UL(22), options))) { return NULL; } ZSTR_VAL(salt)[ZSTR_LEN(salt)] = 0; @@ -303,7 +303,7 @@ static zend_string *php_password_argon2_hash(const zend_string *password, zend_a size_t memory_cost = PHP_PASSWORD_ARGON2_MEMORY_COST; size_t threads = PHP_PASSWORD_ARGON2_THREADS; size_t encoded_len; - int status = 0; + int status; if (options && (option_buffer = zend_hash_str_find(options, "memory_cost", sizeof("memory_cost")-1)) != NULL) { memory_cost = zval_get_long(option_buffer); @@ -332,7 +332,7 @@ static zend_string *php_password_argon2_hash(const zend_string *password, zend_a return NULL; } - if (!(salt = php_password_get_salt(NULL, Z_UL(16), options))) { + if (!(salt = php_password_get_salt(Z_UL(16), options))) { return NULL; } diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index d544e8bf5f0f..32f8968903e4 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -249,9 +249,7 @@ PHP_FUNCTION(stream_socket_server) if (stream == NULL) { php_error_docref(NULL, E_WARNING, "Unable to connect to %s (%s)", host, errstr == NULL ? "Unknown error" : ZSTR_VAL(errstr)); - } - if (stream == NULL) { if (zerrno) { ZEND_TRY_ASSIGN_REF_LONG(zerrno, err); } diff --git a/ext/standard/string.c b/ext/standard/string.c index 2d868513e4ad..87b597dace02 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -753,7 +753,6 @@ PHP_FUNCTION(wordwrap) if (breakchar_len == 1 && !docut) { newtext = zend_string_init(ZSTR_VAL(text), ZSTR_LEN(text), 0); - laststart = lastspace = 0; for (current = 0; current < (zend_long)ZSTR_LEN(text); current++) { if (ZSTR_VAL(text)[current] == breakchar[0]) { laststart = lastspace = current + 1; @@ -785,7 +784,6 @@ PHP_FUNCTION(wordwrap) /* now keep track of the actual new text length */ newtextlen = 0; - laststart = lastspace = 0; for (current = 0; current < (zend_long)ZSTR_LEN(text); current++) { if (chk == 0) { alloced += (size_t) (((ZSTR_LEN(text) - current + 1)/linelength + 1) * breakchar_len) + 1; @@ -2288,10 +2286,6 @@ PHP_FUNCTION(chunk_split) RETURN_NEW_STR(result); } - if (!ZSTR_LEN(str)) { - RETURN_EMPTY_STRING(); - } - result = php_chunk_split(ZSTR_VAL(str), ZSTR_LEN(str), end, endlen, (size_t)chunklen); RETURN_STR(result); diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c index 583cbb5dc47a..9700facdb9f1 100644 --- a/ext/standard/strnatcmp.c +++ b/ext/standard/strnatcmp.c @@ -55,8 +55,6 @@ compare_right(char const **a, char const *aend, char const **b, char const *bend bias = +1; } } - - return 0; } /* }}} */ @@ -79,8 +77,6 @@ compare_left(char const **a, char const *aend, char const **b, char const *bend) else if (**a > **b) return +1; } - - return 0; } /* }}} */ diff --git a/ext/standard/url.c b/ext/standard/url.c index ac303027a722..461865110c41 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -106,7 +106,6 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port goto parse_port; } else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */ s += 2; - e = 0; goto parse_host; } else { goto just_path; diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index b699c12ed9ba..85ac8977a322 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -71,7 +71,6 @@ static ZEND_RSRC_DTOR_FUNC(php_bucket_dtor) php_stream_bucket *bucket = (php_stream_bucket *)res->ptr; if (bucket) { php_stream_bucket_delref(bucket); - bucket = NULL; } } diff --git a/ext/standard/var.c b/ext/standard/var.c index f94c1cf09584..7da08ee5347d 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -320,7 +320,7 @@ static void zval_object_property_dump(zend_property_info *prop_info, zval *zv, z PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */ { - HashTable *myht = NULL; + HashTable *myht; zend_string *class_name; zend_ulong index; zend_string *key; diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c index dc7ca71af469..c64805bd4b2c 100644 --- a/ext/standard/versioning.c +++ b/ext/standard/versioning.c @@ -105,13 +105,13 @@ static int compare_special_version_forms(char *form1, char *form2) }; special_forms_t *pp; - for (pp = special_forms; pp && pp->name; pp++) { + for (pp = special_forms; pp->name; pp++) { if (strncmp(form1, pp->name, pp->name_len) == 0) { found1 = pp->order; break; } } - for (pp = special_forms; pp && pp->name; pp++) { + for (pp = special_forms; pp->name; pp++) { if (strncmp(form2, pp->name, pp->name_len) == 0) { found2 = pp->order; break;