Skip to content

Commit fb6129f

Browse files
committed
ext/opcache: add const qualifiers
1 parent 8caf05f commit fb6129f

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_
10531053
!EG(current_execute_data) &&
10541054
file_handle->primary_script) {
10551055

1056-
zend_stat_t *tmpbuf = sapi_module.get_stat();
1056+
const zend_stat_t *tmpbuf = sapi_module.get_stat();
10571057

10581058
if (tmpbuf) {
10591059
if (size) {
@@ -1134,7 +1134,7 @@ accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_
11341134
return statbuf.st_mtime;
11351135
}
11361136

1137-
static inline zend_result do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
1137+
static inline zend_result do_validate_timestamps(const zend_persistent_script *persistent_script, zend_file_handle *file_handle)
11381138
{
11391139
zend_file_handle ps_handle;
11401140
zend_string *full_path_ptr = NULL;
@@ -1239,7 +1239,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
12391239
} else {
12401240
const char *include_path = NULL, *cwd = NULL;
12411241
int include_path_len = 0, cwd_len = 0;
1242-
zend_string *parent_script = NULL;
1242+
const zend_string *parent_script = NULL;
12431243

12441244
if (EXPECTED(ZCG(cwd_key_len))) {
12451245
cwd = ZCG(cwd_key);
@@ -1274,7 +1274,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
12741274
}
12751275
if (str) {
12761276
char buf[32];
1277-
char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, STRTAB_STR_TO_POS(&ZCSG(interned_strings), str));
1277+
const char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, STRTAB_STR_TO_POS(&ZCSG(interned_strings), str));
12781278

12791279
cwd_len = ZCG(cwd_key_len) = buf + sizeof(buf) - 1 - res;
12801280
cwd = ZCG(cwd_key);
@@ -1318,7 +1318,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
13181318
}
13191319
if (str) {
13201320
char buf[32];
1321-
char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, STRTAB_STR_TO_POS(&ZCSG(interned_strings), str));
1321+
const char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, STRTAB_STR_TO_POS(&ZCSG(interned_strings), str));
13221322

13231323
include_path_len = ZCG(include_path_key_len) = buf + sizeof(buf) - 1 - res;
13241324
include_path = ZCG(include_path_key);
@@ -1517,7 +1517,7 @@ static void zend_accel_add_key(zend_string *key, zend_accel_hash_entry *bucket)
15171517
}
15181518
}
15191519

1520-
static zend_always_inline bool is_phar_file(zend_string *filename)
1520+
static zend_always_inline bool is_phar_file(const zend_string *filename)
15211521
{
15221522
return filename && ZSTR_LEN(filename) >= sizeof(".phar") &&
15231523
!memcmp(ZSTR_VAL(filename) + ZSTR_LEN(filename) - (sizeof(".phar")-1), ".phar", sizeof(".phar")-1) &&
@@ -1987,7 +1987,7 @@ static zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int
19871987
return op_array;
19881988
}
19891989

