Skip to content

Commit 5864ce8

Browse files
committed
Fixed compilation warnings
1 parent c0b49a7 commit 5864ce8

20 files changed

+80
-85
lines changed

Diff for: Zend/zend.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
133133
{
134134
zval *tmp;
135135
zend_string *string_key;
136-
HashPosition iterator;
137136
ulong num_key;
138137
int i;
139138

@@ -193,7 +192,6 @@ static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */
193192
{
194193
zval *tmp;
195194
zend_string *string_key;
196-
HashPosition iterator;
197195
ulong num_key;
198196
int i = 0;
199197

@@ -1029,7 +1027,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
10291027
zval params[5];
10301028
zval retval;
10311029
const char *error_filename;
1032-
uint error_lineno;
1030+
uint error_lineno = 0;
10331031
zval orig_user_error_handler;
10341032
zend_bool in_compilation;
10351033
zend_class_entry *saved_class_entry;

Diff for: Zend/zend_API.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -1222,10 +1222,9 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti
12221222
if (object->ce->default_properties_count) {
12231223
zval *prop, tmp;
12241224
zend_string *key;
1225-
ulong num_key;
12261225
zend_property_info *property_info;
12271226

1228-
ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, prop) {
1227+
ZEND_HASH_FOREACH_STR_KEY_VAL(properties, key, prop) {
12291228
ZVAL_STR(&tmp, key);
12301229
property_info = zend_get_property_info(object->ce, &tmp, 1 TSRMLS_CC);
12311230
if (property_info &&
@@ -1243,10 +1242,9 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties
12431242
{
12441243
zval *prop, tmp;
12451244
zend_string *key;
1246-
ulong num_key;
12471245
zend_property_info *property_info;
12481246

1249-
ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, prop) {
1247+
ZEND_HASH_FOREACH_STR_KEY_VAL(properties, key, prop) {
12501248
ZVAL_STR(&tmp, key);
12511249
property_info = zend_get_property_info(object->ce, &tmp, 1 TSRMLS_CC);
12521250
if (property_info &&
@@ -4000,10 +3998,8 @@ ZEND_API zend_string* zend_find_alias_name(zend_class_entry *ce, zend_string *na
40003998
ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f) /* {{{ */
40013999
{
40024000
zend_function *func;
4003-
HashPosition iterator;
40044001
HashTable *function_table;
40054002
zend_string *name;
4006-
ulong idx;
40074003

40084004
if (f->common.type != ZEND_USER_FUNCTION ||
40094005
*(f->op_array.refcount) < 2 ||
@@ -4013,7 +4009,7 @@ ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_functi
40134009
}
40144010

40154011
function_table = &ce->function_table;
4016-
ZEND_HASH_FOREACH_KEY_PTR(function_table, idx, name, func) {
4012+
ZEND_HASH_FOREACH_STR_KEY_PTR(function_table, name, func) {
40174013
if (func == f) {
40184014
if (!name) {
40194015
return f->common.function_name;

Diff for: Zend/zend_builtin_functions.c

+8-15
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,10 @@ ZEND_FUNCTION(each)
619619
zend_hash_str_update(Z_ARRVAL_P(return_value), "value", sizeof("value")-1, entry);
620620

621621
/* add the key elements */
622-
switch (zend_hash_get_current_key(target_hash, &key, &num_key, 0)) {
623-
case HASH_KEY_IS_STRING:
624-
inserted_pointer = add_get_index_str(return_value, 0, STR_COPY(key));
625-
break;
626-
case HASH_KEY_IS_LONG:
627-
inserted_pointer = add_get_index_long(return_value, 0, num_key);
628-
break;
622+
if (zend_hash_get_current_key(target_hash, &key, &num_key, 0) == HASH_KEY_IS_STRING) {
623+
inserted_pointer = add_get_index_str(return_value, 0, STR_COPY(key));
624+
} else {
625+
inserted_pointer = add_get_index_long(return_value, 0, num_key);
629626
}
630627
zend_hash_str_update(Z_ARRVAL_P(return_value), "key", sizeof("key")-1, inserted_pointer);
631628
if (Z_REFCOUNTED_P(inserted_pointer)) Z_ADDREF_P(inserted_pointer);
@@ -902,9 +899,8 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
902899
zend_property_info *prop_info;
903900
zval *prop, prop_copy;
904901
zend_string *key;
905-
ulong num_index;
906902

907-
ZEND_HASH_FOREACH_KEY_PTR(&ce->properties_info, num_index, key, prop_info) {
903+
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) {
908904
if (((prop_info->flags & ZEND_ACC_SHADOW) &&
909905
prop_info->ce != EG(scope)) ||
910906
((prop_info->flags & ZEND_ACC_PROTECTED) &&
@@ -975,7 +971,6 @@ ZEND_FUNCTION(get_object_vars)
975971
zend_string *key;
976972
const char *prop_name, *class_name;
977973
uint prop_len;
978-
ulong num_index;
979974
zend_object *zobj;
980975

981976
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
@@ -996,7 +991,7 @@ ZEND_FUNCTION(get_object_vars)
996991

997992
array_init(return_value);
998993

999-
ZEND_HASH_FOREACH_KEY_VAL_IND(properties, num_index, key, value) {
994+
ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) {
1000995
if (key) {
1001996
if (zend_check_property_access(zobj, key TSRMLS_CC) == SUCCESS) {
1002997
/* Not separating references */
@@ -1030,7 +1025,6 @@ ZEND_FUNCTION(get_class_methods)
10301025
zend_class_entry *ce = NULL;
10311026
zend_function *mptr;
10321027
zend_string *key;
1033-
ulong num_index;
10341028

10351029
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &klass) == FAILURE) {
10361030
return;
@@ -1052,7 +1046,7 @@ ZEND_FUNCTION(get_class_methods)
10521046

10531047
array_init(return_value);
10541048

1055-
ZEND_HASH_FOREACH_KEY_PTR(&ce->function_table, num_index, key, mptr) {
1049+
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, key, mptr) {
10561050

10571051
if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC)
10581052
|| (EG(scope) &&
@@ -1422,14 +1416,13 @@ ZEND_FUNCTION(crash)
14221416
ZEND_FUNCTION(get_included_files)
14231417
{
14241418
zend_string *entry;
1425-
ulong num_idx;
14261419

14271420
if (zend_parse_parameters_none() == FAILURE) {
14281421
return;
14291422
}
14301423

14311424
array_init(return_value);
1432-
ZEND_HASH_FOREACH_KEY(&EG(included_files), num_idx, entry) {
1425+
ZEND_HASH_FOREACH_STR_KEY(&EG(included_files), entry) {
14331426
if (entry) {
14341427
add_next_index_str(return_value, STR_COPY(entry));
14351428
}

Diff for: Zend/zend_constants.c

+7-11
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,20 @@ ZEND_API int zend_get_constant_ex(const char *name, uint name_len, zval *result,
309309
const char *colon;
310310
zend_class_entry *ce = NULL;
311311
zend_string *class_name;
312-
zval *ret_constant;
313312

314313
/* Skip leading \\ */
315314
if (name[0] == '\\') {
316315
name += 1;
317316
name_len -= 1;
318317
}
319318

320-
321319
if ((colon = zend_memrchr(name, ':', name_len)) &&
322320
colon > name && (*(colon - 1) == ':')) {
323321
int class_name_len = colon - name - 1;
324322
int const_name_len = name_len - class_name_len - 2;
325323
zend_string *constant_name = STR_INIT(colon + 1, const_name_len, 0);
326324
zend_string *lcname;
325+
zval *ret_constant = NULL;
327326

328327
class_name = STR_INIT(name, class_name_len, 0);
329328
lcname = STR_ALLOC(class_name_len, 0);
@@ -381,7 +380,11 @@ ZEND_API int zend_get_constant_ex(const char *name, uint name_len, zval *result,
381380
}
382381
STR_FREE(class_name);
383382
STR_FREE(constant_name);
384-
goto finish;
383+
if (retval) {
384+
zval_update_constant_ex(ret_constant, (void*)1, ce TSRMLS_CC);
385+
ZVAL_DUP(result, ret_constant);
386+
}
387+
return retval;
385388
}
386389

387390
/* non-class constant */
@@ -425,14 +428,7 @@ ZEND_API int zend_get_constant_ex(const char *name, uint name_len, zval *result,
425428
name_len = const_name_len;
426429
return zend_get_constant(name, name_len, result TSRMLS_CC);
427430
}
428-
retval = 0;
429-
finish:
430-
if (retval) {
431-
zval_update_constant_ex(ret_constant, (void*)1, ce TSRMLS_CC);
432-
ZVAL_DUP(result, ret_constant);
433-
}
434-
435-
return retval;
431+
return 0;
436432
}
437433

438434
return zend_get_constant(name, name_len, result TSRMLS_CC);

Diff for: Zend/zend_execute.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const zend_
382382
return NULL;
383383
break;
384384
case IS_CV:
385+
default:
385386
should_free->var = NULL;
386387
return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC);
387388
break;
388-
EMPTY_SWITCH_DEFAULT_CASE()
389389
}
390390
return NULL;
391391
}
@@ -412,10 +412,10 @@ static inline zval *_get_zval_ptr_deref(int op_type, const znode_op *node, const
412412
return NULL;
413413
break;
414414
case IS_CV:
415+
default:
415416
should_free->var = NULL;
416417
return _get_zval_ptr_cv_deref(execute_data, node->var, type TSRMLS_CC);
417418
break;
418-
EMPTY_SWITCH_DEFAULT_CASE()
419419
}
420420
return NULL;
421421
}
@@ -438,8 +438,6 @@ static zend_always_inline zval *_get_zval_ptr_ptr_var(zend_uint var, const zend_
438438

439439
static inline zval *_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
440440
{
441-
zval *ret;
442-
443441
if (op_type == IS_CV) {
444442
should_free->var = NULL;
445443
return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC);

Diff for: Zend/zend_hash.h

+19
Original file line numberDiff line numberDiff line change
@@ -569,23 +569,42 @@ static inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, HashPositio
569569
ZEND_HASH_FOREACH(ht, 0); \
570570
_ptr = Z_PTR_P(_z);
571571

572+
#define ZEND_HASH_FOREACH_STR_KEY(ht, _key) \
573+
ZEND_HASH_FOREACH(ht, 0); \
574+
_key = _p->key;
575+
572576
#define ZEND_HASH_FOREACH_KEY(ht, _h, _key) \
573577
ZEND_HASH_FOREACH(ht, 0); \
574578
_h = _p->h; \
575579
_key = _p->key;
576580

581+
#define ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val) \
582+
ZEND_HASH_FOREACH(ht, 0); \
583+
_key = _p->key; \
584+
_val = _z;
585+
577586
#define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val) \
578587
ZEND_HASH_FOREACH(ht, 0); \
579588
_h = _p->h; \
580589
_key = _p->key; \
581590
_val = _z;
582591

592+
#define ZEND_HASH_FOREACH_STR_KEY_VAL_IND(ht, _key, _val) \
593+
ZEND_HASH_FOREACH(ht, 1); \
594+
_key = _p->key; \
595+
_val = _z;
596+
583597
#define ZEND_HASH_FOREACH_KEY_VAL_IND(ht, _h, _key, _val) \
584598
ZEND_HASH_FOREACH(ht, 1); \
585599
_h = _p->h; \
586600
_key = _p->key; \
587601
_val = _z;
588602

603+
#define ZEND_HASH_FOREACH_STR_KEY_PTR(ht, _key, _ptr) \
604+
ZEND_HASH_FOREACH(ht, 0); \
605+
_key = _p->key; \
606+
_ptr = Z_PTR_P(_z);
607+
589608
#define ZEND_HASH_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \
590609
ZEND_HASH_FOREACH(ht, 0); \
591610
_h = _p->h; \

Diff for: Zend/zend_list.c

-2
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,6 @@ static void list_destructors_dtor(zval *zv)
329329

330330
int zend_init_rsrc_list_dtors(void)
331331
{
332-
int retval;
333-
334332
zend_hash_init(&list_destructors, 64, NULL, list_destructors_dtor, 1);
335333
list_destructors.nNextFreeElement=1; /* we don't want resource type 0 */
336334
return SUCCESS;

Diff for: Zend/zend_objects_API.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,12 @@ ZEND_API void zend_object_proxy_set(zval *property, zval *value TSRMLS_DC)
276276
}
277277
}
278278

279-
ZEND_API zval* zend_object_proxy_get(zval *property TSRMLS_DC)
279+
ZEND_API zval* zend_object_proxy_get(zval *property, zval *rv TSRMLS_DC)
280280
{
281281
zend_proxy_object *probj = (zend_proxy_object*)Z_OBJ_P(property);
282282

283283
if (Z_OBJ_HT(probj->object) && Z_OBJ_HT(probj->object)->read_property) {
284-
return Z_OBJ_HT(probj->object)->read_property(&probj->object, &probj->property, BP_VAR_R, -1, NULL TSRMLS_CC);
284+
return Z_OBJ_HT(probj->object)->read_property(&probj->object, &probj->property, BP_VAR_R, -1, rv TSRMLS_CC);
285285
} else {
286286
zend_error(E_WARNING, "Cannot read property of object - no read handler defined");
287287
}

Diff for: Zend/zend_operators.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {
18071807
}
18081808
/* }}} */
18091809

1810-
static int hash_zval_identical_function(const zval *z1, const zval *z2) /* {{{ */
1810+
static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */
18111811
{
18121812
zval result;
18131813
TSRMLS_FETCH();
@@ -2406,7 +2406,7 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */
24062406
}
24072407
/* }}} */
24082408

2409-
static int hash_zval_compare_function(const zval *z1, const zval *z2 TSRMLS_DC) /* {{{ */
2409+
static int hash_zval_compare_function(zval *z1, zval *z2 TSRMLS_DC) /* {{{ */
24102410
{
24112411
zval result;
24122412

Diff for: Zend/zend_vm_def.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ ZEND_VM_HANDLER(97, ZEND_FETCH_OBJ_UNSET, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
15401540
{
15411541
USE_OPLINE
15421542
zend_free_op free_op1, free_op2;
1543-
zval *container, *property, *retval_ptr;
1543+
zval *container, *property;
15441544

15451545
SAVE_OPLINE();
15461546
container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
@@ -3128,11 +3128,10 @@ ZEND_VM_C_LABEL(send_again):
31283128
HashTable *ht = Z_ARRVAL_P(args);
31293129
zval *arg;
31303130
zend_string *name;
3131-
zend_ulong index;
31323131

31333132
ZEND_VM_STACK_GROW_IF_NEEDED(zend_hash_num_elements(ht));
31343133

3135-
ZEND_HASH_FOREACH_KEY_VAL(ht, index, name, arg) {
3134+
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) {
31363135
if (name) {
31373136
zend_error(E_RECOVERABLE_ERROR, "Cannot unpack array with string keys");
31383137
FREE_OP1();

0 commit comments

Comments
 (0)