Skip to content

Commit 47060d8

Browse files
committed
fix issue
1 parent 1e9edba commit 47060d8

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

Zend/zend_API.c

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,28 +2907,28 @@ static HashTable *interned_type_tree = NULL;
29072907
list[count++] = value; \
29082908
} while (0)
29092909

2910-
static int compare_simple_types(zend_type a, zend_type b) {
2911-
uint32_t a_mask = ZEND_TYPE_FULL_MASK(a);
2912-
uint32_t b_mask = ZEND_TYPE_FULL_MASK(b);
2910+
static int compare_simple_types(const zend_type a, const zend_type b) {
2911+
const uint32_t a_mask = ZEND_TYPE_FULL_MASK(a);
2912+
const uint32_t b_mask = ZEND_TYPE_FULL_MASK(b);
29132913

29142914
if (a_mask != b_mask) {
29152915
return a_mask < b_mask ? -1 : 1;
29162916
}
29172917

2918-
bool a_has_name = ZEND_TYPE_HAS_NAME(a);
2919-
bool b_has_name = ZEND_TYPE_HAS_NAME(b);
2918+
const bool a_has_name = ZEND_TYPE_HAS_NAME(a);
2919+
const bool b_has_name = ZEND_TYPE_HAS_NAME(b);
29202920

29212921
if (a_has_name && b_has_name) {
2922-
zend_string *a_name = ZEND_TYPE_NAME(a);
2923-
zend_string *b_name = ZEND_TYPE_NAME(b);
2924-
int cmp = ZSTR_VAL(a_name) == ZSTR_VAL(b_name);
2922+
const zend_string *a_name = ZEND_TYPE_NAME(a);
2923+
const zend_string *b_name = ZEND_TYPE_NAME(b);
2924+
const int cmp = ZSTR_VAL(a_name) == ZSTR_VAL(b_name);
29252925
if (cmp != 0) {
29262926
return cmp;
29272927
}
29282928
}
29292929

2930-
bool a_nullable = ZEND_TYPE_ALLOW_NULL(a);
2931-
bool b_nullable = ZEND_TYPE_ALLOW_NULL(b);
2930+
const bool a_nullable = ZEND_TYPE_ALLOW_NULL(a);
2931+
const bool b_nullable = ZEND_TYPE_ALLOW_NULL(b);
29322932

29332933
if (a_nullable != b_nullable) {
29342934
return a_nullable ? 1 : -1;
@@ -2939,11 +2939,11 @@ static int compare_simple_types(zend_type a, zend_type b) {
29392939
}
29402940

29412941
static int compare_type_nodes(const void *a_, const void *b_) {
2942-
zend_type_node *a = *(zend_type_node **)a_;
2943-
zend_type_node *b = *(zend_type_node **)b_;
2942+
const zend_type_node *a = *(zend_type_node **)a_;
2943+
const zend_type_node *b = *(zend_type_node **)b_;
29442944

29452945
if (a->kind != b->kind) {
2946-
return a->kind - b->kind;
2946+
return (int)a->kind - (int)b->kind;
29472947
}
29482948

29492949
if (a->kind == ZEND_TYPE_SIMPLE) {
@@ -2964,15 +2964,15 @@ static int compare_type_nodes(const void *a_, const void *b_) {
29642964
return 0;
29652965
}
29662966

2967-
zend_ulong zend_type_node_hash(zend_type_node *node) {
2967+
zend_ulong zend_type_node_hash(const zend_type_node *node) {
29682968
zend_ulong hash = 2166136261u; // FNV-1a offset basis
29692969

29702970
hash ^= (zend_ulong)node->kind;
29712971
hash *= 16777619;
29722972

29732973
switch (node->kind) {
29742974
case ZEND_TYPE_SIMPLE: {
2975-
zend_type type = node->simple_type;
2975+
const zend_type type = node->simple_type;
29762976
hash ^= (zend_ulong)ZEND_TYPE_FULL_MASK(type);
29772977
hash *= 16777619;
29782978

@@ -2988,7 +2988,7 @@ zend_ulong zend_type_node_hash(zend_type_node *node) {
29882988
case ZEND_TYPE_UNION:
29892989
case ZEND_TYPE_INTERSECTION: {
29902990
for (uint32_t i = 0; i < node->compound.num_types; ++i) {
2991-
zend_ulong child_hash = zend_type_node_hash(node->compound.types[i]);
2991+
const zend_ulong child_hash = zend_type_node_hash(node->compound.types[i]);
29922992
hash ^= child_hash;
29932993
hash *= 16777619;
29942994
}
@@ -2999,27 +2999,27 @@ zend_ulong zend_type_node_hash(zend_type_node *node) {
29992999
return hash;
30003000
}
30013001

3002-
bool zend_type_node_equals(zend_type_node *a, zend_type_node *b) {
3002+
bool zend_type_node_equals(const zend_type_node *a, const zend_type_node *b) {
30033003
if (a == b) return true;
30043004
if (a->kind != b->kind) return false;
30053005

30063006
if (a->kind == ZEND_TYPE_SIMPLE) {
3007-
zend_type at = a->simple_type;
3008-
zend_type bt = b->simple_type;
3007+
const zend_type at = a->simple_type;
3008+
const zend_type bt = b->simple_type;
30093009

30103010
if (ZEND_TYPE_FULL_MASK(at) != ZEND_TYPE_FULL_MASK(bt)) {
30113011
return false;
30123012
}
30133013

3014-
bool a_has_name = ZEND_TYPE_HAS_NAME(at);
3015-
bool b_has_name = ZEND_TYPE_HAS_NAME(bt);
3014+
const bool a_has_name = ZEND_TYPE_HAS_NAME(at);
3015+
const bool b_has_name = ZEND_TYPE_HAS_NAME(bt);
30163016
if (a_has_name != b_has_name) {
30173017
return false;
30183018
}
30193019

30203020
if (a_has_name) {
3021-
zend_string *a_name = ZEND_TYPE_NAME(at);
3022-
zend_string *b_name = ZEND_TYPE_NAME(bt);
3021+
const zend_string *a_name = ZEND_TYPE_NAME(at);
3022+
const zend_string *b_name = ZEND_TYPE_NAME(bt);
30233023
if (!zend_string_equals(a_name, b_name)) {
30243024
return false;
30253025
}
@@ -3042,9 +3042,8 @@ bool zend_type_node_equals(zend_type_node *a, zend_type_node *b) {
30423042
return true;
30433043
}
30443044

3045-
30463045
static zend_type_node *intern_type_node(zend_type_node *node) {
3047-
zend_ulong hash = zend_type_node_hash(node);
3046+
const zend_ulong hash = zend_type_node_hash(node);
30483047
zend_type_node *existing;
30493048

30503049
if (interned_type_tree == NULL) {
@@ -3054,6 +3053,7 @@ static zend_type_node *intern_type_node(zend_type_node *node) {
30543053

30553054
if ((existing = zend_hash_index_find_ptr(interned_type_tree, hash))) {
30563055
if (zend_type_node_equals(existing, node)) {
3056+
pefree(node, 1);
30573057
return existing; // reuse interned node
30583058
}
30593059
}
@@ -3062,8 +3062,7 @@ static zend_type_node *intern_type_node(zend_type_node *node) {
30623062
return node;
30633063
}
30643064

3065-
3066-
ZEND_API zend_type_node *zend_type_to_interned_tree(zend_type type) {
3065+
ZEND_API zend_type_node *zend_type_to_interned_tree(const zend_type type) {
30673066
if (type.type_mask == 0) {
30683067
return NULL;
30693068
}
@@ -3076,7 +3075,7 @@ ZEND_API zend_type_node *zend_type_to_interned_tree(zend_type type) {
30763075
}
30773076

30783077
zend_type_list *list = ZEND_TYPE_LIST(type);
3079-
zend_type_node_kind kind = ZEND_TYPE_IS_INTERSECTION(type) ?
3078+
const zend_type_node_kind kind = ZEND_TYPE_IS_INTERSECTION(type) ?
30803079
ZEND_TYPE_INTERSECTION : ZEND_TYPE_UNION;
30813080

30823081
zend_type_node **children = NULL;

ext/zend_test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ static void register_ZendTestClass_dnf_property(zend_class_entry *ce) {
12021202
// The types are upgraded to DNF types in `register_dynamic_function_entries()`
12031203
static zend_internal_arg_info arginfo_zend_test_internal_dnf_arguments[] = {
12041204
// first entry is a zend_internal_function_info (see zend_compile.h): {argument_count, return_type, unused}
1205-
{(const char*)(uintptr_t)(1), {0}, NULL},
1205+
{(const char*)(uintptr_t)(1), {0}, NULL, NULL},
12061206
{"arg", {0}, NULL}
12071207
};
12081208

0 commit comments

Comments
 (0)