1990-
static bool check_persistent_script_access(zend_persistent_script *persistent_script)
1990+
static bool check_persistent_script_access(const zend_persistent_script *persistent_script)
19911991
{
19921992
char *phar_path, *ptr;
19931993
if ((ZSTR_LEN(persistent_script->script.filename)<sizeof("phar://.phar")) ||
@@ -2288,7 +2288,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
22882288
return zend_accel_load_script(persistent_script, from_shared_memory);
22892289
}
22902290

2291-
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)
2291+
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)
22922292
{
22932293
uint32_t i;
22942294

@@ -2310,10 +2310,10 @@ static zend_always_inline zend_inheritance_cache_entry* zend_accel_inheritance_c
23102310
}
23112311
if (found && entry->dependencies) {
23122312
for (i = 0; i < entry->dependencies_count; i++) {
2313-
zend_class_entry *ce = zend_lookup_class_ex(entry->dependencies[i].name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
2313+
const zend_class_entry *dependency_ce = zend_lookup_class_ex(entry->dependencies[i].name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
23142314

2315-
if (ce != entry->dependencies[i].ce) {
2316-
if (!ce) {
2315+
if (dependency_ce != entry->dependencies[i].ce) {
2316+
if (!dependency_ce) {
23172317
needs_autoload = true;
23182318
} else {
23192319
found = false;
@@ -2354,9 +2354,9 @@ static zend_class_entry* zend_accel_inheritance_cache_get(zend_class_entry *ce,
23542354
}
23552355

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

2359-
if (ce == NULL) {
2359+
if (dependency_ce == NULL) {
23602360
return NULL;
23612361
}
23622362
}
@@ -2585,7 +2585,7 @@ static zend_string* persistent_zend_resolve_path(zend_string *filename)
25852585
/* lookup by "not-real" path */
25862586
key = accel_make_persistent_key(filename);
25872587
if (key) {
2588-
zend_accel_hash_entry *bucket = zend_accel_hash_find_entry(&ZCSG(hash), key);
2588+
const zend_accel_hash_entry *bucket = zend_accel_hash_find_entry(&ZCSG(hash), key);
25892589
if (bucket != NULL) {
25902590
zend_persistent_script *persistent_script = (zend_persistent_script *)bucket->data;
25912591
if (!persistent_script->corrupted) {
@@ -3642,7 +3642,7 @@ static void preload_shutdown(void)
36423642

36433643
if (EG(function_table)) {
36443644
ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(function_table), zv) {
3645-
zend_function *func = Z_PTR_P(zv);
3645+
const zend_function *func = Z_PTR_P(zv);
36463646
if (func->type == ZEND_INTERNAL_FUNCTION) {
36473647
break;
36483648
}
@@ -3651,7 +3651,7 @@ static void preload_shutdown(void)
36513651

36523652
if (EG(class_table)) {
36533653
ZEND_HASH_MAP_REVERSE_FOREACH_VAL(EG(class_table), zv) {
3654-
zend_class_entry *ce = Z_PTR_P(zv);
3654+
const zend_class_entry *ce = Z_PTR_P(zv);
36553655
if (ce->type == ZEND_INTERNAL_CLASS && Z_TYPE_P(zv) != IS_ALIAS_PTR) {
36563656
break;
36573657
}
@@ -3678,7 +3678,7 @@ static void preload_restart(void)
36783678
}
36793679
}
36803680

3681-
static size_t preload_try_strip_filename(zend_string *filename) {
3681+
static size_t preload_try_strip_filename(const zend_string *filename) {
36823682
/*FIXME: better way to handle eval()'d code? see COMPILED_STRING_DESCRIPTION_FORMAT */
36833683
if (ZSTR_LEN(filename) > sizeof(" eval()'d code")
36843684
&& *(ZSTR_VAL(filename) + ZSTR_LEN(filename) - sizeof(" eval()'d code")) == ':') {
@@ -3799,17 +3799,17 @@ static void preload_sort_classes(void *base, size_t count, size_t siz, compare_f
37993799
Bucket *b2;
38003800
Bucket *end = b1 + count;
38013801
Bucket tmp;
3802-
zend_class_entry *ce, *p;
3802+
const zend_class_entry *ce, *p;
38033803

38043804
while (b1 < end) {
38053805
try_again:
3806-
ce = (zend_class_entry*)Z_PTR(b1->val);
3806+
ce = Z_PTR(b1->val);
38073807
if (ce->parent && (ce->ce_flags & ZEND_ACC_LINKED)) {
38083808
p = ce->parent;
38093809
if (p->type == ZEND_USER_CLASS) {
38103810
b2 = b1 + 1;
38113811
while (b2 < end) {
3812-
if (p == Z_PTR(b2->val)) {
3812+
if (p == Z_PTR(b2->val)) {
38133813
tmp = *b1;
38143814
*b1 = *b2;
38153815
*b2 = tmp;
@@ -3826,7 +3826,7 @@ static void preload_sort_classes(void *base, size_t count, size_t siz, compare_f
38263826
if (p->type == ZEND_USER_CLASS) {
38273827
b2 = b1 + 1;
38283828
while (b2 < end) {
3829-
if (p == Z_PTR(b2->val)) {
3829+
if (p == Z_PTR(b2->val)) {
38303830
tmp = *b1;
38313831
*b1 = *b2;
38323832
*b2 = tmp;
@@ -3852,7 +3852,7 @@ static zend_result preload_resolve_deps(preload_error *error, const zend_class_e
38523852

38533853
if (ce->parent_name) {
38543854
zend_string *key = zend_string_tolower(ce->parent_name);
3855-
zend_class_entry *parent = zend_hash_find_ptr(EG(class_table), key);
3855+
const zend_class_entry *parent = zend_hash_find_ptr(EG(class_table), key);
38563856
zend_string_release(key);
38573857
if (!parent) {
38583858
error->kind = "Unknown parent ";
@@ -3863,7 +3863,7 @@ static zend_result preload_resolve_deps(preload_error *error, const zend_class_e
38633863

38643864
if (ce->num_interfaces) {
38653865
for (uint32_t i = 0; i < ce->num_interfaces; i++) {
3866-
zend_class_entry *interface =
3866+
const zend_class_entry *interface =
38673867
zend_hash_find_ptr(EG(class_table), ce->interface_names[i].lc_name);
38683868
if (!interface) {
38693869
error->kind = "Unknown interface ";
@@ -3875,7 +3875,7 @@ static zend_result preload_resolve_deps(preload_error *error, const zend_class_e
38753875

38763876
if (ce->num_traits) {
38773877
for (uint32_t i = 0; i < ce->num_traits; i++) {
3878-
zend_class_entry *trait =
3878+
const zend_class_entry *trait =
38793879
zend_hash_find_ptr(EG(class_table), ce->trait_names[i].lc_name);
38803880
if (!trait) {
38813881
error->kind = "Unknown trait ";
@@ -3980,7 +3980,7 @@ static void preload_error_cb(int type, zend_string *error_filename, const uint32
39803980
static void preload_remove_declares(zend_op_array *op_array)
39813981
{
39823982
zend_op *opline = op_array->opcodes;
3983-
zend_op *end = opline + op_array->last;
3983+
const zend_op *end = opline + op_array->last;
39843984
uint32_t skip_dynamic_func_count = 0;
39853985
zend_string *key;
39863986
zend_op_array *func;
@@ -4271,7 +4271,7 @@ static void preload_remove_empty_includes(void)
42714271
if (script->empty) {
42724272
bool empty = true;
42734273
zend_op *opline = script->script.main_op_array.opcodes;
4274-
zend_op *end = opline + script->script.main_op_array.last;
4274+
const zend_op *end = opline + script->script.main_op_array.last;
42754275

42764276
while (opline < end) {
42774277
if (opline->opcode == ZEND_INCLUDE_OR_EVAL &&
@@ -4312,7 +4312,7 @@ static void preload_remove_empty_includes(void)
43124312
/* remove empty includes */
43134313
ZEND_HASH_MAP_FOREACH_PTR(preload_scripts, script) {
43144314
zend_op *opline = script->script.main_op_array.opcodes;
4315-
zend_op *end = opline + script->script.main_op_array.last;
4315+
const zend_op *end = opline + script->script.main_op_array.last;
43164316

43174317
while (opline < end) {
43184318
if (opline->opcode == ZEND_INCLUDE_OR_EVAL &&
@@ -4323,7 +4323,7 @@ static void preload_remove_empty_includes(void)
43234323
zend_string *resolved_path = preload_resolve_path(Z_STR_P(RT_CONSTANT(opline, opline->op1)));
43244324

43254325
if (resolved_path) {
4326-
zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path);
4326+
const zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path);
43274327
if (incl && incl->empty && opline->result_type == IS_UNUSED) {
43284328
MAKE_NOP(opline);
43294329
} else {
@@ -4341,7 +4341,7 @@ static void preload_remove_empty_includes(void)
43414341
} ZEND_HASH_FOREACH_END();
43424342
}
43434343

4344-
static void preload_register_trait_methods(zend_class_entry *ce) {
4344+
static void preload_register_trait_methods(const zend_class_entry *ce) {
43454345
zend_op_array *op_array;
43464346

43474347
ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, op_array) {
@@ -4374,7 +4374,7 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
43744374
return;
43754375
}
43764376

4377-
zend_op_array *orig_op_array = zend_shared_alloc_get_xlat_entry(op_array->refcount);
4377+
const zend_op_array *orig_op_array = zend_shared_alloc_get_xlat_entry(op_array->refcount);
43784378
ZEND_ASSERT(orig_op_array && "Must be in xlat table");
43794379

43804380
zend_string *function_name = op_array->function_name;
@@ -4392,7 +4392,7 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
43924392
op_array->static_variables = ht;
43934393
}
43944394

4395-
static void preload_fix_trait_methods(zend_class_entry *ce)
4395+
static void preload_fix_trait_methods(const zend_class_entry *ce)
43964396
{
43974397
zend_op_array *op_array;
43984398

@@ -4417,7 +4417,7 @@ static void preload_fix_trait_methods(zend_class_entry *ce)
44174417

44184418
static void preload_optimize(zend_persistent_script *script)
44194419
{
4420-
zend_class_entry *ce;
4420+
const zend_class_entry *ce;
44214421
zend_persistent_script *tmp_script;
44224422

44234423
zend_shared_alloc_init_xlat_table();
@@ -4514,10 +4514,10 @@ static zend_persistent_script* preload_script_in_shared_memory(zend_persistent_s
45144514
static void preload_load(size_t orig_map_ptr_static_last)
45154515
{
45164516
/* Load into process tables */
4517-
zend_script *script = &ZCSG(preload_script)->script;
4517+
const zend_script *script = &ZCSG(preload_script)->script;
45184518
if (zend_hash_num_elements(&script->function_table)) {
45194519
Bucket *p = script->function_table.arData;
4520-
Bucket *end = p + script->function_table.nNumUsed;
4520+
const Bucket *end = p + script->function_table.nNumUsed;
45214521

45224522
zend_hash_extend(CG(function_table),
45234523
CG(function_table)->nNumUsed + script->function_table.nNumUsed, 0);
@@ -4528,7 +4528,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
45284528

45294529
if (zend_hash_num_elements(&script->class_table)) {
45304530
Bucket *p = script->class_table.arData;
4531-
Bucket *end = p + script->class_table.nNumUsed;
4531+
const Bucket *end = p + script->class_table.nNumUsed;
45324532

45334533
zend_hash_extend(CG(class_table),
45344534
CG(class_table)->nNumUsed + script->class_table.nNumUsed, 0);
@@ -4576,7 +4576,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
45764576
}
45774577

45784578
#if HAVE_JIT
4579-
static void zend_accel_clear_call_graph_ptrs(zend_op_array *op_array)
4579+
static void zend_accel_clear_call_graph_ptrs(const zend_op_array *op_array)
45804580
{
45814581
ZEND_ASSERT(ZEND_USER_CODE(op_array->type));
45824582
zend_func_info *info = ZEND_FUNC_INFO(op_array);
@@ -4586,9 +4586,9 @@ static void zend_accel_clear_call_graph_ptrs(zend_op_array *op_array)
45864586
}
45874587
}
45884588

4589-
static void accel_reset_arena_info(zend_persistent_script *script)
4589+
static void accel_reset_arena_info(const zend_persistent_script *script)
45904590
{
4591-
zend_op_array *op_array;
4591+
const zend_op_array *op_array;
45924592
zend_class_entry *ce;
45934593

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

0 commit comments

Comments
 (0)