diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-06-01 11:58:57 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-06-01 11:58:57 +0300 |
commit | 0b90cf85a6ace22abd0f9f86d5015a5b6db92387 (patch) | |
tree | e01be0712ad1d7dbcd61c81ce03b9544a69e4972 | |
parent | 9e0f131d2b0e8bf98859c12104a7b0cd8951c135 (diff) | |
download | php-git-0b90cf85a6ace22abd0f9f86d5015a5b6db92387.tar.gz |
Removed "dead" code (zend_hash_update() never fails)
-rw-r--r-- | Zend/zend_API.c | 81 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 12 | ||||
-rw-r--r-- | Zend/zend_hash.c | 6 | ||||
-rw-r--r-- | Zend/zend_hash.h | 24 | ||||
-rw-r--r-- | Zend/zend_list.c | 4 | ||||
-rw-r--r-- | ext/interbase/interbase.c | 6 | ||||
-rw-r--r-- | ext/intl/msgformat/msgformat_helpers.cpp | 20 | ||||
-rw-r--r-- | ext/mbstring/mbstring.c | 8 | ||||
-rw-r--r-- | ext/oci8/oci8_statement.c | 6 | ||||
-rw-r--r-- | ext/odbc/php_odbc.c | 8 | ||||
-rw-r--r-- | ext/pcntl/pcntl.c | 5 | ||||
-rw-r--r-- | ext/pgsql/pgsql.c | 4 | ||||
-rw-r--r-- | ext/phar/dirstream.c | 3 | ||||
-rw-r--r-- | ext/phar/tar.c | 18 | ||||
-rw-r--r-- | ext/phar/zip.c | 26 | ||||
-rw-r--r-- | ext/soap/php_sdl.c | 18 | ||||
-rw-r--r-- | ext/standard/basic_functions.c | 3 | ||||
-rw-r--r-- | ext/standard/streamsfuncs.c | 4 | ||||
-rw-r--r-- | ext/xmlrpc/xmlrpc-epi-php.c | 8 | ||||
-rw-r--r-- | main/output.c | 16 | ||||
-rw-r--r-- | main/streams/streams.c | 6 | ||||
-rw-r--r-- | main/streams/transports.c | 5 |
22 files changed, 104 insertions, 187 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index a2ea7a7030..ab12fed9ad 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1383,90 +1383,88 @@ ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC) /* {{{ */ ZEND_API int add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_LONG(&tmp, n); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_null_ex(zval *arg, const char *key, size_t key_len) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_NULL(&tmp); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_BOOL(&tmp, b); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_RES(&tmp, r); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_DOUBLE(&tmp, d); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_STR(&tmp, str); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, const char *str) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_STRING(&tmp, str); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length) /* {{{ */ { - zval *ret, tmp; + zval tmp; ZVAL_STRINGL(&tmp, str, length); - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */ { - zval *ret; - - ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, value); - return ret ? SUCCESS : FAILURE; + zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, value); + return SUCCESS; } /* }}} */ @@ -1475,7 +1473,8 @@ ZEND_API int add_index_long(zval *arg, zend_ulong index, zend_long n) /* {{{ */ zval tmp; ZVAL_LONG(&tmp, n); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ @@ -1484,7 +1483,8 @@ ZEND_API int add_index_null(zval *arg, zend_ulong index) /* {{{ */ zval tmp; ZVAL_NULL(&tmp); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ @@ -1493,7 +1493,8 @@ ZEND_API int add_index_bool(zval *arg, zend_ulong index, int b) /* {{{ */ zval tmp; ZVAL_BOOL(&tmp, b); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ @@ -1502,7 +1503,8 @@ ZEND_API int add_index_resource(zval *arg, zend_ulong index, zend_resource *r) / zval tmp; ZVAL_RES(&tmp, r); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ @@ -1511,7 +1513,8 @@ ZEND_API int add_index_double(zval *arg, zend_ulong index, double d) /* {{{ */ zval tmp; ZVAL_DOUBLE(&tmp, d); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ @@ -1520,7 +1523,8 @@ ZEND_API int add_index_str(zval *arg, zend_ulong index, zend_string *str) /* {{{ zval tmp; ZVAL_STR(&tmp, str); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ @@ -1529,7 +1533,8 @@ ZEND_API int add_index_string(zval *arg, zend_ulong index, const char *str) /* { zval tmp; ZVAL_STRING(&tmp, str); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ @@ -1538,13 +1543,15 @@ ZEND_API int add_index_stringl(zval *arg, zend_ulong index, const char *str, siz zval tmp; ZVAL_STRINGL(&tmp, str, length); - return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); + return SUCCESS; } /* }}} */ ZEND_API int add_index_zval(zval *arg, zend_ulong index, zval *value) /* {{{ */ { - return zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE; + zend_hash_index_update(Z_ARRVAL_P(arg), index, value); + return SUCCESS; } /* }}} */ diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 4f394df21a..e7a96af743 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1606,11 +1606,13 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{ if (force) { zend_array *symbol_table = zend_rebuild_symbol_table(); if (symbol_table) { - return zend_hash_update(symbol_table, name, value) ? SUCCESS : FAILURE; + zend_hash_update(symbol_table, name, value); + return SUCCESS; } } } else { - return (zend_hash_update_ind(execute_data->symbol_table, name, value) != NULL) ? SUCCESS : FAILURE; + zend_hash_update_ind(execute_data->symbol_table, name, value); + return SUCCESS; } } return FAILURE; @@ -1648,11 +1650,13 @@ ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, i if (force) { zend_array *symbol_table = zend_rebuild_symbol_table(); if (symbol_table) { - return zend_hash_str_update(symbol_table, name, len, value) ? SUCCESS : FAILURE; + zend_hash_str_update(symbol_table, name, len, value); + return SUCCESS; } } } else { - return (zend_hash_str_update_ind(execute_data->symbol_table, name, len, value) != NULL) ? SUCCESS : FAILURE; + zend_hash_str_update_ind(execute_data->symbol_table, name, len, value); + return SUCCESS; } } return FAILURE; diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 8cb666a708..2de46b4f99 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -1994,12 +1994,12 @@ ZEND_API void ZEND_FASTCALL _zend_hash_merge(HashTable *target, HashTable *sourc } if (p->key) { t = _zend_hash_add_or_update_i(target, p->key, &p->val, HASH_UPDATE | HASH_UPDATE_INDIRECT ZEND_FILE_LINE_RELAY_CC); - if (t && pCopyConstructor) { + if (pCopyConstructor) { pCopyConstructor(t); } } else { t = zend_hash_index_update(target, p->h, &p->val); - if (t && pCopyConstructor) { + if (pCopyConstructor) { pCopyConstructor(t); } } @@ -2053,7 +2053,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_merge_ex(HashTable *target, HashTable *sou if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue; if (zend_hash_replace_checker_wrapper(target, &p->val, p, pParam, pMergeSource)) { t = zend_hash_update(target, p->key, &p->val); - if (t && pCopyConstructor) { + if (pCopyConstructor) { pCopyConstructor(t); } } diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index f2399ca937..c65c849dda 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -654,12 +654,8 @@ static zend_always_inline void *zend_hash_update_ptr(HashTable *ht, zend_string ZVAL_PTR(&tmp, pData); zv = zend_hash_update(ht, key, &tmp); - if (zv) { - ZEND_ASSUME(Z_PTR_P(zv)); - return Z_PTR_P(zv); - } else { - return NULL; - } + ZEND_ASSUME(Z_PTR_P(zv)); + return Z_PTR_P(zv); } static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht, const char *str, size_t len, void *pData) @@ -668,12 +664,8 @@ static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht, const ch ZVAL_PTR(&tmp, pData); zv = zend_hash_str_update(ht, str, len, &tmp); - if (zv) { - ZEND_ASSUME(Z_PTR_P(zv)); - return Z_PTR_P(zv); - } else { - return NULL; - } + ZEND_ASSUME(Z_PTR_P(zv)); + return Z_PTR_P(zv); } static zend_always_inline void *zend_hash_add_mem(HashTable *ht, zend_string *key, void *pData, size_t size) @@ -770,12 +762,8 @@ static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_u ZVAL_PTR(&tmp, pData); zv = zend_hash_index_update(ht, h, &tmp); - if (zv) { - ZEND_ASSUME(Z_PTR_P(zv)); - return Z_PTR_P(zv); - } else { - return NULL; - } + ZEND_ASSUME(Z_PTR_P(zv)); + return Z_PTR_P(zv); } static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size) diff --git a/Zend/zend_list.c b/Zend/zend_list.c index cf6e1006b4..69d3b3d142 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -347,10 +347,6 @@ ZEND_API zend_resource* zend_register_persistent_resource_ex(zend_string *key, v GC_MAKE_PERSISTENT_LOCAL(key); zv = zend_hash_update(&EG(persistent_list), key, &tmp); - if (UNEXPECTED(zv == NULL)) { - free(Z_RES(tmp)); - return NULL; - } return Z_RES_P(zv); } diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c index 288534728a..376ecc4da8 100644 --- a/ext/interbase/interbase.c +++ b/ext/interbase/interbase.c @@ -1015,10 +1015,8 @@ static void _php_ibase_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) /* /* add it to the hash */ new_index_ptr.ptr = (void *) Z_RES_P(return_value); new_index_ptr.type = le_index_ptr; - if (zend_hash_str_update_mem(&EG(regular_list), hash, sizeof(hash)-1, - (void *) &new_index_ptr, sizeof(zend_resource)) == NULL) { - RETURN_FALSE; - } + zend_hash_str_update_mem(&EG(regular_list), hash, sizeof(hash)-1, + (void *) &new_index_ptr, sizeof(zend_resource)); if (IBG(default_link)) { zend_list_delete(IBG(default_link)); } diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index 65a00289b5..a3005ded3b 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -122,11 +122,7 @@ static HashTable *umsg_get_numeric_types(MessageFormatter_object *mfo, for (int i = 0; i < parts_count; i++) { const Formattable::Type t = types[i]; - if (zend_hash_index_update_mem(ret, (zend_ulong)i, (void*)&t, sizeof(t)) == NULL) { - intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, - "Write to argument types hash table failed", 0); - break; - } + zend_hash_index_update_mem(ret, (zend_ulong)i, (void*)&t, sizeof(t)); } if (U_FAILURE(err.code)) { @@ -196,12 +192,8 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, if ((storedType = (Formattable::Type*)zend_hash_str_find_ptr(ret, (char*)argName.getBuffer(), argName.length())) == NULL) { /* not found already; create new entry in HT */ Formattable::Type bogusType = Formattable::kObject; - if ((storedType = (Formattable::Type*)zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length(), - (void*)&bogusType, sizeof(bogusType))) == NULL) { - intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, - "Write to argument types hash table failed", 0); - continue; - } + storedType = (Formattable::Type*)zend_hash_str_update_mem(ret, (char*)argName.getBuffer(), argName.length(), + (void*)&bogusType, sizeof(bogusType)); } } else if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NUMBER) { int32_t argNumber = name_part.getValue(); @@ -213,11 +205,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, if ((storedType = (Formattable::Type*)zend_hash_index_find_ptr(ret, (zend_ulong)argNumber)) == NULL) { /* not found already; create new entry in HT */ Formattable::Type bogusType = Formattable::kObject; - if ((storedType = (Formattable::Type*)zend_hash_index_update_mem(ret, (zend_ulong)argNumber, (void*)&bogusType, sizeof(bogusType))) == NULL) { - intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, - "Write to argument types hash table failed", 0); - continue; - } + storedType = (Formattable::Type*)zend_hash_index_update_mem(ret, (zend_ulong)argNumber, (void*)&bogusType, sizeof(bogusType)); } } else { intl_errors_set(&err, U_INVALID_FORMAT_ERROR, "Invalid part type encountered", 0); diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 8ed185c76a..b17b8f8f8e 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -1608,7 +1608,6 @@ ZEND_TSRMLS_CACHE_UPDATE(); zend_function *func, *orig; const struct mb_overload_def *p; zend_string *str; - void *ret; p = &(mb_ovld[0]); while (p->type > 0) { @@ -1628,13 +1627,8 @@ ZEND_TSRMLS_CACHE_UPDATE(); function_add_ref(orig); str = zend_string_init_interned(p->orig_func, strlen(p->orig_func), 1); - ret = zend_hash_update_mem(CG(function_table), str, func, sizeof(zend_internal_function)); + zend_hash_update_mem(CG(function_table), str, func, sizeof(zend_internal_function)); zend_string_release_ex(str, 1); - if (ret == NULL) { - php_error_docref("ref.mbstring", E_WARNING, "mbstring couldn't replace function %s.", p->orig_func); - return FAILURE; - } - function_add_ref(func); } } diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 8d259eebfa..469930fbb4 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -595,11 +595,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode) for (counter = 1; counter <= colcount; counter++) { outcol = (php_oci_out_column *) ecalloc(1, sizeof(php_oci_out_column)); - if ((outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol)) == NULL) { - FREE_HASHTABLE(statement->columns); - /* out of memory */ - return 1; - } + outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol); /* get column */ PHP_OCI_CALL_RETURN(errstatus, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)¶m, counter)); diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index fefb6d91b2..0ecdee98e5 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -2677,12 +2677,8 @@ try_and_get_another_connection: new_index_ptr.ptr = (void *)(zend_uintptr_t)Z_RES_HANDLE_P(return_value); new_index_ptr.type = le_index_ptr; - if (zend_hash_str_update_mem(&EG(regular_list), hashed_details, hashed_len, (void *) &new_index_ptr, - sizeof(zend_resource)) == NULL) { - efree(hashed_details); - RETURN_FALSE; - /* XXX Free Connection */ - } + zend_hash_str_update_mem(&EG(regular_list), hashed_details, hashed_len, (void *) &new_index_ptr, + sizeof(zend_resource)); ODBCG(num_links)++; } efree(hashed_details); diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 9c51659181..6c873a2619 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -1054,9 +1054,8 @@ PHP_FUNCTION(pcntl_signal) } /* Add the function name to our signal table */ - if (zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle)) { - Z_TRY_ADDREF_P(handle); - } + handle = zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle); + Z_TRY_ADDREF_P(handle); if (php_signal4(signo, pcntl_signal_handler, (int) restart_syscalls, 1) == (Sigfunc *)SIG_ERR) { PCNTL_G(last_error) = errno; diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index f0873ce854..c463cd79a9 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1492,9 +1492,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) /* add it to the hash */ new_index_ptr.ptr = (void *) Z_RES_P(return_value); new_index_ptr.type = le_index_ptr; - if (zend_hash_update_mem(&EG(regular_list), str.s, (void *) &new_index_ptr, sizeof(zend_resource)) == NULL) { - goto err; - } + zend_hash_update_mem(&EG(regular_list), str.s, (void *) &new_index_ptr, sizeof(zend_resource)); PGG(num_links)++; } /* set notice processor */ diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index abc60a039e..70e696a167 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -145,7 +145,8 @@ static int phar_add_empty(HashTable *ht, char *arKey, uint32_t nKeyLength) /* { zval dummy; ZVAL_NULL(&dummy); - return (zend_hash_str_update(ht, arKey, nKeyLength, &dummy) != NULL) ? SUCCESS : FAILURE; + zend_hash_str_update(ht, arKey, nKeyLength, &dummy); + return SUCCESS; } /* }}} */ diff --git a/ext/phar/tar.c b/ext/phar/tar.c index d673cc0f68..4241298fe2 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -997,14 +997,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int entry.uncompressed_filesize = phar->alias_len; - if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) { - if (error) { - spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"", phar->fname); - } - php_stream_close(entry.fp); - efree(entry.filename); - return EOF; - } + zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info)); /* At this point the entry is saved into the manifest. The manifest destroy routine will care about any resources to be freed. */ } else { @@ -1129,14 +1122,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int efree(entry.filename); } } else { - if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) { - php_stream_close(entry.fp); - efree(entry.filename); - if (error) { - spprintf(error, 0, "unable to overwrite stub in tar-based phar \"%s\"", phar->fname); - } - return EOF; - } + zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info)); } } nostub: diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 40171203d5..e044a5c3ff 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1233,12 +1233,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1); entry.filename_len = sizeof(".phar/alias.txt")-1; - if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) { - if (error) { - spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname); - } - return EOF; - } + zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info)); } else { zend_hash_str_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1); } @@ -1331,15 +1326,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); entry.filename_len = sizeof(".phar/stub.php")-1; - if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) { - if (free_user_stub) { - efree(user_stub); - } - if (error) { - spprintf(error, 0, "unable to set stub in zip-based phar \"%s\"", phar->fname); - } - return EOF; - } + zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info)); if (free_user_stub) { efree(user_stub); @@ -1378,14 +1365,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int efree(entry.filename); } } else { - if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) { - php_stream_close(entry.fp); - efree(entry.filename); - if (error) { - spprintf(error, 0, "unable to overwrite stub in zip-based phar \"%s\"", phar->fname); - } - return EOF; - } + zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info)); } } nostub: diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index 05df5e7e0c..440c4a7448 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -3360,18 +3360,12 @@ cache_in_memory: p.time = t; p.sdl = psdl; - if (NULL != zend_hash_str_update_mem(SOAP_GLOBAL(mem_cache), uri, - uri_len, &p, sizeof(sdl_cache_bucket))) { - /* remove non-persitent sdl structure */ - delete_sdl_impl(sdl); - /* and replace it with persistent one */ - sdl = psdl; - } else { - php_error_docref(NULL, E_WARNING, "Failed to register persistent entry"); - /* clean up persistent sdl */ - delete_psdl_int(&p); - /* keep non-persistent sdl and return it */ - } + zend_hash_str_update_mem(SOAP_GLOBAL(mem_cache), uri, + uri_len, &p, sizeof(sdl_cache_bucket)); + /* remove non-persitent sdl structure */ + delete_sdl_impl(sdl); + /* and replace it with persistent one */ + sdl = psdl; } } diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 5a4c1f4a2d..578c52d3e9 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5203,7 +5203,8 @@ PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t fun zend_hash_init(BG(user_shutdown_function_names), 0, NULL, user_shutdown_function_dtor, 0); } - return zend_hash_str_update_mem(BG(user_shutdown_function_names), function_name, function_len, shutdown_function_entry, sizeof(php_shutdown_function_entry)) != NULL; + zend_hash_str_update_mem(BG(user_shutdown_function_names), function_name, function_len, shutdown_function_entry, sizeof(php_shutdown_function_entry)); + return 1; } /* }}} */ diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 047a99892f..7f717c4b08 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -689,9 +689,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds) dest_elem = zend_hash_update(ht, key, elem); } - if (dest_elem) { - zval_add_ref(dest_elem); - } + zval_add_ref(dest_elem); ret++; continue; } diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index 0a35c5ea3f..6fbb66ddc5 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -1285,9 +1285,8 @@ int set_zval_xmlrpc_type(zval* value, XMLRPC_VALUE_TYPE newtype) /* {{{ */ ZVAL_LONG(&ztimestamp, timestamp); convert_to_object(value); - if (zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1, &type)) { - bSuccess = (zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_VALUE_TS_ATTR, sizeof(OBJECT_VALUE_TS_ATTR) - 1, &ztimestamp) != NULL)? SUCCESS : FAILURE; - } + zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1, &type); + bSuccess = (zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_VALUE_TS_ATTR, sizeof(OBJECT_VALUE_TS_ATTR) - 1, &ztimestamp) != NULL)? SUCCESS : FAILURE; } else { zval_ptr_dtor(&type); } @@ -1297,7 +1296,8 @@ int set_zval_xmlrpc_type(zval* value, XMLRPC_VALUE_TYPE newtype) /* {{{ */ } } else { convert_to_object(value); - bSuccess = (zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1, &type) != NULL)? SUCCESS : FAILURE; + zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1, &type); + bSuccess = SUCCESS; } } } diff --git a/main/output.c b/main/output.c index 63850a7cd6..82d36e8048 100644 --- a/main/output.c +++ b/main/output.c @@ -609,7 +609,6 @@ PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_n * Register a conflict checking function on MINIT */ PHPAPI int php_output_handler_conflict_register(const char *name, size_t name_len, php_output_handler_conflict_check_t check_func) { - int ret; zend_string *str; if (!EG(current_module)) { @@ -617,9 +616,9 @@ PHPAPI int php_output_handler_conflict_register(const char *name, size_t name_le return FAILURE; } str = zend_string_init_interned(name, name_len, 1); - ret = zend_hash_update_ptr(&php_output_handler_conflicts, str, check_func) ? SUCCESS : FAILURE; + zend_hash_update_ptr(&php_output_handler_conflicts, str, check_func); zend_string_release_ex(str, 1); - return ret; + return SUCCESS; } /* }}} */ @@ -646,12 +645,9 @@ PHPAPI int php_output_handler_reverse_conflict_register(const char *name, size_t return FAILURE; } str = zend_string_init_interned(name, name_len, 1); - ret = zend_hash_update_mem(&php_output_handler_reverse_conflicts, str, &rev, sizeof(HashTable)) ? SUCCESS : FAILURE; + zend_hash_update_mem(&php_output_handler_reverse_conflicts, str, &rev, sizeof(HashTable)); zend_string_release_ex(str, 1); - if (ret != SUCCESS) { - zend_hash_destroy(&rev); - } - return ret; + return SUCCESS; } } /* }}} */ @@ -676,9 +672,9 @@ PHPAPI int php_output_handler_alias_register(const char *name, size_t name_len, return FAILURE; } str = zend_string_init_interned(name, name_len, 1); - ret = zend_hash_update_ptr(&php_output_handler_aliases, str, func) ? SUCCESS : FAILURE; + zend_hash_update_ptr(&php_output_handler_aliases, str, func); zend_string_release_ex(str, 1); - return ret; + return SUCCESS; } /* }}} */ diff --git a/main/streams/streams.c b/main/streams/streams.c index 8d6c4f727c..b82f092f0c 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2205,14 +2205,12 @@ PHPAPI int php_stream_context_set_option(php_stream_context *context, if (NULL == wrapperhash) { array_init(&category); wrapperhash = zend_hash_str_update(Z_ARRVAL(context->options), (char*)wrappername, strlen(wrappername), &category); - if (NULL == wrapperhash) { - return FAILURE; - } } ZVAL_DEREF(optionvalue); Z_TRY_ADDREF_P(optionvalue); SEPARATE_ARRAY(wrapperhash); - return zend_hash_str_update(Z_ARRVAL_P(wrapperhash), optionname, strlen(optionname), optionvalue) ? SUCCESS : FAILURE; + zend_hash_str_update(Z_ARRVAL_P(wrapperhash), optionname, strlen(optionname), optionvalue); + return SUCCESS; } /* }}} */ diff --git a/main/streams/transports.c b/main/streams/transports.c index 6fc77910d4..3015f4cc06 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -31,12 +31,11 @@ PHPAPI HashTable *php_stream_xport_get_hash(void) PHPAPI int php_stream_xport_register(const char *protocol, php_stream_transport_factory factory) { - int ret; zend_string *str = zend_string_init_interned(protocol, strlen(protocol), 1); - ret = zend_hash_update_ptr(&xport_hash, str, factory) ? SUCCESS : FAILURE; + zend_hash_update_ptr(&xport_hash, str, factory); zend_string_release_ex(str, 1); - return ret; + return SUCCESS; } PHPAPI int php_stream_xport_unregister(const char *protocol) |