From 36ef1032742c2ba0ac5fbe8fedaa2926e3c896bf Mon Sep 17 00:00:00 2001 From: Xuefer Date: Mon, 17 Dec 2012 13:22:49 +0000 Subject: [PATCH] fix some 64bit warnings git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1201 c26eb9a1-5813-0410-bd6c-c2e55f420ca7 --- devel/run | 2 +- mod_cacher/xc_cache.h | 8 ++++---- mod_cacher/xc_cacher.c | 22 +++++++++++----------- mod_coverager/xc_coverager.c | 18 +++++++++--------- processor/hashtable.m4 | 2 +- processor/head.m4 | 28 ++++++++++++++-------------- processor/main.m4 | 2 +- processor/processor.m4 | 8 ++++---- xcache.c | 4 ++-- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/devel/run b/devel/run index 68e6052..d36f1d5 100755 --- a/devel/run +++ b/devel/run @@ -170,7 +170,7 @@ do_phpize() { # {{{1 esac phpize --clean \ && phpize \ - && CFLAGS="-g -O0 $pedanti -Wno-variadic-macros -Wno-long-long -Wall -Wno-unused-parameter -Wno-unused-function -W -Wshadow -Werror=implicit-function-declaration -std=c89 -D_GNU_SOURCE -D_POSIX_SOURCE -Dinline=" ./configure \ + && CFLAGS="-g -O0 $pedantic -Wno-variadic-macros -Wno-long-long -Wall -Wno-unused-parameter -Wno-unused-function -W -Wshadow -Werror=implicit-function-declaration -Wconversion -std=c89 -D_GNU_SOURCE -D_POSIX_SOURCE -Dinline=" ./configure \ --enable-xcache-cacher \ --enable-xcache-optimizer \ --enable-xcache-encoder \ diff --git a/mod_cacher/xc_cache.h b/mod_cacher/xc_cache.h index dd63da8..117549d 100644 --- a/mod_cacher/xc_cache.h +++ b/mod_cacher/xc_cache.h @@ -154,12 +154,12 @@ typedef struct { zend_ulong refcount; /* count of php instances holding this entry */ time_t file_mtime; size_t file_size; - int file_device; - int file_inode; + size_t file_device; + size_t file_inode; - int filepath_len; + size_t filepath_len; ZEND_24(NOTHING, const) char *filepath; - int dirpath_len; + size_t dirpath_len; char *dirpath; #ifdef IS_UNICODE int ufilepath_len; diff --git a/mod_cacher/xc_cacher.c b/mod_cacher/xc_cacher.c index ed74957..ac58454 100644 --- a/mod_cacher/xc_cacher.c +++ b/mod_cacher/xc_cacher.c @@ -410,7 +410,7 @@ static inline void xc_counters_inc(time_t *curtime, zend_uint *curslot, time_t i { time_t n = XG(request_time) / interval; if (*curtime != n) { - zend_uint target_slot = n % count; + zend_uint target_slot = ((zend_uint) n) % count; zend_uint slot; for (slot = advance_wrapped(*curslot, count); slot != target_slot; @@ -448,7 +448,7 @@ typedef XC_ENTRY_APPLY_FUNC((*cache_apply_unlocked_func_t)); static void xc_entry_apply_unlocked(xc_entry_type_t type, xc_cache_t *cache, cache_apply_unlocked_func_t apply_func TSRMLS_DC) /* {{{ */ { xc_entry_t *p, **pp; - int i, c; + size_t i, c; for (i = 0, c = cache->hentry->size; i < c; i ++) { pp = &(cache->cached->entries[i]); @@ -516,7 +516,7 @@ static void xc_gc_expires_php(TSRMLS_D) /* {{{ */ /* }}} */ static void xc_gc_expires_var(TSRMLS_D) /* {{{ */ { - int i, c; + size_t i, c; if (!xc_var_gc_interval || !xc_var_caches) { return; @@ -735,7 +735,7 @@ static void xc_fillentry_unlocked(xc_entry_type_t type, const xc_entry_t *entry, static void xc_filllist_unlocked(xc_entry_type_t type, xc_cache_t *cache, zval *return_value TSRMLS_DC) /* {{{ */ { zval* list; - int i, c; + size_t i, c; xc_entry_t *e; ALLOC_INIT_ZVAL(list); @@ -933,7 +933,7 @@ static int xc_resolve_path(const char *filepath, char *path_buffer, xc_resolve_p char *paths, *path; char *tokbuf; size_t path_buffer_len; - int size; + size_t size; char tokens[] = { DEFAULT_DIR_SEPARATOR, '\0' }; int ret; ALLOCA_FLAG(use_heap) @@ -968,7 +968,7 @@ static int xc_resolve_path(const char *filepath, char *path_buffer, xc_resolve_p /* fall back to current directory */ if (zend_is_executing(TSRMLS_C)) { const char *executing_filename = zend_get_executed_filename(TSRMLS_C); - int dirname_len = strlen(executing_filename); + int dirname_len = (int) strlen(executing_filename); size_t filename_len = strlen(filepath); while ((--dirname_len >= 0) && !IS_SLASH(executing_filename[dirname_len])); @@ -1065,7 +1065,7 @@ static XC_RESOLVE_PATH_CHECKER(xc_resolve_path_entry_checker) /* {{{ */ xc_compiler_t *compiler = entry_checker_data->compiler; compiler->new_entry.entry.name.str.val = xc_expand_url(filepath, compiler->opened_path_buffer TSRMLS_CC); - compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val); + compiler->new_entry.entry.name.str.len = (int) strlen(compiler->new_entry.entry.name.str.val); *entry_checker_data->stored_entry = (xc_entry_php_t *) xc_entry_find_unlocked( XC_TYPE_PHP @@ -1143,7 +1143,7 @@ static int xc_entry_php_resolve_opened_path(xc_compiler_t *compiler, struct stat /* fall back to real stat call */ else { #ifdef ZEND_ENGINE_2_3 - char *opened_path = php_resolve_path(compiler->filename, compiler->filename_len, PG(include_path) TSRMLS_CC); + char *opened_path = php_resolve_path(compiler->filename, (int) compiler->filename_len, PG(include_path) TSRMLS_CC); if (opened_path) { strcpy(compiler->opened_path_buffer, opened_path); efree(opened_path); @@ -1181,7 +1181,7 @@ static int xc_entry_php_init_key(xc_compiler_t *compiler TSRMLS_DC) /* {{{ */ } delta = XG(request_time) - buf.st_mtime; - if (abs(delta) < 2 && !xc_test) { + if (abs((int) delta) < 2 && !xc_test) { return FAILURE; } @@ -1213,7 +1213,7 @@ static int xc_entry_php_init_key(xc_compiler_t *compiler TSRMLS_DC) /* {{{ */ /* get back to basename_begin */ ++basename_begin; - basename_hash_value = HASH_STR_L(basename_begin, filename_end - basename_begin); + basename_hash_value = HASH_STR_L(basename_begin, (uint) (filename_end - basename_begin)); } compiler->entry_hash.cacheid = xc_php_hcache.size > 1 ? xc_hash_fold(basename_hash_value, &xc_php_hcache) : 0; @@ -1253,7 +1253,7 @@ static int xc_entry_data_php_init_md5(xc_cache_t *cache, xc_compiler_t *compiler } PHP_MD5Init(&context); - while ((n = php_stream_read(stream, (char *) buf, sizeof(buf))) > 0) { + while ((n = php_stream_read(stream, (char *) buf, (int) sizeof(buf))) > 0) { PHP_MD5Update(&context, buf, n); } PHP_MD5Final((unsigned char *) compiler->new_php.md5.digest, &context); diff --git a/mod_coverager/xc_coverager.c b/mod_coverager/xc_coverager.c index 451ae41..cfca25a 100644 --- a/mod_coverager/xc_coverager.c +++ b/mod_coverager/xc_coverager.c @@ -39,7 +39,7 @@ static void xc_destroy_coverage(void *pDest) /* {{{ */ efree(cov); } /* }}} */ -static void xcache_mkdirs_ex(char *root, int rootlen, char *path, int pathlen TSRMLS_DC) /* {{{ */ +static void xcache_mkdirs_ex(char *root, long rootlen, char *path, long pathlen TSRMLS_DC) /* {{{ */ { char *fullpath; struct stat st; @@ -75,7 +75,7 @@ static void xc_coverager_save_cov(char *srcfile, char *outfilename, coverager_t long *buf = NULL, *p; long covlines, *phits; int fd = -1; - int size; + size_t size; int newfile; struct stat srcstat, outstat; HashPosition pos; @@ -276,7 +276,7 @@ static void xc_coverager_autodump(TSRMLS_D) /* {{{ */ coverager_t *pcov; zstr s; char *outfilename; - int dumpdir_len, outfilelen, alloc_len = 0; + size_t dumpdir_len, outfilelen, alloc_len = 0; uint size; HashPosition pos; @@ -333,7 +333,7 @@ static void xc_coverager_dump(zval *return_value TSRMLS_DC) /* {{{ */ add_index_long(lines, pos2->h, hits >= 0 ? hits : 0); zend_hash_move_forward_ex(cov, &pos2); } - add_assoc_zval_ex(return_value, ZSTR_S(filename), strlen(ZSTR_S(filename)) + 1, lines); + add_assoc_zval_ex(return_value, ZSTR_S(filename), (uint) strlen(ZSTR_S(filename)) + 1, lines); zend_hash_move_forward_ex(XG(coverages), &pos); } @@ -356,7 +356,7 @@ static PHP_RSHUTDOWN_FUNCTION(xcache_coverager) /* {{{ */ /* helper func to store hits into coverages */ static coverager_t xc_coverager_get(const char *filename TSRMLS_DC) /* {{{ */ { - int len = strlen(filename) + 1; + uint len = (uint) strlen(filename) + 1; coverager_t cov, *pcov; if (zend_u_hash_find(XG(coverages), IS_STRING, filename, len, (void **) &pcov) == SUCCESS) { @@ -472,7 +472,7 @@ static void xc_coverager_handle_ext_stmt(zend_op_array *op_array, zend_uchar op) if (XG(coverages) && XG(coverager_started)) { int size = xc_coverager_get_op_array_size_no_tail(op_array); - int oplineno = (*EG(opline_ptr)) - op_array->opcodes; + int oplineno = (int) ((*EG(opline_ptr)) - op_array->opcodes); if (oplineno < size) { xc_coverager_add_hits(xc_coverager_get(op_array->filename TSRMLS_CC), (*EG(opline_ptr))->lineno, 1 TSRMLS_CC); } @@ -497,7 +497,7 @@ PHP_FUNCTION(xcache_coverager_decode) array_init(return_value); p = (long*) str; - len -= sizeof(long); + len -= (int) sizeof(long); if (len < 0) { return; } @@ -506,7 +506,7 @@ PHP_FUNCTION(xcache_coverager_decode) return; } - for (; len >= (int) sizeof(long) * 2; len -= sizeof(long) * 2, p += 2) { + for (; len >= (int) sizeof(long) * 2; len -= (int) sizeof(long) * 2, p += 2) { add_index_long(return_value, p[0], p[1] < 0 ? 0 : p[1]); } } @@ -657,7 +657,7 @@ static PHP_MINIT_FUNCTION(xcache_coverager) /* {{{ */ REGISTER_INI_ENTRIES(); if (cfg_get_string("xcache.coveragedump_directory", &xc_coveragedump_dir) == SUCCESS && xc_coveragedump_dir) { - int len; + size_t len; xc_coveragedump_dir = pestrdup(xc_coveragedump_dir, 1); len = strlen(xc_coveragedump_dir); if (len) { diff --git a/processor/hashtable.m4 b/processor/hashtable.m4 index 05ddb2c..c95bbc3 100644 --- a/processor/hashtable.m4 +++ b/processor/hashtable.m4 @@ -71,7 +71,7 @@ define(`DEF_HASH_TABLE_FUNC', ` zend_bool first = 1; dnl only used for copy IFCOPY(`uint n;') - IFCALCCOPY(`int bucketsize;') + IFCALCCOPY(`size_t bucketsize;') #if defined(HARDENING_PATCH_HASH_PROTECT) && HARDENING_PATCH_HASH_PROTECT IFASM(`dst->canary = zend_hash_canary; DONE(canary)', ` diff --git a/processor/head.m4 b/processor/head.m4 index a6a44f8..ed9935e 100644 --- a/processor/head.m4 +++ b/processor/head.m4 @@ -88,7 +88,7 @@ dnl }}} /* export: typedef struct _xc_processor_t xc_processor_t; :export {{{ */ struct _xc_processor_t { char *p; - zend_uint size; + size_t size; HashTable strings; HashTable zvalptrs; zend_bool reference; /* enable if to deal with reference */ @@ -158,20 +158,20 @@ static void xc_dprint_str_len(const char *str, int len) /* {{{ */ /* }}} */ #endif /* {{{ xc_zstrlen_char */ -static inline int xc_zstrlen_char(const_zstr s) +static inline size_t xc_zstrlen_char(const_zstr s) { return strlen(ZSTR_S(s)); } /* }}} */ #ifdef IS_UNICODE /* {{{ xc_zstrlen_uchar */ -static inline int xc_zstrlen_uchar(zstr s) +static inline size_t xc_zstrlen_uchar(zstr s) { return u_strlen(ZSTR_U(s)); } /* }}} */ /* {{{ xc_zstrlen */ -static inline int xc_zstrlen(int type, const_zstr s) +static inline size_t xc_zstrlen(int type, const_zstr s) { return type == IS_UNICODE ? xc_zstrlen_uchar(s) : xc_zstrlen_char(s); } @@ -191,13 +191,13 @@ IFAUTOCHECK(` ') static inline void xc_calc_string_n(xc_processor_t *processor, zend_uchar type, const_zstr str, long size IFAUTOCHECK(`, int relayline')) { pushdef(`__LINE__', `relayline') - int realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size); + size_t realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size); long dummy = 1; if (realsize > MAX_DUP_STR_LEN) { ALLOC(, char, realsize) } - else if (zend_u_hash_add(&processor->strings, type, str, size, (void *) &dummy, sizeof(dummy), NULL) == SUCCESS) { + else if (zend_u_hash_add(&processor->strings, type, str, (uint) size, (void *) &dummy, sizeof(dummy), NULL) == SUCCESS) { /* new string */ ALLOC(, char, realsize) } @@ -213,7 +213,7 @@ static inline void xc_calc_string_n(xc_processor_t *processor, zend_uchar type, REDEF(`PROCESSOR_TYPE', `store') static inline zstr xc_store_string_n(xc_processor_t *processor, zend_uchar type, const_zstr str, long size IFAUTOCHECK(`, int relayline')) { pushdef(`__LINE__', `relayline') - int realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size); + size_t realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size); zstr ret, *pret; if (realsize > MAX_DUP_STR_LEN) { @@ -222,14 +222,14 @@ static inline zstr xc_store_string_n(xc_processor_t *processor, zend_uchar type, return ret; } - if (zend_u_hash_find(&processor->strings, type, str, size, (void **) &pret) == SUCCESS) { + if (zend_u_hash_find(&processor->strings, type, str, (uint) size, (void **) &pret) == SUCCESS) { return *pret; } /* new string */ ALLOC(ZSTR_V(ret), char, realsize) memcpy(ZSTR_V(ret), ZSTR_V(str), realsize); - zend_u_hash_add(&processor->strings, type, str, size, (void *) &ret, sizeof(zstr), NULL); + zend_u_hash_add(&processor->strings, type, str, (uint) size, (void *) &ret, sizeof(zstr), NULL); return ret; popdef(`__LINE__') @@ -238,8 +238,8 @@ static inline zstr xc_store_string_n(xc_processor_t *processor, zend_uchar type, /* {{{ xc_get_class_num * return class_index + 1 */ -static zend_ulong xc_get_class_num(xc_processor_t *processor, zend_class_entry *ce) { - zend_ulong i; +static zend_uint xc_get_class_num(xc_processor_t *processor, zend_class_entry *ce) { + zend_uint i; const xc_entry_data_php_t *php = processor->php_src; zend_class_entry *ceptr; @@ -356,15 +356,15 @@ static void xc_zend_extension_op_array_ctor_handler(zend_extension *extension, z /* }}} */ /* {{{ field name checker */ IFAUTOCHECK(`dnl -static int xc_check_names(const char *file, int line, const char *functionName, const char **assert_names, int assert_names_count, HashTable *done_names) +static int xc_check_names(const char *file, int line, const char *functionName, const char **assert_names, size_t assert_names_count, HashTable *done_names) { int errors = 0; if (assert_names_count) { - int i; + size_t i; Bucket *b; for (i = 0; i < assert_names_count; ++i) { - if (!zend_u_hash_exists(done_names, IS_STRING, assert_names[i], strlen(assert_names[i]) + 1)) { + if (!zend_u_hash_exists(done_names, IS_STRING, assert_names[i], (uint) strlen(assert_names[i]) + 1)) { fprintf(stderr , "Error: missing field at %s `#'%d %s`' : %s\n" , file, line, functionName diff --git a/processor/main.m4 b/processor/main.m4 index efcf3a2..661c0b9 100644 --- a/processor/main.m4 +++ b/processor/main.m4 @@ -206,7 +206,7 @@ foreach(`i', `($1)', `popdef(`item_'defn(`i'))')dnl dnl }}} dnl {{{ DONE_* define(`DONE_SIZE', `IFAUTOCHECK(`dnl - xc_autocheck_done_size += $1`'; + xc_autocheck_done_size += (int) $1`'; xc_autocheck_done_count ++; ')') define(`DONE', ` diff --git a/processor/processor.m4 b/processor/processor.m4 index 0a8e1b0..5ddb4c5 100644 --- a/processor/processor.m4 +++ b/processor/processor.m4 @@ -1177,12 +1177,12 @@ DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{ IFSTORE(`dst->refcount = 0; DONE(refcount)', `PROCESS(long, refcount)') PROCESS(time_t, file_mtime) PROCESS(size_t, file_size) - PROCESS(int, file_device) - PROCESS(int, file_inode) + PROCESS(size_t, file_device) + PROCESS(size_t, file_inode) - PROCESS(int, filepath_len) + PROCESS(size_t, filepath_len) IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)') - PROCESS(int, dirpath_len) + PROCESS(size_t, dirpath_len) IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)') #ifdef IS_UNICODE PROCESS(int, ufilepath_len) diff --git a/xcache.c b/xcache.c index 4e90b7f..2556d85 100644 --- a/xcache.c +++ b/xcache.c @@ -247,7 +247,7 @@ static void xc_call_getter(xc_name_getter_t getter, int count, INTERNAL_FUNCTION name = getter((zend_uchar) spec); if (name) { /* RETURN_STRING */ - int len = strlen(name); + int len = (int) strlen(name); return_value->value.str.len = len; return_value->value.str.val = estrndup(name, len); return_value->type = IS_STRING; @@ -753,7 +753,7 @@ static PHP_MINIT_FUNCTION(xcache) /* {{{ */ if (strcmp(sapi_module.name, "cli") == 0) { char *env; if ((env = getenv("XCACHE_TEST")) != NULL) { - xc_test = atoi(env); + xc_test = (zend_bool) atoi(env); } }