diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index c86672a8dd248..1251503d5e6bb 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -1671,14 +1671,14 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o } for (i = 0; i < call->num_args; i++) { - zend_op *opline = call->arg_info[i].opline; - if (opline->opcode != ZEND_SEND_VAL && opline->opcode != ZEND_SEND_VAR) { + zend_op *arg_info_opline = call->arg_info[i].opline; + if (arg_info_opline->opcode != ZEND_SEND_VAL && arg_info_opline->opcode != ZEND_SEND_VAR) { SET_RESULT_BOT(result); return; } - args[i] = get_op1_value(ctx, opline, - &ctx->scdf.ssa->ops[opline - ctx->scdf.op_array->opcodes]); + args[i] = get_op1_value(ctx, arg_info_opline, + &ctx->scdf.ssa->ops[arg_info_opline - ctx->scdf.op_array->opcodes]); if (args[i]) { if (IS_BOT(args[i]) || IS_PARTIAL_ARRAY(args[i])) { SET_RESULT_BOT(result); diff --git a/Zend/Optimizer/zend_call_graph.c b/Zend/Optimizer/zend_call_graph.c index 8a2f8ea2a7e1a..c5db4bc77a7e4 100644 --- a/Zend/Optimizer/zend_call_graph.c +++ b/Zend/Optimizer/zend_call_graph.c @@ -110,17 +110,17 @@ ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32 case ZEND_FRAMELESS_ICALL_2: case ZEND_FRAMELESS_ICALL_3: { func = ZEND_FLF_FUNC(opline); - zend_call_info *call_info = zend_arena_calloc(arena, 1, sizeof(zend_call_info)); - call_info->caller_op_array = op_array; - call_info->caller_init_opline = opline; - call_info->caller_call_opline = NULL; - call_info->callee_func = func; - call_info->num_args = ZEND_FLF_NUM_ARGS(opline->opcode); - call_info->next_callee = func_info->callee_info; - call_info->is_prototype = false; - call_info->is_frameless = true; - call_info->next_caller = NULL; - func_info->callee_info = call_info; + zend_call_info *frameless_call_info = zend_arena_calloc(arena, 1, sizeof(zend_call_info)); + frameless_call_info->caller_op_array = op_array; + frameless_call_info->caller_init_opline = opline; + frameless_call_info->caller_call_opline = NULL; + frameless_call_info->callee_func = func; + frameless_call_info->num_args = ZEND_FLF_NUM_ARGS(opline->opcode); + frameless_call_info->next_callee = func_info->callee_info; + frameless_call_info->is_prototype = false; + frameless_call_info->is_frameless = true; + frameless_call_info->next_caller = NULL; + func_info->callee_info = frameless_call_info; break; } case ZEND_DO_FCALL: diff --git a/Zend/Optimizer/zend_cfg.c b/Zend/Optimizer/zend_cfg.c index a05cf6fb79235..2f2895daf5bf4 100644 --- a/Zend/Optimizer/zend_cfg.c +++ b/Zend/Optimizer/zend_cfg.c @@ -673,7 +673,7 @@ ZEND_API void zend_cfg_compute_dominators_tree(const zend_op_array *op_array, ze { zend_basic_block *blocks = cfg->blocks; int blocks_count = cfg->blocks_count; - int j, k, changed; + int j, changed; if (cfg->blocks_count == 1) { blocks[0].level = 0; @@ -697,7 +697,7 @@ ZEND_API void zend_cfg_compute_dominators_tree(const zend_op_array *op_array, ze if ((blocks[j].flags & ZEND_BB_REACHABLE) == 0) { continue; } - for (k = 0; k < blocks[j].predecessors_count; k++) { + for (int k = 0; k < blocks[j].predecessors_count; k++) { int pred = cfg->predecessors[blocks[j].predecessor_offset + k]; if (blocks[pred].idom >= 0) { diff --git a/Zend/zend.h b/Zend/zend.h index 0cf1faeb653fe..437686486d0f4 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -269,8 +269,10 @@ typedef size_t (*zend_write_func_t)(const char *str, size_t str_length); #define zend_try \ { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ JMP_BUF *__orig_bailout = EG(bailout); \ JMP_BUF __bailout; \ + ZEND_DIAGNOSTIC_IGNORED_END \ \ EG(bailout) = &__bailout; \ if (SETJMP(__bailout)==0) { diff --git a/Zend/zend_API.c b/Zend/zend_API.c index fd5b7c8db7966..f6f1d8437a5e9 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3808,14 +3808,14 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc ret = 1; } } else if ((ce = zend_lookup_class(name)) != NULL) { - zend_class_entry *scope = get_scope(frame); + const zend_class_entry *frame_scope = get_scope(frame); fcc->calling_scope = ce; - if (scope && !fcc->object) { + if (frame_scope && !fcc->object) { zend_object *object = zend_get_this_object(frame); if (object && - instanceof_function(object->ce, scope) && - instanceof_function(scope, ce)) { + instanceof_function(object->ce, frame_scope) && + instanceof_function(frame_scope, ce)) { fcc->object = object; fcc->called_scope = object->ce; } else { diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 2c8023e62577e..35f4d15185df9 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1073,9 +1073,9 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_F } #if ZEND_MM_STAT do { - size_t size = heap->real_size + ZEND_MM_CHUNK_SIZE; - size_t peak = MAX(heap->real_peak, size); - heap->real_size = size; + size_t new_real_size = heap->real_size + ZEND_MM_CHUNK_SIZE; + size_t peak = MAX(heap->real_peak, new_real_size); + heap->real_size = new_real_size; heap->real_peak = peak; } while (0); #elif ZEND_MM_LIMIT @@ -1130,9 +1130,9 @@ static zend_always_inline void *zend_mm_alloc_large_ex(zend_mm_heap *heap, size_ #endif #if ZEND_MM_STAT do { - size_t size = heap->size + pages_count * ZEND_MM_PAGE_SIZE; - size_t peak = MAX(heap->peak, size); - heap->size = size; + size_t mem_size = heap->size + pages_count * ZEND_MM_PAGE_SIZE; + size_t peak = MAX(heap->peak, mem_size); + heap->size = mem_size; heap->peak = peak; } while (0); #endif @@ -1799,9 +1799,9 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p zend_mm_bitset_is_free_range(chunk->free_map, page_num + old_pages_count, new_pages_count - old_pages_count)) { #if ZEND_MM_STAT do { - size_t size = heap->size + (new_size - old_size); - size_t peak = MAX(heap->peak, size); - heap->size = size; + size_t new_real_size = heap->size + (new_size - old_size); + size_t peak = MAX(heap->peak, new_real_size); + heap->size = new_real_size; heap->peak = peak; } while (0); #endif @@ -1970,15 +1970,15 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D #endif #if ZEND_MM_STAT do { - size_t size = heap->real_size + new_size; - size_t peak = MAX(heap->real_peak, size); - heap->real_size = size; + size_t new_real_size = heap->real_size + new_size; + size_t peak = MAX(heap->real_peak, new_real_size); + heap->real_size = new_real_size; heap->real_peak = peak; } while (0); do { - size_t size = heap->size + new_size; - size_t peak = MAX(heap->peak, size); - heap->size = size; + size_t new_heap_size = heap->size + new_size; + size_t peak = MAX(heap->peak, new_heap_size); + heap->size = new_heap_size; heap->peak = peak; } while (0); #elif ZEND_MM_LIMIT @@ -3021,7 +3021,7 @@ static void tracked_free_all(zend_mm_heap *heap) { } #endif -static void alloc_globals_ctor(zend_alloc_globals *alloc_globals) +static void alloc_globals_ctor(zend_alloc_globals *alloc_globals_ptr) { char *tmp; @@ -3029,7 +3029,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals) tmp = getenv("USE_ZEND_ALLOC"); if (tmp && !ZEND_ATOL(tmp)) { bool tracked = (tmp = getenv("USE_TRACKED_ALLOC")) && ZEND_ATOL(tmp); - zend_mm_heap *mm_heap = alloc_globals->mm_heap = malloc(sizeof(zend_mm_heap)); + zend_mm_heap *mm_heap = alloc_globals_ptr->mm_heap = malloc(sizeof(zend_mm_heap)); memset(mm_heap, 0, sizeof(zend_mm_heap)); mm_heap->use_custom_heap = ZEND_MM_CUSTOM_HEAP_STD; mm_heap->limit = (size_t)Z_L(-1) >> 1; @@ -3056,13 +3056,13 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals) if (tmp && ZEND_ATOL(tmp)) { zend_mm_use_huge_pages = true; } - alloc_globals->mm_heap = zend_mm_init(); + alloc_globals_ptr->mm_heap = zend_mm_init(); } #ifdef ZTS -static void alloc_globals_dtor(zend_alloc_globals *alloc_globals) +static void alloc_globals_dtor(zend_alloc_globals *alloc_globals_ptr) { - zend_mm_shutdown(alloc_globals->mm_heap, 1, 1); + zend_mm_shutdown(alloc_globals_ptr->mm_heap, 1, 1); } #endif diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index d33747412ef0a..6f18709acf38d 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -2253,9 +2253,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_NEW: smart_str_appends(str, "new "); if (ast->child[0]->kind == ZEND_AST_CLASS) { - zend_ast_decl *decl = (zend_ast_decl *) ast->child[0]; - if (decl->child[3]) { - zend_ast_export_attributes(str, decl->child[3], indent, 0); + zend_ast_decl *class_decl = (zend_ast_decl *) ast->child[0]; + if (class_decl->child[3]) { + zend_ast_export_attributes(str, class_decl->child[3], indent, 0); } smart_str_appends(str, "class"); if (!zend_ast_is_list(ast->child[1]) @@ -2264,7 +2264,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio zend_ast_export_ex(str, ast->child[1], 0, indent); smart_str_appendc(str, ')'); } - zend_ast_export_class_no_header(str, decl, indent); + zend_ast_export_class_no_header(str, class_decl, indent); } else { zend_ast_export_ns_name(str, ast->child[0], 0, indent); smart_str_appendc(str, '('); diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index bb8bb28bf6e4f..9d5b5e08b7e8a 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -2012,8 +2012,6 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int zend_execute_data *prev_call = prev; while (prev_call) { - zend_execute_data *prev; - if (prev_call && prev_call->func && !ZEND_USER_CODE(prev_call->func->common.type) && @@ -2021,15 +2019,14 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int break; } - prev = prev_call->prev_execute_data; - if (prev && prev->func && ZEND_USER_CODE(prev->func->common.type)) { - ZVAL_STR_COPY(&tmp, prev->func->op_array.filename); + prev_call = prev_call->prev_execute_data; + if (prev_call && prev_call->func && ZEND_USER_CODE(prev_call->func->common.type)) { + ZVAL_STR_COPY(&tmp, prev_call->func->op_array.filename); _zend_hash_append_ex(stack_frame, ZSTR_KNOWN(ZEND_STR_FILE), &tmp, 1); - ZVAL_LONG(&tmp, prev->opline->lineno); + ZVAL_LONG(&tmp, prev_call->opline->lineno); _zend_hash_append_ex(stack_frame, ZSTR_KNOWN(ZEND_STR_LINE), &tmp, 1); break; } - prev_call = prev; } filename = NULL; } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ae50c29dffad6..dbce0501afebe 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3161,25 +3161,25 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t if (nullsafe) { if (obj_node.op_type == IS_TMP_VAR) { /* Flush delayed oplines */ - zend_op *opline = NULL, *oplines = zend_stack_base(&CG(delayed_oplines_stack)); + zend_op *delayed_opline = NULL, *delayed_oplines = zend_stack_base(&CG(delayed_oplines_stack)); uint32_t var = obj_node.u.op.var; uint32_t count = zend_stack_count(&CG(delayed_oplines_stack)); uint32_t i = count; - while (i > 0 && oplines[i-1].result_type == IS_TMP_VAR && oplines[i-1].result.var == var) { + while (i > 0 && delayed_oplines[i-1].result_type == IS_TMP_VAR && delayed_oplines[i-1].result.var == var) { i--; - if (oplines[i].op1_type == IS_TMP_VAR) { - var = oplines[i].op1.var; + if (delayed_oplines[i].op1_type == IS_TMP_VAR) { + var = delayed_oplines[i].op1.var; } else { break; } } for (; i < count; ++i) { - if (oplines[i].opcode != ZEND_NOP) { - opline = get_next_op(); - memcpy(opline, &oplines[i], sizeof(zend_op)); - oplines[i].opcode = ZEND_NOP; - oplines[i].extended_value = opline - CG(active_op_array)->opcodes; + if (delayed_oplines[i].opcode != ZEND_NOP) { + delayed_opline = get_next_op(); + memcpy(delayed_opline, &delayed_oplines[i], sizeof(zend_op)); + delayed_oplines[i].opcode = ZEND_NOP; + delayed_oplines[i].extended_value = delayed_opline - CG(active_op_array)->opcodes; } } } @@ -4280,7 +4280,6 @@ static void zend_compile_init_user_func(zend_ast *name_ast, uint32_t num_args, z static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; - zend_op *opline; if (args->children != 2) { return FAILURE; @@ -4322,7 +4321,8 @@ static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, ze zend_compile_expr(&arg_node, args->child[1]); zend_emit_op(NULL, ZEND_SEND_ARRAY, &arg_node, NULL); zend_emit_op(NULL, ZEND_CHECK_UNDEF_ARGS, NULL, NULL); - opline = zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL); + + zend_op *opline = zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL); opline->extended_value = ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS; return SUCCESS; @@ -4384,9 +4384,9 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string if (args->child[0]->kind == ZEND_AST_NAMED_ARG) { /* If the original argument was named, add the new argument as named as well, * as mixing named and positional is not allowed. */ - zend_ast *name = zend_ast_create_zval_from_str( + zend_ast *name_arg = zend_ast_create_zval_from_str( ZSTR_INIT_LITERAL("description", 0)); - arg = zend_ast_create(ZEND_AST_NAMED_ARG, name, arg); + arg = zend_ast_create(ZEND_AST_NAMED_ARG, name_arg, arg); } zend_ast_list_add((zend_ast *) args, arg); } @@ -7146,13 +7146,13 @@ static zend_type zend_compile_typename_ex( type_list->types[type_list->num_types++] = single_type; /* Check for trivially redundant class types */ - for (size_t i = 0; i < type_list->num_types - 1; i++) { - if (ZEND_TYPE_IS_INTERSECTION(type_list->types[i])) { - zend_are_intersection_types_redundant(single_type, type_list->types[i]); + for (size_t type_index = 0; type_index < type_list->num_types - 1; type_index++) { + if (ZEND_TYPE_IS_INTERSECTION(type_list->types[type_index])) { + zend_are_intersection_types_redundant(single_type, type_list->types[type_index]); continue; } /* Type from type list is a simple type */ - zend_is_intersection_type_redundant_by_single_type(single_type, type_list->types[i]); + zend_is_intersection_type_redundant_by_single_type(single_type, type_list->types[type_index]); } continue; } @@ -7206,10 +7206,10 @@ static zend_type zend_compile_typename_ex( } if (type_list->num_types) { - zend_type_list *list = zend_arena_alloc( + zend_type_list *type_list_arena = zend_arena_alloc( &CG(arena), ZEND_TYPE_LIST_SIZE(type_list->num_types)); - memcpy(list, type_list, ZEND_TYPE_LIST_SIZE(type_list->num_types)); - ZEND_TYPE_SET_LIST(type, list); + memcpy(type_list_arena, type_list, ZEND_TYPE_LIST_SIZE(type_list->num_types)); + ZEND_TYPE_SET_LIST(type, type_list_arena); ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_ARENA_BIT; /* Inform that the type list is a union type */ ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_UNION_BIT; @@ -7733,16 +7733,16 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 } if (is_promoted) { - zend_op_array *op_array = CG(active_op_array); - zend_class_entry *scope = op_array->scope; + zend_op_array *promoted_prop_op_array = CG(active_op_array); + zend_class_entry *scope = promoted_prop_op_array->scope; bool is_ctor = - scope && zend_is_constructor(op_array->function_name); + scope && zend_is_constructor(promoted_prop_op_array->function_name); if (!is_ctor) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare promoted property outside a constructor"); } - if ((op_array->fn_flags & ZEND_ACC_ABSTRACT) + if ((promoted_prop_op_array->fn_flags & ZEND_ACC_ABSTRACT) || (scope->ce_flags & ZEND_ACC_INTERFACE)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare promoted property in an abstract constructor"); @@ -7991,24 +7991,20 @@ static void compile_implicit_lexical_binds( static void zend_compile_closure_uses(zend_ast *ast) /* {{{ */ { - zend_op_array *op_array = CG(active_op_array); - zend_ast_list *list = zend_ast_get_list(ast); - uint32_t i; + const zend_op_array *op_array = CG(active_op_array); + const zend_ast_list *list = zend_ast_get_list(ast); - for (i = 0; i < list->children; ++i) { + for (uint32_t i = 0; i < list->children; ++i) { uint32_t mode = ZEND_BIND_EXPLICIT; zend_ast *var_ast = list->child[i]; zend_string *var_name = zend_ast_get_str(var_ast); zval zv; ZVAL_NULL(&zv); - { - int i; - for (i = 0; i < op_array->last_var; i++) { - if (zend_string_equals(op_array->vars[i], var_name)) { - zend_error_noreturn_unchecked(E_COMPILE_ERROR, - "Cannot use lexical variable $%S as a parameter name", var_name); - } + for (int var_index = 0; var_index < op_array->last_var; var_index++) { + if (zend_string_equals(op_array->vars[var_index], var_name)) { + zend_error_noreturn_unchecked(E_COMPILE_ERROR, + "Cannot use lexical variable $%S as a parameter name", var_name); } } diff --git a/Zend/zend_cpuinfo.c b/Zend/zend_cpuinfo.c index 6264031ceba42..113eb4cb490ff 100644 --- a/Zend/zend_cpuinfo.c +++ b/Zend/zend_cpuinfo.c @@ -31,11 +31,11 @@ static zend_cpu_info cpuinfo = {0}; #if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) # if defined(HAVE_CPUID_H) && defined(HAVE_CPUID_COUNT) /* use cpuid.h functions */ # include -static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) { - __cpuid_count(func, subfunc, cpuinfo->eax, cpuinfo->ebx, cpuinfo->ecx, cpuinfo->edx); +static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo_ptr) { + __cpuid_count(func, subfunc, cpuinfo_ptr->eax, cpuinfo_ptr->ebx, cpuinfo_ptr->ecx, cpuinfo_ptr->edx); } # else /* use inline asm */ -static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) { +static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo_ptr) { # if defined(__i386__) && (defined(__pic__) || defined(__PIC__)) /* PIC on i386 uses %ebx, so preserve it. */ __asm__ __volatile__ ( @@ -43,13 +43,13 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo "cpuid\n" "mov %%ebx,%1\n" "popl %%ebx" - : "=a"(cpuinfo->eax), "=r"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx) + : "=a"(cpuinfo_ptr->eax), "=r"(cpuinfo_ptr->ebx), "=c"(cpuinfo_ptr->ecx), "=d"(cpuinfo_ptr->edx) : "a"(func), "c"(subfunc) ); # else __asm__ __volatile__ ( "cpuid" - : "=a"(cpuinfo->eax), "=b"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx) + : "=a"(cpuinfo_ptr->eax), "=b"(cpuinfo_ptr->ebx), "=c"(cpuinfo_ptr->ecx), "=d"(cpuinfo_ptr->edx) : "a"(func), "c"(subfunc) ); # endif @@ -57,19 +57,19 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo # endif #elif defined(_MSC_VER) && !defined(__clang__) && (defined(_M_X64) || defined(_M_IX86)) /* use MSVC __cpuidex intrin */ # include -static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) { +static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo_ptr) { int regs[4]; __cpuidex(regs, func, subfunc); - cpuinfo->eax = regs[0]; - cpuinfo->ebx = regs[1]; - cpuinfo->ecx = regs[2]; - cpuinfo->edx = regs[3]; + cpuinfo_ptr->eax = regs[0]; + cpuinfo_ptr->ebx = regs[1]; + cpuinfo_ptr->ecx = regs[2]; + cpuinfo_ptr->edx = regs[3]; } #else /* fall back to zero */ -static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) { - cpuinfo->eax = 0; +static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo_ptr) { + cpuinfo_ptr->eax = 0; } #endif diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f42479cf745d2..a0e3c5948a787 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -972,14 +972,13 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ } if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) { - uint32_t call_info; + uint32_t closure_call_info = ZEND_CALL_CLOSURE; GC_ADDREF(ZEND_CLOSURE_OBJECT(func)); - call_info = ZEND_CALL_CLOSURE; if (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) { - call_info |= ZEND_CALL_FAKE_CLOSURE; + closure_call_info |= ZEND_CALL_FAKE_CLOSURE; } - ZEND_ADD_CALL_FLAG(call, call_info); + ZEND_ADD_CALL_FLAG(call, closure_call_info); } if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index a966a106def33..136500e7abc2b 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -470,47 +470,47 @@ static zend_always_inline void gc_remove_from_roots(gc_root_buffer *root) GC_BENCH_DEC(root_buf_length); } -static void root_buffer_dtor(zend_gc_globals *gc_globals) +static void root_buffer_dtor(zend_gc_globals *gc_globals_ptr) { - if (gc_globals->buf) { - free(gc_globals->buf); - gc_globals->buf = NULL; + if (gc_globals_ptr->buf) { + free(gc_globals_ptr->buf); + gc_globals_ptr->buf = NULL; } } -static void gc_globals_ctor_ex(zend_gc_globals *gc_globals) +static void gc_globals_ctor_ex(zend_gc_globals *gc_globals_ptr) { - gc_globals->gc_enabled = 0; - gc_globals->gc_active = 0; - gc_globals->gc_protected = 1; - gc_globals->gc_full = 0; - - gc_globals->buf = NULL; - gc_globals->unused = GC_INVALID; - gc_globals->first_unused = GC_INVALID; - gc_globals->gc_threshold = GC_INVALID; - gc_globals->buf_size = GC_INVALID; - gc_globals->num_roots = 0; - - gc_globals->gc_runs = 0; - gc_globals->collected = 0; - gc_globals->collector_time = 0; - gc_globals->dtor_time = 0; - gc_globals->free_time = 0; - gc_globals->activated_at = 0; - - gc_globals->dtor_idx = GC_FIRST_ROOT; - gc_globals->dtor_end = 0; - gc_globals->dtor_fiber = NULL; - gc_globals->dtor_fiber_running = false; + gc_globals_ptr->gc_enabled = 0; + gc_globals_ptr->gc_active = 0; + gc_globals_ptr->gc_protected = 1; + gc_globals_ptr->gc_full = 0; + + gc_globals_ptr->buf = NULL; + gc_globals_ptr->unused = GC_INVALID; + gc_globals_ptr->first_unused = GC_INVALID; + gc_globals_ptr->gc_threshold = GC_INVALID; + gc_globals_ptr->buf_size = GC_INVALID; + gc_globals_ptr->num_roots = 0; + + gc_globals_ptr->gc_runs = 0; + gc_globals_ptr->collected = 0; + gc_globals_ptr->collector_time = 0; + gc_globals_ptr->dtor_time = 0; + gc_globals_ptr->free_time = 0; + gc_globals_ptr->activated_at = 0; + + gc_globals_ptr->dtor_idx = GC_FIRST_ROOT; + gc_globals_ptr->dtor_end = 0; + gc_globals_ptr->dtor_fiber = NULL; + gc_globals_ptr->dtor_fiber_running = false; #if GC_BENCH - gc_globals->root_buf_length = 0; - gc_globals->root_buf_peak = 0; - gc_globals->zval_possible_root = 0; - gc_globals->zval_buffered = 0; - gc_globals->zval_remove_from_buffer = 0; - gc_globals->zval_marked_grey = 0; + gc_globals_ptr->root_buf_length = 0; + gc_globals_ptr->root_buf_peak = 0; + gc_globals_ptr->zval_possible_root = 0; + gc_globals_ptr->zval_buffered = 0; + gc_globals_ptr->zval_remove_from_buffer = 0; + gc_globals_ptr->zval_marked_grey = 0; #endif } @@ -917,11 +917,11 @@ static void gc_scan_black(zend_refcounted *ref, gc_stack *stack) zv++; while (--n) { if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_ADDREF(ref); - if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { - GC_REF_SET_BLACK(ref); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_ADDREF(tmp_ref); + if (!GC_REF_CHECK_COLOR(tmp_ref, GC_BLACK)) { + GC_REF_SET_BLACK(tmp_ref); + GC_STACK_PUSH(tmp_ref); } } zv++; @@ -960,11 +960,11 @@ static void gc_scan_black(zend_refcounted *ref, gc_stack *stack) zv = Z_INDIRECT_P(zv); } if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_ADDREF(ref); - if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { - GC_REF_SET_BLACK(ref); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_ADDREF(tmp_ref); + if (!GC_REF_CHECK_COLOR(tmp_ref, GC_BLACK)) { + GC_REF_SET_BLACK(tmp_ref); + GC_STACK_PUSH(tmp_ref); } } p++; @@ -1092,11 +1092,11 @@ static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack) zv++; while (--n) { if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_DELREF(ref); - if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) { - GC_REF_SET_COLOR(ref, GC_GREY); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_DELREF(tmp_ref); + if (!GC_REF_CHECK_COLOR(tmp_ref, GC_GREY)) { + GC_REF_SET_COLOR(tmp_ref, GC_GREY); + GC_STACK_PUSH(tmp_ref); } } zv++; @@ -1135,11 +1135,11 @@ static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack) zv = Z_INDIRECT_P(zv); } if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_DELREF(ref); - if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) { - GC_REF_SET_COLOR(ref, GC_GREY); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_DELREF(tmp_ref); + if (!GC_REF_CHECK_COLOR(tmp_ref, GC_GREY)) { + GC_REF_SET_COLOR(tmp_ref, GC_GREY); + GC_STACK_PUSH(tmp_ref); } } p++; @@ -1304,10 +1304,10 @@ static void gc_scan(zend_refcounted *ref, gc_stack *stack) zv++; while (--n) { if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - if (GC_REF_CHECK_COLOR(ref, GC_GREY)) { - GC_REF_SET_COLOR(ref, GC_WHITE); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + if (GC_REF_CHECK_COLOR(tmp_ref, GC_GREY)) { + GC_REF_SET_COLOR(tmp_ref, GC_WHITE); + GC_STACK_PUSH(tmp_ref); } } zv++; @@ -1346,10 +1346,10 @@ static void gc_scan(zend_refcounted *ref, gc_stack *stack) zv = Z_INDIRECT_P(zv); } if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - if (GC_REF_CHECK_COLOR(ref, GC_GREY)) { - GC_REF_SET_COLOR(ref, GC_WHITE); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + if (GC_REF_CHECK_COLOR(tmp_ref, GC_GREY)) { + GC_REF_SET_COLOR(tmp_ref, GC_WHITE); + GC_STACK_PUSH(tmp_ref); } } p++; @@ -1541,11 +1541,11 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta zv++; while (--n) { if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_ADDREF(ref); - if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { - GC_REF_SET_BLACK(ref); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_ADDREF(tmp_ref); + if (GC_REF_CHECK_COLOR(tmp_ref, GC_WHITE)) { + GC_REF_SET_BLACK(tmp_ref); + GC_STACK_PUSH(tmp_ref); } } zv++; @@ -1588,11 +1588,11 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta zv = Z_INDIRECT_P(zv); } if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_ADDREF(ref); - if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { - GC_REF_SET_BLACK(ref); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_ADDREF(tmp_ref); + if (GC_REF_CHECK_COLOR(tmp_ref, GC_WHITE)) { + GC_REF_SET_BLACK(tmp_ref); + GC_STACK_PUSH(tmp_ref); } } p++; @@ -1737,8 +1737,8 @@ static int gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buffe zv++; while (--n) { if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_STACK_PUSH(tmp_ref); } zv++; } @@ -1772,8 +1772,8 @@ static int gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buffe zv = Z_INDIRECT_P(zv); } if (Z_REFCOUNTED_P(zv)) { - zend_refcounted *ref = Z_COUNTED_P(zv); - GC_STACK_PUSH(ref); + zend_refcounted *tmp_ref = Z_COUNTED_P(zv); + GC_STACK_PUSH(tmp_ref); } p++; } diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 7d5726e496905..93187d98c7320 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -1000,23 +1000,28 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, ((zval*)(((char*)(_el)) - (_size))) #define _ZEND_HASH_FOREACH_VAL(_ht) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ const HashTable *__ht = (_ht); \ uint32_t _count = __ht->nNumUsed; \ size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \ zval *_z = __ht->arPacked; \ + ZEND_DIAGNOSTIC_IGNORED_END \ for (; _count > 0; _z = ZEND_HASH_NEXT_ELEMENT(_z, _size), _count--) { \ if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue; #define _ZEND_HASH_REVERSE_FOREACH_VAL(_ht) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ const HashTable *__ht = (_ht); \ uint32_t _idx = __ht->nNumUsed; \ size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \ zval *_z = ZEND_HASH_ELEMENT_EX(__ht, _idx, _size); \ + ZEND_DIAGNOSTIC_IGNORED_END \ for (;_idx > 0; _idx--) { \ _z = ZEND_HASH_PREV_ELEMENT(_z, _size); \ if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue; #define ZEND_HASH_FOREACH_FROM(_ht, indirect, _from) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ const HashTable *__ht = (_ht); \ zend_ulong __h; \ zend_string *__key = NULL; \ @@ -1024,14 +1029,19 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \ zval *__z = ZEND_HASH_ELEMENT_EX(__ht, _idx, _size); \ uint32_t _count = __ht->nNumUsed - _idx; \ + ZEND_DIAGNOSTIC_IGNORED_END \ for (;_count > 0; _count--) { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z = __z; \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (HT_IS_PACKED(__ht)) { \ __z++; \ __h = _idx; \ _idx++; \ } else { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ Bucket *_p = (Bucket*)__z; \ + ZEND_DIAGNOSTIC_IGNORED_END \ __z = &(_p + 1)->val; \ __h = _p->h; \ __key = _p->key; \ @@ -1045,6 +1055,7 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, #define ZEND_HASH_FOREACH(_ht, indirect) ZEND_HASH_FOREACH_FROM(_ht, indirect, 0) #define ZEND_HASH_REVERSE_FOREACH(_ht, indirect) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ const HashTable *__ht = (_ht); \ uint32_t _idx = __ht->nNumUsed; \ zval *_z; \ @@ -1052,13 +1063,16 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, zend_string *__key = NULL; \ size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \ zval *__z = ZEND_HASH_ELEMENT_EX(__ht, _idx, _size); \ + ZEND_DIAGNOSTIC_IGNORED_END \ for (;_idx > 0; _idx--) { \ if (HT_IS_PACKED(__ht)) { \ __z--; \ _z = __z; \ __h = _idx - 1; \ } else { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ Bucket *_p = (Bucket*)__z; \ + ZEND_DIAGNOSTIC_IGNORED_END \ _p--; \ __z = &_p->val; \ _z = __z; \ @@ -1234,12 +1248,16 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, /* Hash array iterators */ #define ZEND_HASH_MAP_FOREACH_FROM(_ht, indirect, _from) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ const HashTable *__ht = (_ht); \ Bucket *_p = __ht->arData + (_from); \ const Bucket *_end = __ht->arData + __ht->nNumUsed; \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(!HT_IS_PACKED(__ht)); \ for (; _p != _end; _p++) { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z = &_p->val; \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \ _z = Z_INDIRECT_P(_z); \ } \ @@ -1248,10 +1266,12 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, #define ZEND_HASH_MAP_FOREACH(_ht, indirect) ZEND_HASH_MAP_FOREACH_FROM(_ht, indirect, 0) #define ZEND_HASH_MAP_REVERSE_FOREACH(_ht, indirect) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ /* const */ HashTable *__ht = (_ht); \ uint32_t _idx = __ht->nNumUsed; \ Bucket *_p = __ht->arData + _idx; \ zval *_z; \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(!HT_IS_PACKED(__ht)); \ for (_idx = __ht->nNumUsed; _idx > 0; _idx--) { \ _p--; \ @@ -1265,11 +1285,15 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, ZEND_ASSERT(!HT_IS_PACKED(__ht)); \ __ht->nNumOfElements--; \ do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ uint32_t j = HT_IDX_TO_HASH(_idx - 1); \ uint32_t nIndex = _p->h | __ht->nTableMask; \ uint32_t i = HT_HASH(__ht, nIndex); \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (UNEXPECTED(j != i)) { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ Bucket *prev = HT_HASH_TO_BUCKET(__ht, i); \ + ZEND_DIAGNOSTIC_IGNORED_END \ while (Z_NEXT(prev->val) != j) { \ i = Z_NEXT(prev->val); \ prev = HT_HASH_TO_BUCKET(__ht, i); \ @@ -1442,10 +1466,12 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, /* Packed array iterators */ #define ZEND_HASH_PACKED_FOREACH_FROM(_ht, _from) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ const HashTable *__ht = (_ht); \ zend_ulong _idx = (_from); \ zval *_z = __ht->arPacked + (_from); \ zval *_end = __ht->arPacked + __ht->nNumUsed; \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(HT_IS_PACKED(__ht)); \ for (;_z != _end; _z++, _idx++) { \ (void) _idx; \ @@ -1454,9 +1480,11 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, #define ZEND_HASH_PACKED_FOREACH(_ht) ZEND_HASH_PACKED_FOREACH_FROM(_ht, 0) #define ZEND_HASH_PACKED_REVERSE_FOREACH(_ht) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ const HashTable *__ht = (_ht); \ zend_ulong _idx = __ht->nNumUsed; \ zval *_z = __ht->arPacked + _idx; \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(HT_IS_PACKED(__ht)); \ while (_idx > 0) { \ _z--; \ @@ -1514,9 +1542,11 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, * (HashTable must have enough free buckets). */ #define ZEND_HASH_FILL_PACKED(ht) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ HashTable *__fill_ht = (ht); \ zval *__fill_val = __fill_ht->arPacked + __fill_ht->nNumUsed; \ uint32_t __fill_idx = __fill_ht->nNumUsed; \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(HT_IS_PACKED(__fill_ht)); #define ZEND_HASH_FILL_GROW() do { \ diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c index 5c3cd136d5807..37e545ce8b922 100644 --- a/Zend/zend_highlight.c +++ b/Zend/zend_highlight.c @@ -75,23 +75,23 @@ ZEND_API void zend_html_puts(const char *s, size_t len) } -ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini) +ZEND_API void zend_highlight(const zend_syntax_highlighter_ini *syntax_highlighter_ini_ptr) { zval token; int token_type; - char *last_color = syntax_highlighter_ini->highlight_html; - char *next_color; + const char *last_color = syntax_highlighter_ini_ptr->highlight_html; + const char *next_color; zend_printf("
", last_color);
 	/* highlight stuff coming back from zendlex() */
 	while ((token_type=lex_scan(&token, NULL))) {
 		switch (token_type) {
 			case T_INLINE_HTML:
-				next_color = syntax_highlighter_ini->highlight_html;
+				next_color = syntax_highlighter_ini_ptr->highlight_html;
 				break;
 			case T_COMMENT:
 			case T_DOC_COMMENT:
-				next_color = syntax_highlighter_ini->highlight_comment;
+				next_color = syntax_highlighter_ini_ptr->highlight_comment;
 				break;
 			case T_OPEN_TAG:
 			case T_OPEN_TAG_WITH_ECHO:
@@ -105,12 +105,12 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
 			case T_PROPERTY_C:
 			case T_NS_C:
 			case T_CLASS_C:
-				next_color = syntax_highlighter_ini->highlight_default;
+				next_color = syntax_highlighter_ini_ptr->highlight_default;
 				break;
 			case '"':
 			case T_ENCAPSED_AND_WHITESPACE:
 			case T_CONSTANT_ENCAPSED_STRING:
-				next_color = syntax_highlighter_ini->highlight_string;
+				next_color = syntax_highlighter_ini_ptr->highlight_string;
 				break;
 			case T_WHITESPACE:
 				zend_html_puts((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));  /* no color needed */
@@ -119,19 +119,19 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
 				break;
 			default:
 				if (Z_TYPE(token) == IS_UNDEF) {
-					next_color = syntax_highlighter_ini->highlight_keyword;
+					next_color = syntax_highlighter_ini_ptr->highlight_keyword;
 				} else {
-					next_color = syntax_highlighter_ini->highlight_default;
+					next_color = syntax_highlighter_ini_ptr->highlight_default;
 				}
 				break;
 		}
 
 		if (last_color != next_color) {
-			if (last_color != syntax_highlighter_ini->highlight_html) {
+			if (last_color != syntax_highlighter_ini_ptr->highlight_html) {
 				zend_printf("");
 			}
 			last_color = next_color;
-			if (last_color != syntax_highlighter_ini->highlight_html) {
+			if (last_color != syntax_highlighter_ini_ptr->highlight_html) {
 				zend_printf("", last_color);
 			}
 		}
@@ -155,7 +155,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
 		ZVAL_UNDEF(&token);
 	}
 
-	if (last_color != syntax_highlighter_ini->highlight_html) {
+	if (last_color != syntax_highlighter_ini_ptr->highlight_html) {
 		zend_printf("");
 	}
 	zend_printf("
"); diff --git a/Zend/zend_highlight.h b/Zend/zend_highlight.h index 04688d65132b2..46baab66685c3 100644 --- a/Zend/zend_highlight.h +++ b/Zend/zend_highlight.h @@ -39,7 +39,7 @@ typedef struct _zend_syntax_highlighter_ini { BEGIN_EXTERN_C() -ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini); +ZEND_API void zend_highlight(const zend_syntax_highlighter_ini *syntax_highlighter_ini_ptr); ZEND_API void zend_strip(void); ZEND_API zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); ZEND_API void highlight_string(zend_string *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 88f1d3447c2a7..27e7e4c9a3841 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1328,9 +1328,9 @@ static inheritance_status verify_property_type_compatibility( if (parent_info->hooks[ZEND_PROPERTY_HOOK_SET] && (!child_info->hooks || !child_info->hooks[ZEND_PROPERTY_HOOK_SET])) { zend_type set_type = parent_info->hooks[ZEND_PROPERTY_HOOK_SET]->common.arg_info[0].type; - inheritance_status result = zend_perform_covariant_type_check( + inheritance_status hook_result = zend_perform_covariant_type_check( parent_info->ce, set_type, child_info->ce, child_info->type); - if ((result == INHERITANCE_ERROR && throw_on_error) || (result == INHERITANCE_UNRESOLVED && throw_on_unresolved)) { + if ((hook_result == INHERITANCE_ERROR && throw_on_error) || (hook_result == INHERITANCE_UNRESOLVED && throw_on_unresolved)) { emit_set_hook_type_error(child_info, parent_info); } } @@ -2900,9 +2900,9 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent zend_function **hooks = new_prop->hooks = zend_arena_alloc(&CG(arena), ZEND_PROPERTY_HOOK_STRUCT_SIZE); memcpy(hooks, property_info->hooks, ZEND_PROPERTY_HOOK_STRUCT_SIZE); - for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) { - if (hooks[i]) { - zend_function *old_fn = hooks[i]; + for (uint32_t hook_index = 0; hook_index < ZEND_PROPERTY_HOOK_COUNT; hook_index++) { + if (hooks[hook_index]) { + const zend_function *old_fn = hooks[hook_index]; /* Hooks are not yet supported for internal properties. */ ZEND_ASSERT(ZEND_USER_CODE(old_fn->type)); @@ -2917,7 +2917,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent zend_fixup_trait_method(new_fn, ce); - hooks[i] = new_fn; + hooks[hook_index] = new_fn; } } ce->ce_flags |= ZEND_ACC_USE_GUARDS; @@ -3293,7 +3293,7 @@ static zend_op_array *zend_lazy_method_load( static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce) { zend_class_entry *ce; - Bucket *p, *end; + Bucket *p; ce = zend_arena_alloc(&CG(arena), sizeof(zend_class_entry)); memcpy(ce, pce, sizeof(zend_class_entry)); @@ -3325,8 +3325,8 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce) memcpy(p, HT_GET_DATA_ADDR(&ce->function_table), HT_USED_SIZE(&ce->function_table)); HT_SET_DATA_ADDR(&ce->function_table, p); p = ce->function_table.arData; - end = p + ce->function_table.nNumUsed; - for (; p != end; p++) { + + for (const Bucket *end = p + ce->function_table.nNumUsed; p != end; p++) { zend_op_array *op_array = Z_PTR(p->val); zend_op_array *new_op_array = Z_PTR(p->val) = zend_lazy_method_load(op_array, ce, pce); @@ -3365,8 +3365,8 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce) memcpy(p, HT_GET_DATA_ADDR(&ce->properties_info), HT_USED_SIZE(&ce->properties_info)); HT_SET_DATA_ADDR(&ce->properties_info, p); p = ce->properties_info.arData; - end = p + ce->properties_info.nNumUsed; - for (; p != end; p++) { + + for (const Bucket *end = p + ce->properties_info.nNumUsed; p != end; p++) { zend_property_info *prop_info, *new_prop_info; prop_info = Z_PTR(p->val); @@ -3401,8 +3401,8 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce) memcpy(p, HT_GET_DATA_ADDR(&ce->constants_table), HT_USED_SIZE(&ce->constants_table)); HT_SET_DATA_ADDR(&ce->constants_table, p); p = ce->constants_table.arData; - end = p + ce->constants_table.nNumUsed; - for (; p != end; p++) { + + for (const Bucket *end = p + ce->constants_table.nNumUsed; p != end; p++) { zend_class_constant *c, *new_c; c = Z_PTR(p->val); diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 194f5a995fbce..54eb1e3c50ffc 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -820,7 +820,7 @@ zend_op_array *compile_string(zend_string *source_string, const char *filename, } -zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini) +zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini_ptr) { zend_lex_state original_lex_state; zend_file_handle file_handle; @@ -833,7 +833,7 @@ zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *sy zend_restore_lexical_state(&original_lex_state); return FAILURE; } - zend_highlight(syntax_highlighter_ini); + zend_highlight(syntax_highlighter_ini_ptr); if (SCNG(script_filtered)) { efree(SCNG(script_filtered)); SCNG(script_filtered) = NULL; @@ -843,7 +843,7 @@ zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *sy return SUCCESS; } -void highlight_string(zend_string *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *filename) +void highlight_string(zend_string *str, zend_syntax_highlighter_ini *syntax_highlighter_ini_ptr, const char *filename) { zend_lex_state original_lex_state; zval str_zv; @@ -853,7 +853,7 @@ void highlight_string(zend_string *str, zend_syntax_highlighter_ini *syntax_high zend_prepare_string_for_scanning(&str_zv, filename_str); zend_string_release(filename_str); BEGIN(INITIAL); - zend_highlight(syntax_highlighter_ini); + zend_highlight(syntax_highlighter_ini_ptr); if (SCNG(script_filtered)) { efree(SCNG(script_filtered)); SCNG(script_filtered) = NULL; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index c2fbc0ee110c9..d11a36c90a761 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -3663,21 +3663,17 @@ ZEND_API uint8_t ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t len * http://www.iti.fh-flensburg.de/lang/algorithmen/pattern/sundayen.htm */ static zend_always_inline void zend_memnstr_ex_pre(unsigned int td[], const char *needle, size_t needle_len, int reverse) /* {{{ */ { - int i; - - for (i = 0; i < 256; i++) { + for (unsigned int i = 0; i < 256; i++) { td[i] = needle_len + 1; } if (reverse) { - for (i = needle_len - 1; i >= 0; i--) { + for (int i = needle_len - 1; i >= 0; i--) { td[(unsigned char)needle[i]] = i + 1; } } else { - size_t i; - - for (i = 0; i < needle_len; i++) { - td[(unsigned char)needle[i]] = (int)needle_len - i; + for (size_t i = 0; i < needle_len; i++) { + td[(unsigned char)needle[i]] = needle_len - i; } } } diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 83f8aa0852db8..91fdc997abf92 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -371,18 +371,18 @@ void zend_signal_deactivate(void) } /* }}} */ -static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals) /* {{{ */ +static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals_ptr) /* {{{ */ { size_t x; - memset(zend_signal_globals, 0, sizeof(*zend_signal_globals)); - zend_signal_globals->reset = 1; + memset(zend_signal_globals_ptr, 0, sizeof(*zend_signal_globals_ptr)); + zend_signal_globals_ptr->reset = 1; - for (x = 0; x < sizeof(zend_signal_globals->pstorage) / sizeof(*zend_signal_globals->pstorage); ++x) { - zend_signal_queue_t *queue = &zend_signal_globals->pstorage[x]; + for (x = 0; x < sizeof(zend_signal_globals_ptr->pstorage) / sizeof(*zend_signal_globals_ptr->pstorage); ++x) { + zend_signal_queue_t *queue = &zend_signal_globals_ptr->pstorage[x]; queue->zend_signal.signo = 0; - queue->next = zend_signal_globals->pavail; - zend_signal_globals->pavail = queue; + queue->next = zend_signal_globals_ptr->pavail; + zend_signal_globals_ptr->pavail = queue; } } /* }}} */ diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 8f012868ddab4..6e4cd49db4770 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -209,8 +209,10 @@ typedef struct { /* This iterates over a zend_type_list. */ #define ZEND_TYPE_LIST_FOREACH(list, type_ptr) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_type *_list = (list)->types; \ zend_type *_end = _list + (list)->num_types; \ + ZEND_DIAGNOSTIC_IGNORED_END \ for (; _list < _end; _list++) { \ type_ptr = _list; @@ -221,9 +223,13 @@ typedef struct { /* This iterates over any zend_type. If it's a type list, all list elements will * be visited. If it's a single type, only the single type is visited. */ #define ZEND_TYPE_FOREACH(type, type_ptr) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_type *_cur, *_end; \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (ZEND_TYPE_HAS_LIST(type)) { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_type_list *_list = ZEND_TYPE_LIST(type); \ + ZEND_DIAGNOSTIC_IGNORED_END \ _cur = _list->types; \ _end = _cur + _list->num_types; \ } else { \ @@ -485,9 +491,11 @@ struct _zend_array { (HT_HASH_SIZE((ht)->nTableMask) + ((size_t)(ht)->nNumUsed * sizeof(zval))) #if defined(__AVX2__) # define HT_HASH_RESET(ht) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ char *p = (char*)&HT_HASH(ht, (ht)->nTableMask); \ size_t size = HT_HASH_SIZE((ht)->nTableMask); \ __m256i ymm0 = _mm256_setzero_si256(); \ + ZEND_DIAGNOSTIC_IGNORED_END \ ymm0 = _mm256_cmpeq_epi64(ymm0, ymm0); \ ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \ do { \ @@ -499,9 +507,11 @@ struct _zend_array { } while (0) #elif defined(__SSE2__) # define HT_HASH_RESET(ht) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ char *p = (char*)&HT_HASH(ht, (ht)->nTableMask); \ size_t size = HT_HASH_SIZE((ht)->nTableMask); \ __m128i xmm0 = _mm_setzero_si128(); \ + ZEND_DIAGNOSTIC_IGNORED_END \ xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \ ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \ do { \ @@ -515,9 +525,11 @@ struct _zend_array { } while (0) #elif defined(__aarch64__) || defined(_M_ARM64) # define HT_HASH_RESET(ht) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ char *p = (char*)&HT_HASH(ht, (ht)->nTableMask); \ size_t size = HT_HASH_SIZE((ht)->nTableMask); \ int32x4_t t = vdupq_n_s32(-1); \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \ do { \ vst1q_s32((int32_t*)p, t); \ @@ -715,7 +727,9 @@ static zend_always_inline uint8_t zval_get_type(const zval* pz) { #define GC_DTOR(p) \ do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_refcounted_h *_p = &(p)->gc; \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (zend_gc_delref(_p) == 0) { \ rc_dtor_func((zend_refcounted *)_p); \ } else { \ @@ -725,7 +739,9 @@ static zend_always_inline uint8_t zval_get_type(const zval* pz) { #define GC_DTOR_NO_REF(p) \ do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_refcounted_h *_p = &(p)->gc; \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (zend_gc_delref(_p) == 0) { \ rc_dtor_func((zend_refcounted *)_p); \ } else { \ @@ -1064,20 +1080,26 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_LONG(z, l) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_LVAL_P(__z) = l; \ Z_TYPE_INFO_P(__z) = IS_LONG; \ } while (0) #define ZVAL_DOUBLE(z, d) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_DVAL_P(__z) = d; \ Z_TYPE_INFO_P(__z) = IS_DOUBLE; \ } while (0) #define ZVAL_STR(z, s) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ zend_string *__s = (s); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_STR_P(__z) = __s; \ /* interned strings support */ \ Z_TYPE_INFO_P(__z) = ZSTR_IS_INTERNED(__s) ? \ @@ -1086,22 +1108,28 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_INTERNED_STR(z, s) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ zend_string *__s = (s); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_STR_P(__z) = __s; \ Z_TYPE_INFO_P(__z) = IS_INTERNED_STRING_EX; \ } while (0) #define ZVAL_NEW_STR(z, s) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ zend_string *__s = (s); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_STR_P(__z) = __s; \ Z_TYPE_INFO_P(__z) = IS_STRING_EX; \ } while (0) #define ZVAL_STR_COPY(z, s) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ zend_string *__s = (s); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_STR_P(__z) = __s; \ /* interned strings support */ \ if (ZSTR_IS_INTERNED(__s)) { \ @@ -1113,44 +1141,56 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_ARR(z, a) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_array *__arr = (a); \ zval *__z = (z); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_ARR_P(__z) = __arr; \ Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \ } while (0) #define ZVAL_NEW_PERSISTENT_ARR(z) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ zend_array *_arr = \ (zend_array *) malloc(sizeof(zend_array)); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_ARR_P(__z) = _arr; \ Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \ } while (0) #define ZVAL_OBJ(z, o) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_OBJ_P(__z) = (o); \ Z_TYPE_INFO_P(__z) = IS_OBJECT_EX; \ } while (0) #define ZVAL_OBJ_COPY(z, o) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ zend_object *__o = (o); \ + ZEND_DIAGNOSTIC_IGNORED_END \ GC_ADDREF(__o); \ Z_OBJ_P(__z) = __o; \ Z_TYPE_INFO_P(__z) = IS_OBJECT_EX; \ } while (0) #define ZVAL_RES(z, r) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_RES_P(__z) = (r); \ Z_TYPE_INFO_P(__z) = IS_RESOURCE_EX; \ } while (0) #define ZVAL_NEW_RES(z, h, p, t) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_resource *_res = \ (zend_resource *) emalloc(sizeof(zend_resource)); \ zval *__z; \ + ZEND_DIAGNOSTIC_IGNORED_END \ GC_SET_REFCOUNT(_res, 1); \ GC_TYPE_INFO(_res) = GC_RESOURCE; \ _res->handle = (h); \ @@ -1162,9 +1202,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_NEW_PERSISTENT_RES(z, h, p, t) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_resource *_res = \ (zend_resource *) malloc(sizeof(zend_resource)); \ zval *__z; \ + ZEND_DIAGNOSTIC_IGNORED_END \ GC_SET_REFCOUNT(_res, 1); \ GC_TYPE_INFO(_res) = GC_RESOURCE | \ (GC_PERSISTENT << GC_FLAGS_SHIFT); \ @@ -1177,14 +1219,18 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_REF(z, r) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_REF_P(__z) = (r); \ Z_TYPE_INFO_P(__z) = IS_REFERENCE_EX; \ } while (0) #define ZVAL_NEW_EMPTY_REF(z) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_reference *_ref = \ (zend_reference *) emalloc(sizeof(zend_reference)); \ + ZEND_DIAGNOSTIC_IGNORED_END \ GC_SET_REFCOUNT(_ref, 1); \ GC_TYPE_INFO(_ref) = GC_REFERENCE; \ _ref->sources.ptr = NULL; \ @@ -1193,8 +1239,10 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_NEW_REF(z, r) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_reference *_ref = \ (zend_reference *) emalloc(sizeof(zend_reference)); \ + ZEND_DIAGNOSTIC_IGNORED_END \ GC_SET_REFCOUNT(_ref, 1); \ GC_TYPE_INFO(_ref) = GC_REFERENCE; \ ZVAL_COPY_VALUE(&_ref->val, r); \ @@ -1204,9 +1252,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_MAKE_REF_EX(z, refcount) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z = (z); \ zend_reference *_ref = \ (zend_reference *) emalloc(sizeof(zend_reference)); \ + ZEND_DIAGNOSTIC_IGNORED_END \ GC_SET_REFCOUNT(_ref, (refcount)); \ GC_TYPE_INFO(_ref) = GC_REFERENCE; \ ZVAL_COPY_VALUE(&_ref->val, _z); \ @@ -1216,8 +1266,10 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_NEW_PERSISTENT_REF(z, r) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_reference *_ref = \ (zend_reference *) malloc(sizeof(zend_reference)); \ + ZEND_DIAGNOSTIC_IGNORED_END \ GC_SET_REFCOUNT(_ref, 1); \ GC_TYPE_INFO(_ref) = GC_REFERENCE | \ (GC_PERSISTENT << GC_FLAGS_SHIFT); \ @@ -1228,7 +1280,9 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { } while (0) #define ZVAL_AST(z, ast) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__z = (z); \ + ZEND_DIAGNOSTIC_IGNORED_END \ Z_AST_P(__z) = ast; \ Z_TYPE_INFO_P(__z) = IS_CONSTANT_AST_EX; \ } while (0) @@ -1402,19 +1456,23 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { #define ZVAL_COPY_VALUE(z, v) \ do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z1 = (z); \ const zval *_z2 = (v); \ zend_refcounted *_gc = Z_COUNTED_P(_z2); \ uint32_t _t = Z_TYPE_INFO_P(_z2); \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \ } while (0) #define ZVAL_COPY(z, v) \ do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z1 = (z); \ const zval *_z2 = (v); \ zend_refcounted *_gc = Z_COUNTED_P(_z2); \ uint32_t _t = Z_TYPE_INFO_P(_z2); \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \ if (Z_TYPE_INFO_REFCOUNTED(_t)) { \ GC_ADDREF(_gc); \ @@ -1423,10 +1481,12 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { #define ZVAL_DUP(z, v) \ do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z1 = (z); \ const zval *_z2 = (v); \ zend_refcounted *_gc = Z_COUNTED_P(_z2); \ uint32_t _t = Z_TYPE_INFO_P(_z2); \ + ZEND_DIAGNOSTIC_IGNORED_END \ if ((_t & Z_TYPE_MASK) == IS_ARRAY) { \ ZVAL_ARR(_z1, zend_array_dup((zend_array*)_gc));\ } else { \ @@ -1443,10 +1503,12 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { */ #define ZVAL_COPY_OR_DUP(z, v) \ do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z1 = (z); \ const zval *_z2 = (v); \ zend_refcounted *_gc = Z_COUNTED_P(_z2); \ uint32_t _t = Z_TYPE_INFO_P(_z2); \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \ if (Z_TYPE_INFO_REFCOUNTED(_t)) { \ /* Objects reuse PERSISTENT as WEAKLY_REFERENCED */ \ @@ -1478,15 +1540,19 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { } while (0) #define ZVAL_MAKE_REF(zv) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__zv = (zv); \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (!Z_ISREF_P(__zv)) { \ ZVAL_NEW_REF(__zv, __zv); \ } \ } while (0) #define ZVAL_UNREF(z) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z = (z); \ zend_reference *ref; \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(Z_ISREF_P(_z)); \ ref = Z_REF_P(_z); \ ZVAL_COPY_VALUE(_z, &ref->val); \ @@ -1494,7 +1560,9 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { } while (0) #define ZVAL_COPY_DEREF(z, v) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_z3 = (v); \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (Z_OPT_REFCOUNTED_P(_z3)) { \ if (UNEXPECTED(Z_OPT_ISREF_P(_z3))) { \ _z3 = Z_REFVAL_P(_z3); \ @@ -1510,7 +1578,9 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { #define SEPARATE_STRING(zv) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_zv = (zv); \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (Z_REFCOUNT_P(_zv) > 1) { \ zend_string *_str = Z_STR_P(_zv); \ ZEND_ASSERT(Z_REFCOUNTED_P(_zv)); \ @@ -1522,8 +1592,10 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { } while (0) #define SEPARATE_ARRAY(zv) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *__zv = (zv); \ zend_array *_arr = Z_ARR_P(__zv); \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (UNEXPECTED(GC_REFCOUNT(_arr) > 1)) { \ ZVAL_ARR(__zv, zend_array_dup(_arr)); \ GC_TRY_DELREF(_arr); \ @@ -1531,7 +1603,9 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { } while (0) #define SEPARATE_ZVAL_NOREF(zv) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_zv = (zv); \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZEND_ASSERT(Z_TYPE_P(_zv) != IS_REFERENCE); \ if (Z_TYPE_P(_zv) == IS_ARRAY) { \ SEPARATE_ARRAY(_zv); \ @@ -1539,9 +1613,13 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) { } while (0) #define SEPARATE_ZVAL(zv) do { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zval *_zv = (zv); \ + ZEND_DIAGNOSTIC_IGNORED_END \ if (Z_ISREF_P(_zv)) { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ zend_reference *_r = Z_REF_P(_zv); \ + ZEND_DIAGNOSTIC_IGNORED_END \ ZVAL_COPY_VALUE(_zv, &_r->val); \ if (GC_DELREF(_r) == 0) { \ efree_size(_r, sizeof(zend_reference)); \ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index e19c503379319..93317bb8878d2 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3240,8 +3240,6 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -3298,6 +3296,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if (OP1_TYPE == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -3343,7 +3342,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index af9ea669b6b4f..d6a2231b357d2 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -6999,8 +6999,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = RT_CONSTANT(opline, opline->op1); op2 = RT_CONSTANT(opline, opline->op2); @@ -7057,6 +7055,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if (IS_CONST == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -7102,7 +7101,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_ break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -9563,8 +9562,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = RT_CONSTANT(opline, opline->op1); op2 = _get_zval_ptr_var(opline->op2.var EXECUTE_DATA_CC); @@ -9621,6 +9618,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if (IS_CONST == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -9666,7 +9664,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_ break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -12045,8 +12043,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -12103,6 +12099,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if (IS_CONST == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -12148,7 +12145,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -16438,8 +16435,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); op2 = RT_CONSTANT(opline, opline->op2); @@ -16496,6 +16491,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -16541,7 +16537,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_ break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -17931,8 +17927,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); op2 = _get_zval_ptr_var(opline->op2.var EXECUTE_DATA_CC); @@ -17989,6 +17983,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -18034,7 +18029,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -19338,8 +19333,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); op2 = EX_VAR(opline->op2.var); @@ -19396,6 +19389,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -19441,7 +19435,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -44654,8 +44648,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -44712,6 +44704,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if (IS_CV == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -44757,7 +44750,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -48548,8 +48541,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = EX_VAR(opline->op1.var); op2 = _get_zval_ptr_var(opline->op2.var EXECUTE_DATA_CC); @@ -48606,6 +48597,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if (IS_CV == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -48651,7 +48643,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); @@ -54143,8 +54135,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER { USE_OPLINE zval *op1, *op2; - zend_string *op1_str, *op2_str, *str; - op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -54201,6 +54191,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER } SAVE_OPLINE(); + zend_string *op1_str, *op2_str; if (IS_CV == IS_CONST) { op1_str = Z_STR_P(op1); } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -54246,7 +54237,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER break; } } - str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); + zend_string *str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0); memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str)); memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1); diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 19068b90c0d0b..27d61dcd2374b 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1329,19 +1329,19 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, * arrays with NULLs or empty strings. */ if (count < num_subpats) { - for (int i = count; i < num_subpats; i++) { + for (int subpattern = count; subpattern < num_subpats; subpattern++) { if (offset_capture) { add_offset_pair( - match_sets[i], NULL, PCRE2_UNSET, PCRE2_UNSET, + match_sets[subpattern], NULL, PCRE2_UNSET, PCRE2_UNSET, NULL, unmatched_as_null); } else if (unmatched_as_null) { zval tmp; ZVAL_NULL(&tmp); - zend_hash_next_index_insert_new(match_sets[i], &tmp); + zend_hash_next_index_insert_new(match_sets[subpattern], &tmp); } else { zval tmp; ZVAL_EMPTY_STRING(&tmp); - zend_hash_next_index_insert_new(match_sets[i], &tmp); + zend_hash_next_index_insert_new(match_sets[subpattern], &tmp); } } } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 349410ed9feba..7b88b54f38bb4 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -286,11 +286,11 @@ static void spl_recursive_it_move_forward_ex(spl_recursive_it_object *object, zv if (object->callHasChildren) { zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->callHasChildren, "callHasChildren", &retval); } else { - zend_class_entry *ce = object->iterators[object->level].ce; + zend_class_entry *ce_scope = object->iterators[object->level].ce; zend_object *obj = Z_OBJ(object->iterators[object->level].zobject); zend_function **cache = &object->iterators[object->level].haschildren; - zend_call_method_with_0_params(obj, ce, cache, "haschildren", &retval); + zend_call_method_with_0_params(obj, ce_scope, cache, "haschildren", &retval); } if (EG(exception)) { if (!(object->flags & RIT_CATCH_GET_CHILD)) { @@ -350,11 +350,11 @@ static void spl_recursive_it_move_forward_ex(spl_recursive_it_object *object, zv if (object->callGetChildren) { zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->callGetChildren, "callGetChildren", &child); } else { - zend_class_entry *ce = object->iterators[object->level].ce; + zend_class_entry *ce_scope = object->iterators[object->level].ce; zend_object *obj = Z_OBJ(object->iterators[object->level].zobject); zend_function **cache = &object->iterators[object->level].getchildren; - zend_call_method_with_0_params(obj, ce, cache, "getchildren", &child); + zend_call_method_with_0_params(obj, ce_scope, cache, "getchildren", &child); } if (EG(exception)) { @@ -2809,20 +2809,20 @@ PHP_METHOD(AppendIterator, __construct) /* {{{ Append an iterator */ PHP_METHOD(AppendIterator, append) { - spl_dual_it_object *intern; - zval *it; + spl_dual_it_object *intern; + zval *iterator; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &it, zend_ce_iterator) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &iterator, zend_ce_iterator) == FAILURE) { RETURN_THROWS(); } SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS); if (intern->u.append.iterator->funcs->valid(intern->u.append.iterator) == SUCCESS && spl_dual_it_valid(intern) != SUCCESS) { - spl_array_iterator_append(&intern->u.append.zarrayit, it); + spl_array_iterator_append(&intern->u.append.zarrayit, iterator); intern->u.append.iterator->funcs->move_forward(intern->u.append.iterator); }else{ - spl_array_iterator_append(&intern->u.append.zarrayit, it); + spl_array_iterator_append(&intern->u.append.zarrayit, iterator); } if (!intern->inner.iterator || spl_dual_it_valid(intern) != SUCCESS) { @@ -2831,7 +2831,7 @@ PHP_METHOD(AppendIterator, append) } do { spl_append_it_next_iterator(intern); - } while (Z_OBJ(intern->inner.zobject) != Z_OBJ_P(it)); + } while (Z_OBJ(intern->inner.zobject) != Z_OBJ_P(iterator)); spl_append_it_fetch(intern); } } /* }}} */ diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 5f5fbca70d4f3..0043f24d8c73c 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -339,9 +339,9 @@ static inline HashTable* spl_object_storage_debug_info(zend_object *obj) /* {{{ /* Incrementing the refcount of obj and inf would confuse the garbage collector. * Prefer to null the destructor */ Z_ARRVAL_P(&tmp)->pDestructor = NULL; - zval obj; - ZVAL_OBJ(&obj, element->obj); - add_assoc_zval_ex(&tmp, "obj", sizeof("obj") - 1, &obj); + zval element_obj; + ZVAL_OBJ(&element_obj, element->obj); + add_assoc_zval_ex(&tmp, "obj", sizeof("obj") - 1, &element_obj); add_assoc_zval_ex(&tmp, "inf", sizeof("inf") - 1, &element->inf); zend_hash_next_index_insert(Z_ARRVAL(storage), &tmp); } ZEND_HASH_FOREACH_END(); diff --git a/ext/standard/array.c b/ext/standard/array.c index 8f6418b032731..de6c7ec44445c 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4209,10 +4209,10 @@ static zend_always_inline void php_array_replace_wrapper(INTERNAL_FUNCTION_PARAM for (i = 0; i < argc; i++) { - zval *arg = args + i; + zval *check_arg = args + i; - if (Z_TYPE_P(arg) != IS_ARRAY) { - zend_argument_type_error(i + 1, "must be of type array, %s given", zend_zval_value_name(arg)); + if (Z_TYPE_P(check_arg) != IS_ARRAY) { + zend_argument_type_error(i + 1, "must be of type array, %s given", zend_zval_value_name(check_arg)); RETURN_THROWS(); } } @@ -4264,13 +4264,13 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET } for (i = 0; i < argc; i++) { - zval *arg = args + i; + zval *check_arg = args + i; - if (Z_TYPE_P(arg) != IS_ARRAY) { - zend_argument_type_error(i + 1, "must be of type array, %s given", zend_zval_value_name(arg)); + if (Z_TYPE_P(check_arg) != IS_ARRAY) { + zend_argument_type_error(i + 1, "must be of type array, %s given", zend_zval_value_name(check_arg)); RETURN_THROWS(); } - count += zend_hash_num_elements(Z_ARRVAL_P(arg)); + count += zend_hash_num_elements(Z_ARRVAL_P(check_arg)); } if (argc == 2) { @@ -4674,8 +4674,8 @@ PHP_FUNCTION(array_column) continue; } - zval rv; - zval *keyval = array_column_fetch_prop(data, index_str, index_long, cache_slot_index, &rv); + zval ignored_rv; + zval *keyval = array_column_fetch_prop(data, index_str, index_long, cache_slot_index, &ignored_rv); if (keyval) { array_set_zval_key(Z_ARRVAL_P(return_value), keyval, colval); zval_ptr_dtor(colval); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index dbbf9896f2b73..33d90abbe7283 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1752,13 +1752,13 @@ PHPAPI bool append_user_shutdown_function(php_shutdown_function_entry *shutdown_ } /* }}} */ -ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini) /* {{{ */ +ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini_ptr) /* {{{ */ { - syntax_highlighter_ini->highlight_comment = INI_STR("highlight.comment"); - syntax_highlighter_ini->highlight_default = INI_STR("highlight.default"); - syntax_highlighter_ini->highlight_html = INI_STR("highlight.html"); - syntax_highlighter_ini->highlight_keyword = INI_STR("highlight.keyword"); - syntax_highlighter_ini->highlight_string = INI_STR("highlight.string"); + syntax_highlighter_ini_ptr->highlight_comment = INI_STR("highlight.comment"); + syntax_highlighter_ini_ptr->highlight_default = INI_STR("highlight.default"); + syntax_highlighter_ini_ptr->highlight_html = INI_STR("highlight.html"); + syntax_highlighter_ini_ptr->highlight_keyword = INI_STR("highlight.keyword"); + syntax_highlighter_ini_ptr->highlight_string = INI_STR("highlight.string"); } /* }}} */ @@ -1767,8 +1767,7 @@ PHP_FUNCTION(highlight_file) { char *filename; size_t filename_len; - int ret; - zend_syntax_highlighter_ini syntax_highlighter_ini; + zend_syntax_highlighter_ini default_syntax_highlighter_ini; bool i = 0; ZEND_PARSE_PARAMETERS_START(1, 2) @@ -1785,9 +1784,9 @@ PHP_FUNCTION(highlight_file) php_output_start_default(); } - php_get_highlight_struct(&syntax_highlighter_ini); + php_get_highlight_struct(&default_syntax_highlighter_ini); - ret = highlight_file(filename, &syntax_highlighter_ini); + zend_result ret = highlight_file(filename, &default_syntax_highlighter_ini); if (ret == FAILURE) { if (i) { @@ -1842,7 +1841,7 @@ PHP_FUNCTION(php_strip_whitespace) PHP_FUNCTION(highlight_string) { zend_string *str; - zend_syntax_highlighter_ini syntax_highlighter_ini; + zend_syntax_highlighter_ini default_syntax_highlighter_ini; char *hicompiled_string_description; bool i = 0; int old_error_reporting = EG(error_reporting); @@ -1859,11 +1858,11 @@ PHP_FUNCTION(highlight_string) EG(error_reporting) = E_ERROR; - php_get_highlight_struct(&syntax_highlighter_ini); + php_get_highlight_struct(&default_syntax_highlighter_ini); hicompiled_string_description = zend_make_compiled_string_description("highlighted code"); - highlight_string(str, &syntax_highlighter_ini, hicompiled_string_description); + highlight_string(str, &default_syntax_highlighter_ini, hicompiled_string_description); efree(hicompiled_string_description); EG(error_reporting) = old_error_reporting; diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 1985040f70ad2..b2b6ab8e6c1ac 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -40,7 +40,7 @@ PHP_RINIT_FUNCTION(basic); PHP_RSHUTDOWN_FUNCTION(basic); PHP_MINFO_FUNCTION(basic); -ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini); +ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini_ptr); PHP_MINIT_FUNCTION(user_filters); PHP_RSHUTDOWN_FUNCTION(user_filters); diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 04477129e3599..b51356916de4b 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -576,10 +576,10 @@ static uint8_t *php_parserr(uint8_t *cp, uint8_t *end, querybuf *answer, int typ { int l1 = 0, l2 = 0; zval entries; - zend_string *tp; + zend_string *tp_str; add_assoc_string(subarray, "type", "TXT"); - tp = zend_string_alloc(dlen, 0); + tp_str = zend_string_alloc(dlen, 0); array_init(&entries); @@ -590,17 +590,17 @@ static uint8_t *php_parserr(uint8_t *cp, uint8_t *end, querybuf *answer, int typ n = dlen - (l1 + 1); } if (n) { - memcpy(ZSTR_VAL(tp) + l2 , cp + l1 + 1, n); + memcpy(ZSTR_VAL(tp_str) + l2 , cp + l1 + 1, n); add_next_index_stringl(&entries, (char *) cp + l1 + 1, n); } l1 = l1 + n + 1; l2 = l2 + n; } - ZSTR_VAL(tp)[l2] = '\0'; - ZSTR_LEN(tp) = l2; + ZSTR_VAL(tp_str)[l2] = '\0'; + ZSTR_LEN(tp_str) = l2; cp += dlen; - add_assoc_str(subarray, "txt", tp); + add_assoc_str(subarray, "txt", tp_str); add_assoc_zval(subarray, "entries", &entries); } break; diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c index d4688dcb9c136..a55d236884d58 100644 --- a/ext/standard/levenshtein.c +++ b/ext/standard/levenshtein.c @@ -20,7 +20,7 @@ * reference implementation, only optimized for memory usage, not speed */ static zend_long reference_levdist(const zend_string *string1, const zend_string *string2, zend_long cost_ins, zend_long cost_rep, zend_long cost_del ) { - zend_long *p1, *p2, *tmp; + zend_long *p1, *p2; zend_long c0, c1, c2; size_t i1, i2; @@ -61,7 +61,7 @@ static zend_long reference_levdist(const zend_string *string1, const zend_string } p2[i2 + 1] = c0; } - tmp = p1; + zend_long *tmp = p1; p1 = p2; p2 = tmp; } diff --git a/ext/standard/var.c b/ext/standard/var.c index 1c2b0eb164a1c..292b178a67bdd 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -103,12 +103,7 @@ static const char *php_var_dump_object_prefix(zend_object *obj) { PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */ { HashTable *myht; - zend_string *class_name; int is_ref = 0; - zend_ulong num; - zend_string *key; - zval *val; - uint32_t count; if (level > 1) { php_printf("%*c", level - 1, ' '); @@ -136,7 +131,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */ PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc)); PUTS("\"\n"); break; - case IS_ARRAY: + case IS_ARRAY: { myht = Z_ARRVAL_P(struc); if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) { if (GC_IS_RECURSIVE(myht)) { @@ -146,8 +141,11 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */ GC_ADDREF(myht); GC_PROTECT_RECURSION(myht); } - count = zend_hash_num_elements(myht); + uint32_t count = zend_hash_num_elements(myht); php_printf("%sarray(%d) {\n", COMMON, count); + zend_ulong num; + zend_string *key; + zval *val; ZEND_HASH_FOREACH_KEY_VAL(myht, num, key, val) { php_array_element_dump(val, num, key, level); } ZEND_HASH_FOREACH_END(); @@ -160,6 +158,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */ } PUTS("}\n"); break; + } case IS_OBJECT: { zend_class_entry *ce = Z_OBJCE_P(struc); if (ce->ce_flags & ZEND_ACC_ENUM) { @@ -176,7 +175,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */ ZEND_GUARD_OR_GC_PROTECT_RECURSION(guard, DEBUG, zobj); myht = zend_get_properties_for(struc, ZEND_PROP_PURPOSE_DEBUG); - class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc)); + zend_string *class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc)); const char *prefix = php_var_dump_object_prefix(Z_OBJ_P(struc)); php_printf("%s%sobject(%s)#%d (%d) {\n", COMMON, prefix, ZSTR_VAL(class_name), Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0); @@ -616,8 +615,8 @@ PHPAPI zend_result php_var_export_ex(zval *struc, int level, smart_str *buf) /* smart_str_appendc(buf, '\\'); smart_str_append(buf, ce->name); if (is_enum) { - zend_object *zobj = Z_OBJ_P(struc); - zval *case_name_zval = zend_enum_fetch_case_name(zobj); + zend_object *enum_obj = Z_OBJ_P(struc); + zval *case_name_zval = zend_enum_fetch_case_name(enum_obj); smart_str_appendl(buf, "::", 2); smart_str_append(buf, Z_STR_P(case_name_zval)); } else { @@ -787,10 +786,10 @@ static inline void php_var_serialize_long(smart_str *buf, zend_long val) /* {{{ } /* }}} */ -static inline void php_var_serialize_string(smart_str *buf, char *str, size_t len) /* {{{ */ +static inline void php_var_serialize_string(smart_str *buf, const char *str, size_t len) /* {{{ */ { char b[32]; - char *s = zend_print_long_to_buf(b + sizeof(b) - 1, len); + char *s = zend_print_ulong_to_buf(b + sizeof(b) - 1, len); size_t l = b + sizeof(b) - 1 - s; char *res = smart_str_extend(buf, 2 + l + 2 + len + 2); res = zend_mempcpy(res, "s:", 2); @@ -808,7 +807,7 @@ static inline bool php_var_serialize_class_name(smart_str *buf, zval *struc) /* PHP_SET_CLASS_ATTRIBUTES(struc); size_t class_name_len = ZSTR_LEN(class_name); - char *s = zend_print_long_to_buf(b + sizeof(b) - 1, class_name_len); + char *s = zend_print_ulong_to_buf(b + sizeof(b) - 1, class_name_len); size_t l = b + sizeof(b) - 1 - s; char *res = smart_str_extend(buf, 2 + l + 2 + class_name_len + 2); res = zend_mempcpy(res, "O:", 2); diff --git a/main/SAPI.c b/main/SAPI.c index 866b44c3eac7d..87242fcbe24dc 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -49,16 +49,16 @@ static void _type_dtor(zval *zv) free(Z_PTR_P(zv)); } -static void sapi_globals_ctor(sapi_globals_struct *sapi_globals) +static void sapi_globals_ctor(sapi_globals_struct *sapi_globals_ptr) { - memset(sapi_globals, 0, sizeof(*sapi_globals)); - zend_hash_init(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1); + memset(sapi_globals_ptr, 0, sizeof(*sapi_globals_ptr)); + zend_hash_init(&sapi_globals_ptr->known_post_content_types, 8, NULL, _type_dtor, 1); php_setup_sapi_content_types(); } -static void sapi_globals_dtor(sapi_globals_struct *sapi_globals) +static void sapi_globals_dtor(sapi_globals_struct *sapi_globals_ptr) { - zend_hash_destroy(&sapi_globals->known_post_content_types); + zend_hash_destroy(&sapi_globals_ptr->known_post_content_types); } /* True globals (no need for thread safety) */ diff --git a/main/main.c b/main/main.c index 0b38f303c58fc..409eaf09c6e51 100644 --- a/main/main.c +++ b/main/main.c @@ -107,11 +107,11 @@ PHPAPI unsigned int php_version_id(void) return PHP_VERSION_ID; } -PHPAPI char *php_get_version(sapi_module_struct *sapi_module) +PHPAPI char *php_get_version(const sapi_module_struct *sapi_module_ptr) { char *version_info; spprintf(&version_info, 0, "PHP %s (%s) (built: %s %s) (%s)\nCopyright (c) The PHP Group\n%s%s", - PHP_VERSION, sapi_module->name, __DATE__, __TIME__, + PHP_VERSION, sapi_module_ptr->name, __DATE__, __TIME__, #ifdef ZTS "ZTS" #else @@ -141,9 +141,9 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module) return version_info; } -PHPAPI void php_print_version(sapi_module_struct *sapi_module) +PHPAPI void php_print_version(const sapi_module_struct *sapi_module_ptr) { - char *version_info = php_get_version(sapi_module); + char *version_info = php_get_version(sapi_module_ptr); php_printf("%s", version_info); efree(version_info); } @@ -2025,20 +2025,20 @@ static void core_globals_ctor(php_core_globals *core_globals) #endif /* {{{ core_globals_dtor */ -static void core_globals_dtor(php_core_globals *core_globals) +static void core_globals_dtor(php_core_globals *core_globals_ptr) { /* These should have been freed earlier. */ - ZEND_ASSERT(!core_globals->last_error_message); - ZEND_ASSERT(!core_globals->last_error_file); + ZEND_ASSERT(!core_globals_ptr->last_error_message); + ZEND_ASSERT(!core_globals_ptr->last_error_file); - if (core_globals->disable_classes) { - free(core_globals->disable_classes); + if (core_globals_ptr->disable_classes) { + free(core_globals_ptr->disable_classes); } - if (core_globals->php_binary) { - free(core_globals->php_binary); + if (core_globals_ptr->php_binary) { + free(core_globals_ptr->php_binary); } - php_shutdown_ticks(core_globals); + php_shutdown_ticks(core_globals_ptr); } /* }}} */ @@ -2412,7 +2412,7 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi /* }}} */ /* {{{ php_module_shutdown_wrapper */ -int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals) +int php_module_shutdown_wrapper(sapi_module_struct *sapi_module_ptr) { php_module_shutdown(); return SUCCESS; diff --git a/main/php_main.h b/main/php_main.h index 889fcf48501f0..032fda85ea357 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -39,14 +39,14 @@ PHPAPI unsigned int php_version_id(void); /* Prints the PHP version string for the -v option. It's in main/ so that * it can be shared between SAPIs. */ -PHPAPI char *php_get_version(sapi_module_struct *sapi_module); -PHPAPI void php_print_version(sapi_module_struct *sapi_module); +PHPAPI char *php_get_version(const sapi_module_struct *sapi_module_ptr); +PHPAPI void php_print_version(const sapi_module_struct *sapi_module_ptr); PHPAPI zend_result php_request_startup(void); PHPAPI void php_request_shutdown(void *dummy); PHPAPI zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_module); PHPAPI void php_module_shutdown(void); -PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals); +PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_module_ptr); PHPAPI zend_result php_register_extensions(zend_module_entry * const * ptr, int count); diff --git a/main/php_ticks.c b/main/php_ticks.c index 70201ddecd08d..6220f477ac338 100644 --- a/main/php_ticks.c +++ b/main/php_ticks.c @@ -34,9 +34,9 @@ void php_deactivate_ticks(void) zend_llist_clean(&PG(tick_functions)); } -void php_shutdown_ticks(php_core_globals *core_globals) +void php_shutdown_ticks(php_core_globals *php_core_globals_ptr) { - zend_llist_destroy(&core_globals->tick_functions); + zend_llist_destroy(&php_core_globals_ptr->tick_functions); } static int php_compare_tick_functions(void *elem1, void *elem2) diff --git a/main/php_ticks.h b/main/php_ticks.h index 270ea5348fd2a..6a3f92e6ffba7 100644 --- a/main/php_ticks.h +++ b/main/php_ticks.h @@ -19,7 +19,7 @@ int php_startup_ticks(void); void php_deactivate_ticks(void); -void php_shutdown_ticks(php_core_globals *core_globals); +void php_shutdown_ticks(php_core_globals *php_core_globals_ptr); void php_run_ticks(int count); BEGIN_EXTERN_C() diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 7b0813c3db623..3af394100aaf2 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -746,7 +746,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void #ifdef HAVE_MMAP { php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam; - int prot, flags; + int prot, range_flags; switch (value) { case PHP_STREAM_MMAP_SUPPORTED: @@ -766,24 +766,24 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void switch (range->mode) { case PHP_STREAM_MAP_MODE_READONLY: prot = PROT_READ; - flags = MAP_PRIVATE; + range_flags = MAP_PRIVATE; break; case PHP_STREAM_MAP_MODE_READWRITE: prot = PROT_READ | PROT_WRITE; - flags = MAP_PRIVATE; + range_flags = MAP_PRIVATE; break; case PHP_STREAM_MAP_MODE_SHARED_READONLY: prot = PROT_READ; - flags = MAP_SHARED; + range_flags = MAP_SHARED; break; case PHP_STREAM_MAP_MODE_SHARED_READWRITE: prot = PROT_READ | PROT_WRITE; - flags = MAP_SHARED; + range_flags = MAP_SHARED; break; default: return PHP_STREAM_OPTION_RETURN_ERR; } - range->mapped = (char*)mmap(NULL, range->length, prot, flags, fd, range->offset); + range->mapped = (char*)mmap(NULL, range->length, prot, range_flags, fd, range->offset); if (range->mapped == (char*)MAP_FAILED) { range->mapped = NULL; return PHP_STREAM_OPTION_RETURN_ERR; diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 0e7b3009c6024..5ede45e766674 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -968,9 +968,9 @@ static int sapi_cgi_deactivate(void) return SUCCESS; } -static int php_cgi_startup(sapi_module_struct *sapi_module) +static int php_cgi_startup(sapi_module_struct *sapi_module_ptr) { - return php_module_startup(sapi_module, &cgi_module_entry); + return php_module_startup(sapi_module_ptr, &cgi_module_entry); } /* {{{ sapi_module_struct cgi_sapi_module */ @@ -1518,23 +1518,23 @@ PHP_INI_BEGIN() PHP_INI_END() /* {{{ php_cgi_globals_ctor */ -static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals) +static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals_ptr) { #if defined(ZTS) && defined(PHP_WIN32) ZEND_TSRMLS_CACHE_UPDATE(); #endif - php_cgi_globals->rfc2616_headers = 0; - php_cgi_globals->nph = 0; - php_cgi_globals->check_shebang_line = 1; - php_cgi_globals->force_redirect = 1; - php_cgi_globals->redirect_status_env = NULL; - php_cgi_globals->fix_pathinfo = 1; - php_cgi_globals->discard_path = 0; - php_cgi_globals->fcgi_logging = 1; + php_cgi_globals_ptr->rfc2616_headers = 0; + php_cgi_globals_ptr->nph = 0; + php_cgi_globals_ptr->check_shebang_line = 1; + php_cgi_globals_ptr->force_redirect = 1; + php_cgi_globals_ptr->redirect_status_env = NULL; + php_cgi_globals_ptr->fix_pathinfo = 1; + php_cgi_globals_ptr->discard_path = 0; + php_cgi_globals_ptr->fcgi_logging = 1; #ifdef PHP_WIN32 - php_cgi_globals->impersonate = 0; + php_cgi_globals_ptr->impersonate = 0; #endif - zend_hash_init(&php_cgi_globals->user_config_cache, 8, NULL, user_config_cache_entry_dtor, 1); + zend_hash_init(&php_cgi_globals_ptr->user_config_cache, 8, NULL, user_config_cache_entry_dtor, 1); } /* }}} */ @@ -2548,11 +2548,11 @@ consult the installation file that came with this distribution, or visit \n\ break; case PHP_MODE_HIGHLIGHT: { - zend_syntax_highlighter_ini syntax_highlighter_ini; + zend_syntax_highlighter_ini default_syntax_highlighter_ini; if (open_file_for_scanning(&file_handle) == SUCCESS) { - php_get_highlight_struct(&syntax_highlighter_ini); - zend_highlight(&syntax_highlighter_ini); + php_get_highlight_struct(&default_syntax_highlighter_ini); + zend_highlight(&default_syntax_highlighter_ini); } } break; diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 9444f3d6253aa..2731a1f93738a 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -392,9 +392,9 @@ static void sapi_cli_send_header(sapi_header_struct *sapi_header, void *server_c } /* }}} */ -static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */ +static int php_cli_startup(sapi_module_struct *sapi_module_ptr) /* {{{ */ { - return php_module_startup(sapi_module, NULL); + return php_module_startup(sapi_module_ptr, NULL); } /* }}} */ @@ -951,11 +951,11 @@ static int do_cli(int argc, char **argv) /* {{{ */ break; case PHP_CLI_MODE_HIGHLIGHT: { - zend_syntax_highlighter_ini syntax_highlighter_ini; + zend_syntax_highlighter_ini default_syntax_highlighter_ini; if (open_file_for_scanning(&file_handle) == SUCCESS) { - php_get_highlight_struct(&syntax_highlighter_ini); - zend_highlight(&syntax_highlighter_ini); + php_get_highlight_struct(&default_syntax_highlighter_ini); + zend_highlight(&default_syntax_highlighter_ini); } goto out; } @@ -1155,7 +1155,7 @@ int main(int argc, char *argv[]) char *ini_path_override = NULL; struct php_ini_builder ini_builder; int ini_ignore = 0; - sapi_module_struct *sapi_module = &cli_sapi_module; + sapi_module_struct *sapi_module_ptr = &cli_sapi_module; /* * Do not move this initialization. It needs to happen before argv is used @@ -1234,7 +1234,7 @@ int main(int argc, char *argv[]) break; #ifndef PHP_CLI_WIN32_NO_CONSOLE case 'S': - sapi_module = &cli_server_sapi_module; + sapi_module_ptr = &cli_server_sapi_module; cli_server_sapi_module.additional_functions = server_additional_functions; break; #endif @@ -1247,7 +1247,7 @@ int main(int argc, char *argv[]) exit_status = 1; goto out; case 'i': case 'v': case 'm': - sapi_module = &cli_sapi_module; + sapi_module_ptr = &cli_sapi_module; goto exit_loop; case 'e': /* enable extended info output */ use_extended_info = 1; @@ -1256,25 +1256,25 @@ int main(int argc, char *argv[]) } exit_loop: - sapi_module->ini_defaults = sapi_cli_ini_defaults; - sapi_module->php_ini_path_override = ini_path_override; - sapi_module->phpinfo_as_text = 1; - sapi_module->php_ini_ignore_cwd = 1; - sapi_startup(sapi_module); + sapi_module_ptr->ini_defaults = sapi_cli_ini_defaults; + sapi_module_ptr->php_ini_path_override = ini_path_override; + sapi_module_ptr->phpinfo_as_text = 1; + sapi_module_ptr->php_ini_ignore_cwd = 1; + sapi_startup(sapi_module_ptr); sapi_started = 1; - sapi_module->php_ini_ignore = ini_ignore; + sapi_module_ptr->php_ini_ignore = ini_ignore; - sapi_module->executable_location = argv[0]; + sapi_module_ptr->executable_location = argv[0]; - if (sapi_module == &cli_sapi_module) { + if (sapi_module_ptr == &cli_sapi_module) { php_ini_builder_prepend_literal(&ini_builder, HARDCODED_INI); } - sapi_module->ini_entries = php_ini_builder_finish(&ini_builder); + sapi_module_ptr->ini_entries = php_ini_builder_finish(&ini_builder); /* startup after we get the above ini override so we get things right */ - if (sapi_module->startup(sapi_module) == FAILURE) { + if (sapi_module_ptr->startup(sapi_module_ptr) == FAILURE) { /* there is no way to see if we must call zend_ini_deactivate() * since we cannot check if EG(ini_directives) has been initialized * because the executor's constructor does not set initialize it. @@ -1305,7 +1305,7 @@ int main(int argc, char *argv[]) zend_first_try { #ifndef PHP_CLI_WIN32_NO_CONSOLE - if (sapi_module == &cli_sapi_module) { + if (sapi_module_ptr == &cli_sapi_module) { #endif exit_status = do_cli(argc, argv); #ifndef PHP_CLI_WIN32_NO_CONSOLE diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index bcf5af320d73b..fc2e282995644 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -510,9 +510,9 @@ const zend_function_entry server_additional_functions[] = { PHP_FE_END }; -static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */ +static int sapi_cli_server_startup(sapi_module_struct *sapi_module_ptr) /* {{{ */ { - return php_module_startup(sapi_module, &cli_server_module_entry); + return php_module_startup(sapi_module_ptr, &cli_server_module_entry); } /* }}} */ static size_t sapi_cli_server_ub_write(const char *str, size_t str_length) /* {{{ */ @@ -2353,14 +2353,14 @@ static zend_result php_cli_server_dispatch(php_cli_server *server, php_cli_serve } /* }}} */ -static void php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_server_ext_mime_type_pair *mime_type_map) /* {{{ */ +static void php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_server_ext_mime_type_pair *mime_type_map_ptr) /* {{{ */ { const php_cli_server_ext_mime_type_pair *pair; zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1); GC_MAKE_PERSISTENT_LOCAL(&server->extension_mime_types); - for (pair = mime_type_map; pair->ext; pair++) { + for (pair = mime_type_map_ptr; pair->ext; pair++) { size_t ext_len = strlen(pair->ext); zend_hash_str_add_ptr(&server->extension_mime_types, pair->ext, ext_len, (void*)pair->mime_type); } @@ -2396,7 +2396,7 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */ do { if (waitpid(php_cli_server_workers[php_cli_server_worker], &php_cli_server_worker_status, - 0) == FAILURE) { + 0) == (pid_t) -1) { /* an extremely bad thing happened */ break; } diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 76b3c7f725951..f298a8029faea 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1124,8 +1124,8 @@ int main(int argc, char **argv) /* {{{ */ sapi_module_struct *phpdbg = &phpdbg_sapi_module; char *sapi_name; struct php_ini_builder ini_builder; - char **zend_extensions = NULL; - zend_ulong zend_extensions_len = 0L; + char **zend_extensions_list = NULL; + size_t zend_extensions_len = 0; bool ini_ignore; char *ini_override; char *exec = NULL; @@ -1177,8 +1177,6 @@ int main(int argc, char **argv) /* {{{ */ php_ini_builder_init(&ini_builder); ini_ignore = 0; ini_override = NULL; - zend_extensions = NULL; - zend_extensions_len = 0L; init_file = NULL; init_file_len = 0; init_file_default = 1; @@ -1216,10 +1214,12 @@ int main(int argc, char **argv) /* {{{ */ case 'z': zend_extensions_len++; - if (zend_extensions) { - zend_extensions = realloc(zend_extensions, sizeof(char*) * zend_extensions_len); - } else zend_extensions = malloc(sizeof(char*) * zend_extensions_len); - zend_extensions[zend_extensions_len-1] = strdup(php_optarg); + if (zend_extensions_list) { + zend_extensions_list = realloc(zend_extensions_list, sizeof(char*) * zend_extensions_len); + } else { + zend_extensions_list = malloc(sizeof(char*) * zend_extensions_len); + } + zend_extensions_list[zend_extensions_len-1] = strdup(php_optarg); break; /* begin phpdbg options */ @@ -1316,19 +1316,19 @@ int main(int argc, char **argv) /* {{{ */ php_ini_builder_prepend_literal(&ini_builder, phpdbg_ini_hardcoded); if (zend_extensions_len) { - zend_ulong zend_extension = 0L; + size_t zend_extension_index = 0; - while (zend_extension < zend_extensions_len) { - const char *ze = zend_extensions[zend_extension]; + while (zend_extension_index < zend_extensions_len) { + const char *ze = zend_extensions_list[zend_extension_index]; size_t ze_len = strlen(ze); php_ini_builder_unquoted(&ini_builder, "zend_extension", strlen("zend_extension"), ze, ze_len); - free(zend_extensions[zend_extension]); - zend_extension++; + free(zend_extensions_list[zend_extension_index]); + zend_extension_index++; } - free(zend_extensions); + free(zend_extensions_list); } phpdbg->ini_entries = php_ini_builder_finish(&ini_builder); diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 41fe8faecf99b..e5f6413b060ed 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -193,8 +193,10 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input); #define phpdbg_try_access \ { \ + ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \ JMP_BUF *__orig_bailout = PHPDBG_G(sigsegv_bailout); \ JMP_BUF __bailout; \ + ZEND_DIAGNOSTIC_IGNORED_END \ \ PHPDBG_G(sigsegv_bailout) = &__bailout; \ if (SETJMP(__bailout) == 0) { diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 90f8ed7bb1295..0a94adf21305a 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -1510,28 +1510,28 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type) /* {{{ */ phpdbg_out(SEPARATE "\n"); phpdbg_out("Opline Breakpoints:\n"); ZEND_HASH_MAP_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], brake) { - const char *type; + const char *str_type; switch (brake->type) { case PHPDBG_BREAK_METHOD_OPLINE: - type = "method"; + str_type = "method"; goto print_opline; case PHPDBG_BREAK_FUNCTION_OPLINE: - type = "function"; + str_type = "function"; goto print_opline; case PHPDBG_BREAK_FILE_OPLINE: - type = "method"; + str_type = "method"; print_opline: { if (brake->type == PHPDBG_BREAK_METHOD_OPLINE) { - type = "method"; + str_type = "method"; } else if (brake->type == PHPDBG_BREAK_FUNCTION_OPLINE) { - type = "function"; + str_type = "function"; } else if (brake->type == PHPDBG_BREAK_FILE_OPLINE) { - type = "file"; + str_type = "file"; } phpdbg_writeln("#%d\t\t#"ZEND_ULONG_FMT"\t\t(%s breakpoint)%s", - brake->id, brake->opline, type, + brake->id, brake->opline, str_type, ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : ""); } break; diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index 10a06c1310d7e..4478dca0516ba 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -310,9 +310,9 @@ int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context) { # if defined(__GNUC__) && !defined(__clang__) __attribute__((no_sanitize_address)) # endif -void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals) { +void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals_ptr) { pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); - zend_phpdbg_globals *globals = (zend_phpdbg_globals *) phpdbg_globals; + zend_phpdbg_globals *globals = (zend_phpdbg_globals *) phpdbg_globals_ptr; struct uffd_msg fault_msg = {0}; while (read(globals->watch_userfaultfd, &fault_msg, sizeof(fault_msg)) == sizeof(fault_msg)) {