From: Dmitry Stogov Date: Tue, 21 Jun 2016 13:55:17 +0000 (+0300) Subject: Fixed compilation warnings X-Git-Tag: php-7.1.0alpha2~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebb99a1a3a2ec9216d95c63b267ae0f66074f4de;p=php Fixed compilation warnings --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 0de75c005c..ae52921ba6 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2892,7 +2892,7 @@ static int zend_is_callable_check_class(zend_string *name, zend_class_entry *sco *strict_class = 1; ret = 1; } else { - if (error) zend_spprintf(error, 0, "class '%.*s' not found", name_len, ZSTR_VAL(name)); + if (error) zend_spprintf(error, 0, "class '%.*s' not found", (int)name_len, ZSTR_VAL(name)); } ZSTR_ALLOCA_FREE(lcname, use_heap); return ret; diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 76664c01ce..76f1952f93 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -280,9 +280,9 @@ struct _zend_mm_chunk { zend_mm_heap *heap; zend_mm_chunk *next; zend_mm_chunk *prev; - int free_pages; /* number of free pages */ - int free_tail; /* number of free pages at the end of chunk */ - int num; + uint32_t free_pages; /* number of free pages */ + uint32_t free_tail; /* number of free pages at the end of chunk */ + uint32_t num; char reserve[64 - (sizeof(void*) * 3 + sizeof(int) * 3)]; zend_mm_heap heap_slot; /* used only in main chunk */ zend_mm_page_map free_map; /* 512 bits or 64 bytes */ @@ -318,17 +318,17 @@ struct _zend_mm_huge_list { ((void*)(((zend_mm_page*)(chunk)) + (page_num))) #define _BIN_DATA_SIZE(num, size, elements, pages, x, y) size, -static const unsigned int bin_data_size[] = { +static const uint32_t bin_data_size[] = { ZEND_MM_BINS_INFO(_BIN_DATA_SIZE, x, y) }; #define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y) elements, -static const int bin_elements[] = { +static const uint32_t bin_elements[] = { ZEND_MM_BINS_INFO(_BIN_DATA_ELEMENTS, x, y) }; #define _BIN_DATA_PAGES(num, size, elements, pages, x, y) pages, -static const int bin_pages[] = { +static const uint32_t bin_pages[] = { ZEND_MM_BINS_INFO(_BIN_DATA_PAGES, x, y) }; @@ -844,13 +844,13 @@ static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t /**************/ #if ZEND_DEBUG -static void *zend_mm_alloc_pages(zend_mm_heap *heap, int pages_count, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) +static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) #else -static void *zend_mm_alloc_pages(zend_mm_heap *heap, int pages_count ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) +static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) #endif { zend_mm_chunk *chunk = heap->main_chunk; - int page_num, len; + uint32_t page_num, len; while (1) { if (UNEXPECTED(chunk->free_pages < pages_count)) { @@ -906,11 +906,11 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, int pages_count ZEND_FILE_L } else { /* Best-Fit Search */ int best = -1; - int best_len = ZEND_MM_PAGES; - int free_tail = chunk->free_tail; + uint32_t best_len = ZEND_MM_PAGES; + uint32_t free_tail = chunk->free_tail; zend_mm_bitset *bitset = chunk->free_map; zend_mm_bitset tmp = *(bitset++); - int i = 0; + uint32_t i = 0; while (1) { /* skip allocated blocks */ @@ -1085,7 +1085,7 @@ static zend_always_inline void zend_mm_delete_chunk(zend_mm_heap *heap, zend_mm_ } } -static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm_chunk *chunk, int page_num, int pages_count, int free_chunk) +static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm_chunk *chunk, uint32_t page_num, uint32_t pages_count, int free_chunk) { chunk->free_pages += pages_count; zend_mm_bitset_reset_range(chunk->free_map, page_num, pages_count); @@ -1178,7 +1178,7 @@ static zend_always_inline int zend_mm_small_size_to_bin(size_t size) #define ZEND_MM_SMALL_SIZE_TO_BIN(size) zend_mm_small_size_to_bin(size) -static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, int bin_num ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) +static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, uint32_t bin_num ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) { zend_mm_chunk *chunk; int page_num; @@ -1199,7 +1199,8 @@ static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, int page_num = ZEND_MM_ALIGNED_OFFSET(bin, ZEND_MM_CHUNK_SIZE) / ZEND_MM_PAGE_SIZE; chunk->map[page_num] = ZEND_MM_SRUN(bin_num); if (bin_pages[bin_num] > 1) { - int i = 1; + uint32_t i = 1; + do { chunk->map[page_num+i] = ZEND_MM_NRUN(bin_num, i); i++; @@ -1836,7 +1837,8 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap) size_t page_offset; int page_num; zend_mm_page_info info; - int i, has_free_pages, free_counter; + uint32_t i, free_counter; + int has_free_pages; size_t collected = 0; #if ZEND_MM_CUSTOM @@ -1947,7 +1949,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap) /* Leak detection */ /******************/ -static zend_long zend_mm_find_leaks_small(zend_mm_chunk *p, int i, int j, zend_leak_info *leak) +static zend_long zend_mm_find_leaks_small(zend_mm_chunk *p, uint32_t i, uint32_t j, zend_leak_info *leak) { int empty = 1; zend_long count = 0; @@ -1974,7 +1976,7 @@ static zend_long zend_mm_find_leaks_small(zend_mm_chunk *p, int i, int j, zend_l return count; } -static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, int i, zend_leak_info *leak) +static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, uint32_t i, zend_leak_info *leak) { zend_long count = 0; @@ -2032,7 +2034,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap) zend_leak_info leak; zend_long repeated = 0; uint32_t total = 0; - int i, j; + uint32_t i, j; /* find leaked huge blocks and free them */ list = heap->huge_list; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7780066b27..93566eefff 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -665,7 +665,7 @@ static void zend_end_live_range(zend_op_array *op_array, uint32_t offset, uint32 { zend_live_range *range = op_array->live_range + offset; - if (range->start == end && offset == op_array->last_live_range - 1) { + if (range->start == end && offset == (uint32_t)op_array->last_live_range - 1) { op_array->last_live_range--; } else { range->end = end; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 302f4598dc..d05852e8f7 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -783,7 +783,7 @@ ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char zend_op *get_next_op(zend_op_array *op_array); void init_op(zend_op *op); -int get_next_op_number(zend_op_array *op_array); +uint32_t get_next_op_number(zend_op_array *op_array); ZEND_API int pass_two(zend_op_array *op_array); zend_brk_cont_element *get_next_brk_cont_element(void); ZEND_API zend_bool zend_is_compiling(void); diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index ba4704fdd9..b7e6f37f71 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -158,7 +158,7 @@ ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulo #define ZEND_HASH_INDEX_FIND(_ht, _h, _ret, _not_found) do { \ if (EXPECTED((_ht)->u.flags & HASH_FLAG_PACKED)) { \ - if (EXPECTED((_h) < (_ht)->nNumUsed)) { \ + if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) { \ _ret = &_ht->arData[_h].val; \ if (UNEXPECTED(Z_TYPE_P(_ret) == IS_UNDEF)) { \ goto _not_found; \ diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c index 939e22bc26..f4aa710918 100644 --- a/Zend/zend_language_scanner.c +++ b/Zend/zend_language_scanner.c @@ -386,7 +386,7 @@ static const zend_encoding* zend_multibyte_detect_unicode(void) /* check if the NULL byte is after the __HALT_COMPILER(); */ pos2 = LANG_SCNG(script_org); - while (pos1 - pos2 >= sizeof("__HALT_COMPILER();")-1) { + while ((size_t)(pos1 - pos2) >= sizeof("__HALT_COMPILER();")-1) { pos2 = memchr(pos2, '_', pos1 - pos2); if (!pos2) break; pos2++; @@ -503,7 +503,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle) /* The shebang line was read, get the current position to obtain the buffer start */ if (CG(start_lineno) == 2 && file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp) { - if ((offset = ftell(file_handle->handle.fp)) == -1) { + if ((offset = ftell(file_handle->handle.fp)) == (size_t)-1) { offset = 0; } } @@ -524,7 +524,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle) SCNG(yy_in) = file_handle; SCNG(yy_start) = NULL; - if (size != -1) { + if (size != (size_t)-1) { if (CG(multibyte)) { SCNG(script_org) = (unsigned char*)buf; SCNG(script_org_size) = size; diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 122c6d4eda..f5f11b0c47 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -384,7 +384,7 @@ static const zend_encoding* zend_multibyte_detect_unicode(void) /* check if the NULL byte is after the __HALT_COMPILER(); */ pos2 = LANG_SCNG(script_org); - while (pos1 - pos2 >= sizeof("__HALT_COMPILER();")-1) { + while ((size_t)(pos1 - pos2) >= sizeof("__HALT_COMPILER();")-1) { pos2 = memchr(pos2, '_', pos1 - pos2); if (!pos2) break; pos2++; @@ -501,7 +501,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle) /* The shebang line was read, get the current position to obtain the buffer start */ if (CG(start_lineno) == 2 && file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp) { - if ((offset = ftell(file_handle->handle.fp)) == -1) { + if ((offset = ftell(file_handle->handle.fp)) == (size_t)-1) { offset = 0; } } @@ -522,7 +522,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle) SCNG(yy_in) = file_handle; SCNG(yy_start) = NULL; - if (size != -1) { + if (size != (size_t)-1) { if (CG(multibyte)) { SCNG(script_org) = (unsigned char*)buf; SCNG(script_org_size) = size; diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 4e7469edb9..bffe9e2d6e 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -465,7 +465,7 @@ zend_op *get_next_op(zend_op_array *op_array) return next_op; } -int get_next_op_number(zend_op_array *op_array) +uint32_t get_next_op_number(zend_op_array *op_array) { return op_array->last; } diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 40dcd3bb0d..1bbf49619a 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -172,10 +172,11 @@ ZEND_API void zend_signal_handler_unblock(void) static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context) { int errno_save = errno; - struct sigaction sa = {{0}}; + struct sigaction sa; sigset_t sigset; zend_signal_entry_t p_sig = SIGG(handlers)[signo-1]; + memset(&sa, 0, sizeof(sa)); if (p_sig.handler == SIG_DFL) { /* raise default handler */ if (sigaction(signo, NULL, &sa) == 0) { sa.sa_handler = SIG_DFL; @@ -209,9 +210,10 @@ static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context) * Register a signal handler that will be deferred in critical sections */ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact) { - struct sigaction sa = {{0}}; + struct sigaction sa; sigset_t sigset; + memset(&sa, 0, sizeof(sa)); if (oldact != NULL) { oldact->sa_flags = SIGG(handlers)[signo-1].flags; oldact->sa_handler = (void *) SIGG(handlers)[signo-1].handler; @@ -247,8 +249,9 @@ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigac * Register a signal handler that will be deferred in critical sections */ ZEND_API int zend_signal(int signo, void (*handler)(int)) { - struct sigaction sa = {{0}}; + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); sa.sa_flags = 0; sa.sa_handler = handler; sa.sa_mask = global_sigmask; @@ -263,8 +266,9 @@ ZEND_API int zend_signal(int signo, void (*handler)(int)) */ static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)) { - struct sigaction sa = {{0}}; + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); if (sigaction(signo, NULL, &sa) == 0) { if ((sa.sa_flags & SA_SIGINFO) && sa.sa_sigaction == handler) { return FAILURE; @@ -294,7 +298,7 @@ static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void * Install our signal handlers, per request */ void zend_signal_activate(void) { - int x; + size_t x; memcpy(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers)); @@ -312,8 +316,10 @@ void zend_signal_deactivate(void) { if (SIGG(check)) { - int x; - struct sigaction sa = {{0}}; + size_t x; + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); if (SIGG(depth) != 0) { zend_error(E_CORE_WARNING, "zend_signal: shutdown with non-zero blocking depth (%d)", SIGG(depth)); } @@ -353,8 +359,9 @@ static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals) void zend_signal_init(void) /* {{{ */ { int signo; - struct sigaction sa = {{0}}; + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); /* Save previously registered signal handlers into orig_handlers */ memset(&global_orig_handlers, 0, sizeof(global_orig_handlers)); for (signo = 1; signo < NSIG; ++signo) { diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index a524e64aa1..c69a265231 100644 --- a/Zend/zend_strtod.c +++ b/Zend/zend_strtod.c @@ -3615,7 +3615,7 @@ rv_alloc(int i) j = sizeof(ULong); for(k = 0; - sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; + sizeof(Bigint) - sizeof(ULong) - sizeof(int) + (size_t)j <= (size_t)i; j <<= 1) k++; r = (int*)Balloc(k); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index c8e9eb12a5..add7028c6d 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -7189,7 +7189,7 @@ ZEND_VM_HELPER(zend_dispatch_try_catch_finally_helper, ANY, ANY, uint32_t try_ca ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) { uint32_t throw_op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes; - uint32_t i, current_try_catch_offset = (uint32_t) -1; + int i, current_try_catch_offset = -1; { const zend_op *exc_opline = EG(opline_before_exception); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 837cab2b56..19d06bdd17 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1762,7 +1762,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_dispatch_try_catch_finally_hel static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { uint32_t throw_op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes; - uint32_t i, current_try_catch_offset = (uint32_t) -1; + int i, current_try_catch_offset = -1; { const zend_op *exc_opline = EG(opline_before_exception);