Skip to content

Commit 922285e

Browse files
committed
Don't use cast (compiler friendly)
1 parent 0ade00c commit 922285e

File tree

8 files changed

+31
-25
lines changed

8 files changed

+31
-25
lines changed

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6831,7 +6831,7 @@ static int zend_auto_global_init(zval *zv TSRMLS_DC) /* {{{ */
68316831

68326832
ZEND_API void zend_activate_auto_globals(TSRMLS_D) /* {{{ */
68336833
{
6834-
zend_hash_apply(CG(auto_globals), (apply_func_t) zend_auto_global_init TSRMLS_CC);
6834+
zend_hash_apply(CG(auto_globals), zend_auto_global_init TSRMLS_CC);
68356835
}
68366836
/* }}} */
68376837

Zend/zend_constants.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ static int clean_non_persistent_constant_full(zval *zv TSRMLS_DC)
8282
}
8383

8484

85-
static int clean_module_constant(const zend_constant *c, int *module_number TSRMLS_DC)
85+
static int clean_module_constant(zval *el, void *arg TSRMLS_DC)
8686
{
87-
if (c->module_number == *module_number) {
87+
zend_constant *c = (zend_constant *)Z_PTR_P(el);
88+
int module_number = *(int *)arg;
89+
90+
if (c->module_number == module_number) {
8891
return 1;
8992
} else {
9093
return 0;
@@ -94,7 +97,7 @@ static int clean_module_constant(const zend_constant *c, int *module_number TSRM
9497

9598
void clean_module_constants(int module_number TSRMLS_DC)
9699
{
97-
zend_hash_apply_with_argument(EG(zend_constants), (apply_func_arg_t) clean_module_constant, (void *) &module_number TSRMLS_CC);
100+
zend_hash_apply_with_argument(EG(zend_constants), clean_module_constant, (void *) &module_number TSRMLS_CC);
98101
}
99102

100103

Zend/zend_ini.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ static HashTable *registered_zend_ini_directives;
3434
/*
3535
* hash_apply functions
3636
*/
37-
static int zend_remove_ini_entries(zval *el, int *module_number TSRMLS_DC) /* {{{ */
37+
static int zend_remove_ini_entries(zval *el, void *arg TSRMLS_DC) /* {{{ */
3838
{
3939
zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
40-
if (ini_entry->module_number == *module_number) {
40+
int module_number = *(int *)arg;
41+
if (ini_entry->module_number == module_number) {
4142
return 1;
4243
} else {
4344
return 0;

Zend/zend_list.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,22 @@ void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC)
228228
zend_hash_graceful_reverse_destroy(ht);
229229
}
230230

231-
static int clean_module_resource(zval *zv, int *resource_id TSRMLS_DC)
231+
static int clean_module_resource(zval *zv, void *arg TSRMLS_DC)
232232
{
233-
if (Z_RES_TYPE_P(zv) == *resource_id) {
233+
int resource_id = *(int *)arg;
234+
if (Z_RES_TYPE_P(zv) == resource_id) {
234235
return 1;
235236
} else {
236237
return 0;
237238
}
238239
}
239240

240241

241-
static int zend_clean_module_rsrc_dtors_cb(zval *zv, int *module_number TSRMLS_DC)
242+
static int zend_clean_module_rsrc_dtors_cb(zval *zv, void *arg TSRMLS_DC)
242243
{
243-
zend_rsrc_list_dtors_entry *ld = Z_PTR_P(zv);
244-
if (ld->module_number == *module_number) {
244+
zend_rsrc_list_dtors_entry *ld = (zend_rsrc_list_dtors_entry *)Z_PTR_P(zv);
245+
int module_number = *(int *)arg;
246+
if (ld->module_number == module_number) {
245247
zend_hash_apply_with_argument(&EG(persistent_list), clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC);
246248
return 1;
247249
} else {

ext/standard/basic_functions.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4526,7 +4526,7 @@ static int add_config_entry_cb(zval *entry TSRMLS_DC, int num_args, va_list args
45264526
}
45274527
} else if (Z_TYPE_P(entry) == IS_ARRAY) {
45284528
array_init(&tmp);
4529-
zend_hash_apply_with_arguments(Z_ARRVAL_P(entry) TSRMLS_CC, (apply_func_args_t) add_config_entry_cb, 1, tmp);
4529+
zend_hash_apply_with_arguments(Z_ARRVAL_P(entry) TSRMLS_CC, add_config_entry_cb, 1, tmp);
45304530
zend_hash_update(Z_ARRVAL_P(retval), hash_key->key, &tmp);
45314531
}
45324532
return 0;
@@ -4550,7 +4550,7 @@ PHP_FUNCTION(get_cfg_var)
45504550
if (retval) {
45514551
if (Z_TYPE_P(retval) == IS_ARRAY) {
45524552
array_init(return_value);
4553-
zend_hash_apply_with_arguments(Z_ARRVAL_P(retval) TSRMLS_CC, (apply_func_args_t) add_config_entry_cb, 1, return_value);
4553+
zend_hash_apply_with_arguments(Z_ARRVAL_P(retval) TSRMLS_CC, add_config_entry_cb, 1, return_value);
45544554
return;
45554555
} else {
45564556
RETURN_STRING(Z_STRVAL_P(retval));
@@ -4939,7 +4939,7 @@ void php_call_shutdown_functions(TSRMLS_D) /* {{{ */
49394939
{
49404940
if (BG(user_shutdown_function_names)) {
49414941
zend_try {
4942-
zend_hash_apply(BG(user_shutdown_function_names), (apply_func_t) user_shutdown_function_call TSRMLS_CC);
4942+
zend_hash_apply(BG(user_shutdown_function_names), user_shutdown_function_call TSRMLS_CC);
49434943
}
49444944
zend_end_try();
49454945
php_free_shutdown_functions(TSRMLS_C);
@@ -5262,7 +5262,7 @@ PHP_FUNCTION(ini_get_all)
52625262
}
52635263

52645264
array_init(return_value);
5265-
zend_hash_apply_with_arguments(EG(ini_directives) TSRMLS_CC, (apply_func_args_t) php_ini_get_option, 2, return_value, extnumber, details);
5265+
zend_hash_apply_with_arguments(EG(ini_directives) TSRMLS_CC, php_ini_get_option, 2, return_value, extnumber, details);
52665266
}
52675267
/* }}} */
52685268

@@ -5902,7 +5902,7 @@ PHP_FUNCTION(config_get_hash) /* {{{ */
59025902
HashTable *hash = php_ini_get_configuration_hash();
59035903

59045904
array_init(return_value);
5905-
zend_hash_apply_with_arguments(hash TSRMLS_CC, (apply_func_args_t) add_config_entry_cb, 1, return_value);
5905+
zend_hash_apply_with_arguments(hash TSRMLS_CC, add_config_entry_cb, 1, return_value);
59065906
}
59075907
/* }}} */
59085908
#endif

ext/standard/browscap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ PHP_FUNCTION(get_browser)
483483

484484
if ((agent = zend_hash_str_find(bdata->htab, lookup_browser_name, agent_name_len)) == NULL) {
485485
ZVAL_UNDEF(&found_browser_entry);
486-
zend_hash_apply_with_arguments(bdata->htab TSRMLS_CC, (apply_func_args_t) browser_reg_compare, 3, lookup_browser_name, agent_name_len, &found_browser_entry);
486+
zend_hash_apply_with_arguments(bdata->htab TSRMLS_CC, browser_reg_compare, 3, lookup_browser_name, agent_name_len, &found_browser_entry);
487487

488488
if (Z_TYPE(found_browser_entry) != IS_UNDEF) {
489489
agent = &found_browser_entry;

ext/standard/var.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
119119
{
120120
HashTable *myht;
121121
zend_string *class_name;
122-
int (*php_element_dump_func)(zval* TSRMLS_DC, int, va_list, zend_hash_key*);
122+
apply_func_args_t php_element_dump_func;
123123
int is_temp;
124124
int is_ref = 0;
125125

@@ -178,7 +178,7 @@ PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
178178
php_element_dump_func = php_object_property_dump;
179179
head_done:
180180
if (myht) {
181-
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_element_dump_func, 1, level);
181+
zend_hash_apply_with_arguments(myht TSRMLS_CC, php_element_dump_func, 1, level);
182182
--myht->u.v.nApplyCount;
183183
if (is_temp) {
184184
zend_hash_destroy(myht);
@@ -297,7 +297,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
297297
{
298298
HashTable *myht = NULL;
299299
zend_string *class_name;
300-
int (*zval_element_dump_func)(zval* TSRMLS_DC, int, va_list, zend_hash_key*);
300+
apply_func_args_t zval_element_dump_func;
301301
int is_temp = 0;
302302
int is_ref = 0;
303303

@@ -348,7 +348,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
348348
zval_element_dump_func = zval_object_property_dump;
349349
head_done:
350350
if (myht) {
351-
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) zval_element_dump_func, 1, level, (Z_TYPE_P(struc) == IS_ARRAY ? 0 : 1));
351+
zend_hash_apply_with_arguments(myht TSRMLS_CC, zval_element_dump_func, 1, level, (Z_TYPE_P(struc) == IS_ARRAY ? 0 : 1));
352352
if (is_temp) {
353353
zend_hash_destroy(myht);
354354
efree(myht);
@@ -537,7 +537,7 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf TSRMLS_DC)
537537
buffer_append_spaces(buf, level - 1);
538538
}
539539
smart_str_appendl(buf, "array (\n", 8);
540-
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_array_element_export, 2, level, buf);
540+
zend_hash_apply_with_arguments(myht TSRMLS_CC, php_array_element_export, 2, level, buf);
541541

542542
if (level > 1) {
543543
buffer_append_spaces(buf, level - 1);
@@ -564,7 +564,7 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf TSRMLS_DC)
564564

565565
STR_RELEASE(class_name);
566566
if (myht) {
567-
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 1, level, buf);
567+
zend_hash_apply_with_arguments(myht TSRMLS_CC, php_object_element_export, 1, level, buf);
568568
}
569569
if (level > 1) {
570570
buffer_append_spaces(buf, level - 1);

main/streams/streams.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fprintf(stderr, "forget_persistent: %s:%p\n", stream->ops->label, stream);
103103

104104
PHP_RSHUTDOWN_FUNCTION(streams)
105105
{
106-
zend_hash_apply(&EG(persistent_list), (apply_func_t)forget_persistent_resource_id_numbers TSRMLS_CC);
106+
zend_hash_apply(&EG(persistent_list), forget_persistent_resource_id_numbers TSRMLS_CC);
107107
return SUCCESS;
108108
}
109109

@@ -517,7 +517,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
517517

518518
if (stream->is_persistent && (close_options & PHP_STREAM_FREE_PERSISTENT)) {
519519
/* we don't work with *stream but need its value for comparison */
520-
zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) _php_stream_free_persistent, stream TSRMLS_CC);
520+
zend_hash_apply_with_argument(&EG(persistent_list), _php_stream_free_persistent, stream TSRMLS_CC);
521521
}
522522
#if ZEND_DEBUG
523523
if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) && (stream->__exposed == 0) && (EG(error_reporting) & E_WARNING)) {

0 commit comments

Comments
 (0)