Skip to content

Commit 964b903

Browse files
committed
ext/opcache: add const qualifiers
1 parent e75f6de commit 964b903

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_
11351135
return statbuf.st_mtime;
11361136
}
11371137

1138-
static inline zend_result do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
1138+
static inline zend_result do_validate_timestamps(const zend_persistent_script *persistent_script, zend_file_handle *file_handle)
11391139
{
11401140
zend_file_handle ps_handle;
11411141
zend_string *full_path_ptr = NULL;
@@ -1521,7 +1521,7 @@ static void zend_accel_add_key(zend_string *key, zend_accel_hash_entry *bucket)
15211521
}
15221522
}
15231523

1524-
static zend_always_inline bool is_phar_file(zend_string *filename)
1524+
static zend_always_inline bool is_phar_file(const zend_string *filename)
15251525
{
15261526
return filename && ZSTR_LEN(filename) >= sizeof(".phar") &&
15271527
!memcmp(ZSTR_VAL(filename) + ZSTR_LEN(filename) - (sizeof(".phar")-1), ".phar", sizeof(".phar")-1) &&
@@ -1991,7 +1991,7 @@ static zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int
19911991
return op_array;
19921992
}
19931993

1994-
static bool check_persistent_script_access(zend_persistent_script *persistent_script)
1994+
static bool check_persistent_script_access(const zend_persistent_script *persistent_script)
19951995
{
19961996
char *phar_path, *ptr;
19971997
if ((ZSTR_LEN(persistent_script->script.filename)<sizeof("phar://.phar")) ||
@@ -2292,7 +2292,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
22922292
return zend_accel_load_script(persistent_script, from_shared_memory);
22932293
}
22942294

2295-
static zend_always_inline zend_inheritance_cache_entry* zend_accel_inheritance_cache_find(zend_inheritance_cache_entry *entry, zend_class_entry *ce, zend_class_entry *parent, zend_class_entry **traits_and_interfaces, bool *needs_autoload_ptr)
2295+
static zend_always_inline zend_inheritance_cache_entry* zend_accel_inheritance_cache_find(zend_inheritance_cache_entry *entry, const zend_class_entry *ce, const zend_class_entry *parent, zend_class_entry **traits_and_interfaces, bool *needs_autoload_ptr)
22962296
{
22972297
uint32_t i;
22982298

@@ -2314,10 +2314,10 @@ static zend_always_inline zend_inheritance_cache_entry* zend_accel_inheritance_c
23142314
}
23152315
if (found && entry->dependencies) {
23162316
for (i = 0; i < entry->dependencies_count; i++) {
2317-
zend_class_entry *ce = zend_lookup_class_ex(entry->dependencies[i].name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
2317+
const zend_class_entry *dependent_ce = zend_lookup_class_ex(entry->dependencies[i].name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
23182318

2319-
if (ce != entry->dependencies[i].ce) {
2320-
if (!ce) {
2319+
if (dependent_ce != entry->dependencies[i].ce) {
2320+
if (!dependent_ce) {
23212321
needs_autoload = true;
23222322
} else {
23232323
found = false;
@@ -2358,9 +2358,9 @@ static zend_class_entry* zend_accel_inheritance_cache_get(zend_class_entry *ce,
23582358
}
23592359

23602360
for (uint32_t i = 0; i < entry->dependencies_count; i++) {
2361-
zend_class_entry *ce = zend_lookup_class_ex(entry->dependencies[i].name, NULL, 0);
2361+
const zend_class_entry *dependency_ce = zend_lookup_class_ex(entry->dependencies[i].name, NULL, 0);
23622362

2363-
if (ce == NULL) {
2363+
if (dependency_ce == NULL) {
23642364
return NULL;
23652365
}
23662366
}
@@ -3646,7 +3646,7 @@ static void preload_shutdown(void)
36463646

36473647
if (EG(function_table)) {
36483648
ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(function_table), zv) {
3649-
zend_function *func = Z_PTR_P(zv);
3649+
const zend_function *func = Z_PTR_P(zv);
36503650
if (func->type == ZEND_INTERNAL_FUNCTION) {
36513651
break;
36523652
}
@@ -3655,7 +3655,7 @@ static void preload_shutdown(void)
36553655

36563656
if (EG(class_table)) {
36573657
ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(class_table), zv) {
3658-
zend_class_entry *ce = Z_PTR_P(zv);
3658+
const zend_class_entry *ce = Z_PTR_P(zv);
36593659
if (ce->type == ZEND_INTERNAL_CLASS && Z_TYPE_P(zv) != IS_ALIAS_PTR) {
36603660
break;
36613661
}
@@ -3682,7 +3682,7 @@ static void preload_restart(void)
36823682
}
36833683
}
36843684

3685-
static size_t preload_try_strip_filename(zend_string *filename) {
3685+
static size_t preload_try_strip_filename(const zend_string *filename) {
36863686
/*FIXME: better way to handle eval()'d code? see COMPILED_STRING_DESCRIPTION_FORMAT */
36873687
if (ZSTR_LEN(filename) > sizeof(" eval()'d code")
36883688
&& *(ZSTR_VAL(filename) + ZSTR_LEN(filename) - sizeof(" eval()'d code")) == ':') {
@@ -3803,17 +3803,17 @@ static void preload_sort_classes(void *base, size_t count, size_t siz, compare_f
38033803
Bucket *b2;
38043804
Bucket *end = b1 + count;
38053805
Bucket tmp;
3806-
zend_class_entry *ce, *p;
3806+
const zend_class_entry *ce, *p;
38073807

38083808
while (b1 < end) {
38093809
try_again:
3810-
ce = (zend_class_entry*)Z_PTR(b1->val);
3810+
ce = Z_PTR(b1->val);
38113811
if (ce->parent && (ce->ce_flags & ZEND_ACC_LINKED)) {
38123812
p = ce->parent;
38133813
if (p->type == ZEND_USER_CLASS) {
38143814
b2 = b1 + 1;
38153815
while (b2 < end) {
3816-
if (p == Z_PTR(b2->val)) {
3816+
if (p == Z_PTR(b2->val)) {
38173817
tmp = *b1;
38183818
*b1 = *b2;
38193819
*b2 = tmp;
@@ -3830,7 +3830,7 @@ static void preload_sort_classes(void *base, size_t count, size_t siz, compare_f
38303830
if (p->type == ZEND_USER_CLASS) {
38313831
b2 = b1 + 1;
38323832
while (b2 < end) {
3833-
if (p == Z_PTR(b2->val)) {
3833+
if (p == Z_PTR(b2->val)) {
38343834
tmp = *b1;
38353835
*b1 = *b2;
38363836
*b2 = tmp;
@@ -3856,7 +3856,7 @@ static zend_result preload_resolve_deps(preload_error *error, const zend_class_e
38563856

38573857
if (ce->parent_name) {
38583858
zend_string *key = zend_string_tolower(ce->parent_name);
3859-
zend_class_entry *parent = zend_hash_find_ptr(EG(class_table), key);
3859+
const zend_class_entry *parent = zend_hash_find_ptr(EG(class_table), key);
38603860
zend_string_release(key);
38613861
if (!parent) {
38623862
error->kind = "Unknown parent ";
@@ -3867,7 +3867,7 @@ static zend_result preload_resolve_deps(preload_error *error, const zend_class_e
38673867

38683868
if (ce->num_interfaces) {
38693869
for (uint32_t i = 0; i < ce->num_interfaces; i++) {
3870-
zend_class_entry *interface =
3870+
const zend_class_entry *interface =
38713871
zend_hash_find_ptr(EG(class_table), ce->interface_names[i].lc_name);
38723872
if (!interface) {
38733873
error->kind = "Unknown interface ";
@@ -3879,7 +3879,7 @@ static zend_result preload_resolve_deps(preload_error *error, const zend_class_e
38793879

38803880
if (ce->num_traits) {
38813881
for (uint32_t i = 0; i < ce->num_traits; i++) {
3882-
zend_class_entry *trait =
3882+
const zend_class_entry *trait =
38833883
zend_hash_find_ptr(EG(class_table), ce->trait_names[i].lc_name);
38843884
if (!trait) {
38853885
error->kind = "Unknown trait ";
@@ -3984,7 +3984,7 @@ static void preload_error_cb(int type, zend_string *error_filename, const uint32
39843984
static void preload_remove_declares(zend_op_array *op_array)
39853985
{
39863986
zend_op *opline = op_array->opcodes;
3987-
zend_op *end = opline + op_array->last;
3987+
const zend_op *end = opline + op_array->last;
39883988
uint32_t skip_dynamic_func_count = 0;
39893989
zend_string *key;
39903990
zend_op_array *func;
@@ -4316,7 +4316,7 @@ static void preload_remove_empty_includes(void)
43164316
/* remove empty includes */
43174317
ZEND_HASH_MAP_FOREACH_PTR(preload_scripts, script) {
43184318
zend_op *opline = script->script.main_op_array.opcodes;
4319-
zend_op *end = opline + script->script.main_op_array.last;
4319+
const zend_op *end = opline + script->script.main_op_array.last;
43204320

43214321
while (opline < end) {
43224322
if (opline->opcode == ZEND_INCLUDE_OR_EVAL &&
@@ -4345,7 +4345,7 @@ static void preload_remove_empty_includes(void)
43454345
} ZEND_HASH_FOREACH_END();
43464346
}
43474347

4348-
static void preload_register_trait_methods(zend_class_entry *ce) {
4348+
static void preload_register_trait_methods(const zend_class_entry *ce) {
43494349
zend_op_array *op_array;
43504350
zend_property_info *info;
43514351

@@ -4379,7 +4379,7 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
43794379
return;
43804380
}
43814381

4382-
zend_op_array *orig_op_array = zend_shared_alloc_get_xlat_entry(op_array->refcount);
4382+
const zend_op_array *orig_op_array = zend_shared_alloc_get_xlat_entry(op_array->refcount);
43834383
ZEND_ASSERT(orig_op_array && "Must be in xlat table");
43844384

43854385
zend_string *function_name = op_array->function_name;
@@ -4397,7 +4397,7 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
43974397
op_array->static_variables = ht;
43984398
}
43994399

4400-
static void preload_fix_trait_methods(zend_class_entry *ce)
4400+
static void preload_fix_trait_methods(const zend_class_entry *ce)
44014401
{
44024402
zend_op_array *op_array;
44034403

@@ -4422,7 +4422,7 @@ static void preload_fix_trait_methods(zend_class_entry *ce)
44224422

44234423
static void preload_optimize(zend_persistent_script *script)
44244424
{
4425-
zend_class_entry *ce;
4425+
const zend_class_entry *ce;
44264426
zend_persistent_script *tmp_script;
44274427

44284428
zend_shared_alloc_init_xlat_table();
@@ -4533,7 +4533,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
45334533

45344534
if (zend_hash_num_elements(&script->class_table)) {
45354535
Bucket *p = script->class_table.arData;
4536-
Bucket *end = p + script->class_table.nNumUsed;
4536+
const Bucket *end = p + script->class_table.nNumUsed;
45374537

45384538
zend_hash_extend(CG(class_table),
45394539
CG(class_table)->nNumUsed + script->class_table.nNumUsed, 0);
@@ -4581,7 +4581,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
45814581
}
45824582

45834583
#if HAVE_JIT
4584-
static void zend_accel_clear_call_graph_ptrs(zend_op_array *op_array)
4584+
static void zend_accel_clear_call_graph_ptrs(const zend_op_array *op_array)
45854585
{
45864586
ZEND_ASSERT(ZEND_USER_CODE(op_array->type));
45874587
zend_func_info *info = ZEND_FUNC_INFO(op_array);
@@ -4591,9 +4591,9 @@ static void zend_accel_clear_call_graph_ptrs(zend_op_array *op_array)
45914591
}
45924592
}
45934593

4594-
static void accel_reset_arena_info(zend_persistent_script *script)
4594+
static void accel_reset_arena_info(const zend_persistent_script *script)
45954595
{
4596-
zend_op_array *op_array;
4596+
const zend_op_array *op_array;
45974597
zend_class_entry *ce;
45984598

45994599
zend_accel_clear_call_graph_ptrs(&script->script.main_op_array);

0 commit comments

Comments
 (0)