Skip to content

Commit 8caf05f

Browse files
committed
ext/opcache: reduce scope of variable
1 parent 8cf699a commit 8caf05f

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,12 @@ static zend_string* ZEND_FASTCALL accel_new_interned_string_for_php(zend_string
591591
static zend_always_inline zend_string *accel_find_interned_string_ex(zend_ulong h, const char *str, size_t size)
592592
{
593593
zend_string_table_pos_t pos;
594-
zend_string *s;
595594

596595
/* check for existing interned string */
597596
pos = *STRTAB_HASH_TO_SLOT(&ZCSG(interned_strings), h);
598597
if (EXPECTED(pos != STRTAB_INVALID_POS)) {
599598
do {
600-
s = STRTAB_POS_TO_STR(&ZCSG(interned_strings), pos);
599+
zend_string *s = STRTAB_POS_TO_STR(&ZCSG(interned_strings), pos);
601600
if (EXPECTED(ZSTR_H(s) == h) && zend_string_equals_cstr(s, str, size)) {
602601
return s;
603602
}
@@ -720,14 +719,13 @@ static void accel_copy_permanent_strings(zend_new_interned_string_func_t new_int
720719
Z_FUNC(q->val)->common.function_name = new_interned_string(Z_FUNC(q->val)->common.function_name);
721720
}
722721
if (Z_FUNC(q->val)->common.scope == ce) {
723-
uint32_t i;
724722
uint32_t num_args = Z_FUNC(q->val)->common.num_args + 1;
725723
zend_arg_info *arg_info = Z_FUNC(q->val)->common.arg_info - 1;
726724

727725
if (Z_FUNC(q->val)->common.fn_flags & ZEND_ACC_VARIADIC) {
728726
num_args++;
729727
}
730-
for (i = 0 ; i < num_args; i++) {
728+
for (uint32_t i = 0 ; i < num_args; i++) {
731729
if (i > 0) {
732730
arg_info[i].name = new_interned_string(arg_info[i].name);
733731
if (arg_info[i].default_value) {
@@ -860,15 +858,14 @@ static void accel_use_shm_interned_strings(void)
860858
#ifndef ZEND_WIN32
861859
static inline void kill_all_lockers(struct flock *mem_usage_check)
862860
{
863-
int tries;
864861
/* so that other process won't try to force while we are busy cleaning up */
865862
ZCSG(force_restart_time) = 0;
866863
while (mem_usage_check->l_pid > 0) {
867864
/* Try SIGTERM first, switch to SIGKILL if not successful. */
868865
int signal = SIGTERM;
869866
errno = 0;
870867
bool success = false;
871-
tries = 10;
868+
int tries = 10;
872869

873870
while (tries--) {
874871
zend_accel_error(ACCEL_LOG_WARNING, "Attempting to kill locker %d", mem_usage_check->l_pid);
@@ -1225,8 +1222,6 @@ zend_string *accel_make_persistent_key(zend_string *str)
12251222
{
12261223
const char *path = ZSTR_VAL(str);
12271224
size_t path_length = ZSTR_LEN(str);
1228-
char *key;
1229-
int key_length;
12301225

12311226
ZEND_ASSERT(GC_REFCOUNT(ZCG(key)) == 1);
12321227
ZSTR_LEN(ZCG(key)) = 0;
@@ -1245,7 +1240,6 @@ zend_string *accel_make_persistent_key(zend_string *str)
12451240
const char *include_path = NULL, *cwd = NULL;
12461241
int include_path_len = 0, cwd_len = 0;
12471242
zend_string *parent_script = NULL;
1248-
size_t parent_script_len = 0;
12491243

12501244
if (EXPECTED(ZCG(cwd_key_len))) {
12511245
cwd = ZCG(cwd_key);
@@ -1348,10 +1342,10 @@ zend_string *accel_make_persistent_key(zend_string *str)
13481342
* since in itself, it may include colons (which we use to separate
13491343
* different components of the key)
13501344
*/
1351-
key = ZSTR_VAL(ZCG(key));
1345+
char *key = ZSTR_VAL(ZCG(key));
13521346
memcpy(key, path, path_length);
13531347
key[path_length] = ':';
1354-
key_length = path_length + 1;
1348+
int key_length = path_length + 1;
13551349
memcpy(key + key_length, cwd, cwd_len);
13561350
key_length += cwd_len;
13571351

@@ -1369,7 +1363,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
13691363
if (EXPECTED(EG(current_execute_data)) &&
13701364
EXPECTED((parent_script = zend_get_executed_filename_ex()) != NULL)) {
13711365

1372-
parent_script_len = ZSTR_LEN(parent_script);
1366+
size_t parent_script_len = ZSTR_LEN(parent_script);
13731367
while (parent_script_len > 0) {
13741368
--parent_script_len;
13751369
if (IS_SLASH(ZSTR_VAL(parent_script)[parent_script_len])) {
@@ -2341,7 +2335,6 @@ static zend_always_inline zend_inheritance_cache_entry* zend_accel_inheritance_c
23412335

23422336
static zend_class_entry* zend_accel_inheritance_cache_get(zend_class_entry *ce, zend_class_entry *parent, zend_class_entry **traits_and_interfaces)
23432337
{
2344-
uint32_t i;
23452338
bool needs_autoload;
23462339
zend_inheritance_cache_entry *entry = ce->inheritance_cache;
23472340

@@ -2360,7 +2353,7 @@ static zend_class_entry* zend_accel_inheritance_cache_get(zend_class_entry *ce,
23602353
return ce;
23612354
}
23622355

2363-
for (i = 0; i < entry->dependencies_count; i++) {
2356+
for (uint32_t i = 0; i < entry->dependencies_count; i++) {
23642357
zend_class_entry *ce = zend_lookup_class_ex(entry->dependencies[i].name, NULL, 0);
23652358

23662359
if (ce == NULL) {
@@ -3925,10 +3918,9 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
39253918
ce->ce_flags &= ~ZEND_ACC_HAS_AST_CONSTANTS;
39263919
}
39273920
if (ce->default_properties_count) {
3928-
uint32_t i;
39293921
bool resolved = true;
39303922

3931-
for (i = 0; i < ce->default_properties_count; i++) {
3923+
for (uint32_t i = 0; i < ce->default_properties_count; i++) {
39323924
zend_property_info *prop = ce->properties_info_table[i];
39333925
if (!prop) {
39343926
continue;
@@ -4351,7 +4343,6 @@ static void preload_remove_empty_includes(void)
43514343

43524344
static void preload_register_trait_methods(zend_class_entry *ce) {
43534345
zend_op_array *op_array;
4354-
zend_property_info *info;
43554346

43564347
ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, op_array) {
43574348
if (!(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
@@ -4361,7 +4352,7 @@ static void preload_register_trait_methods(zend_class_entry *ce) {
43614352
} ZEND_HASH_FOREACH_END();
43624353

43634354
if (ce->num_hooked_props > 0) {
4364-
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, info) {
4355+
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, zend_property_info *info) {
43654356
if (info->hooks) {
43664357
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
43674358
if (info->hooks[i]) {

0 commit comments

Comments
 (0)