From: Kalle Sommer Nielsen Date: Sat, 1 Aug 2009 14:45:42 +0000 (+0000) Subject: Kill compiler warnings X-Git-Tag: php-5.4.0alpha1~191^2~2897 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fef66b3c2d1ce54dc69149d04bc6439b8bb87006;p=php Kill compiler warnings --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index ee6a5ca71b..45267c4b6b 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -3956,10 +3956,10 @@ PHP_FUNCTION(imagepstext) bg_al = gdImageAlpha(bg_img, _bg); for (i = 0; i < aa_steps; i++) { - rd = bg_rd + (double) (fg_rd - bg_rd) / aa_steps * (i + 1); - gr = bg_gr + (double) (fg_gr - bg_gr) / aa_steps * (i + 1); - bl = bg_bl + (double) (fg_bl - bg_bl) / aa_steps * (i + 1); - al = bg_al + (double) (fg_al - bg_al) / aa_steps * (i + 1); + rd = bg_rd + (int) (fg_rd - bg_rd) / aa_steps * (i + 1); + gr = bg_gr + (int) (fg_gr - bg_gr) / aa_steps * (i + 1); + bl = bg_bl + (int) (fg_bl - bg_bl) / aa_steps * (i + 1); + al = bg_al + (int) (fg_al - bg_al) / aa_steps * (i + 1); aa[i] = gdImageColorResolveAlpha(bg_img, rd, gr, bl, al); } @@ -3997,7 +3997,7 @@ PHP_FUNCTION(imagepstext) for (i = 1; i < str_len; i++) { amount_kern = (int) T1_GetKerning(*f_ind, str[i - 1], str[i]); amount_kern += str[i - 1] == ' ' ? space : 0; - add_width = (int) (amount_kern + width) / extend; + add_width = (int) ((amount_kern + width) / extend); char_path = T1_GetMoveOutline(*f_ind, add_width, 0, 0, (float) size, transform); str_path = T1_ConcatOutlines(str_path, char_path); @@ -4699,7 +4699,7 @@ PHP_FUNCTION(imageconvolution) zval copyval = **var2; zval_copy_ctor(©val); convert_to_double(©val); - matrix[i][j] = Z_DVAL_PP(var2); + matrix[i][j] = (float) Z_DVAL_PP(var2); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have a 3x3 matrix"); RETURN_FALSE; @@ -4707,7 +4707,7 @@ PHP_FUNCTION(imageconvolution) } } } - RETURN_BOOL(gdImageConvolution(im_src, matrix, div, offset)); + RETURN_BOOL(gdImageConvolution(im_src, matrix, (float) div, (float) offset)); } /* }}} */ /* End section: Filters */ diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 7e90147b40..1459067850 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -132,7 +132,7 @@ static char *ps_files_path_create(char *buf, size_t buflen, ps_files *data, cons if (status != U_ZERO_ERROR) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failure converting savepath to local filesystem encoding, attempting to use utf8"); } else { - if (newlen >= buflen) { + if ((unsigned int)newlen >= buflen) { newlen = buflen - 1; newbuf[newlen] = 0; } diff --git a/ext/standard/crypt_blowfish.c b/ext/standard/crypt_blowfish.c index b640a1081b..2ffd093700 100644 --- a/ext/standard/crypt_blowfish.c +++ b/ext/standard/crypt_blowfish.c @@ -744,7 +744,7 @@ char *php_crypt_gensalt_blowfish_rn(unsigned long count, output[1] = '2'; output[2] = 'a'; output[3] = '$'; - output[4] = '0' + count / 10; + output[4] = (char) ('0' + count / 10); output[5] = '0' + count % 10; output[6] = '$'; diff --git a/ext/standard/dir.c b/ext/standard/dir.c index ce45ace899..c760b21cde 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -449,8 +449,7 @@ PHP_FUNCTION(glob) int pattern_len; long flags = 0; glob_t globbuf; - unsigned int n; - int ret; + int ret, n; zend_bool basedir_limit = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|l", &pppattern, &flags) == FAILURE || diff --git a/ext/standard/html.c b/ext/standard/html.c index eeaf296599..8b56ac848a 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1397,7 +1397,7 @@ PHP_FUNCTION(htmlspecialchars_decode) if (!memcmp(p, basic_entities_dec[j].entity, basic_entities_dec[j].entitylen)) { int e_len = basic_entities_dec[j].entitylen - 1; - *p++ = basic_entities_dec[j].charcode; + *p++ = (char)basic_entities_dec[j].charcode; memmove(p, p + e_len, (e - p - e_len)); e -= e_len; goto done; diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c index d174aad4c1..fcd98189d5 100644 --- a/ext/standard/iptc.c +++ b/ext/standard/iptc.c @@ -183,7 +183,8 @@ PHP_FUNCTION(iptcembed) int jpeg_file_len, iptcdata_len; FILE *fp; unsigned int marker; - unsigned int done = 0, inx; + unsigned int done = 0; + int inx; long spool = 0; unsigned char *spoolbuf=0, *poi=0; struct stat sb; diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 605aede826..349977f5ad 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -255,7 +255,7 @@ PHP_FUNCTION(pack) case 'i': case 'I': - INC_OUTPUTPOS(arg,sizeof(int)) + INC_OUTPUTPOS((unsigned int) arg, sizeof(int)) break; case 'l': @@ -266,11 +266,11 @@ PHP_FUNCTION(pack) break; case 'f': - INC_OUTPUTPOS(arg,sizeof(float)) + INC_OUTPUTPOS((unsigned int) arg, sizeof(float)) break; case 'd': - INC_OUTPUTPOS(arg,sizeof(double)) + INC_OUTPUTPOS((unsigned int) arg, sizeof(double)) break; case 'X': diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index c2ef4f2beb..76b9800dd8 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -116,10 +116,10 @@ PHP_FUNCTION(stream_socket_client) /* prepare the timeout value for use */ conv = (php_timeout_ull) (timeout * 1000000.0); - tv.tv_sec = conv / 1000000; + tv.tv_sec = (long) (conv / 1000000); tv.tv_usec = conv % 1000000; - if (zerrno) { + if (zerrno) { zval_dtor(zerrno); ZVAL_LONG(zerrno, 0); } @@ -260,7 +260,7 @@ PHP_FUNCTION(stream_socket_accept) /* prepare the timeout value for use */ conv = (php_timeout_ull) (timeout * 1000000.0); - tv.tv_sec = conv / 1000000; + tv.tv_sec = (long) (conv / 1000000); tv.tv_usec = conv % 1000000; if (zpeername) { diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c index 569e02ddf5..ecd14b03b4 100644 --- a/ext/standard/strnatcmp.c +++ b/ext/standard/strnatcmp.c @@ -104,7 +104,7 @@ compare_left(char const *a, char const *b) PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len, int fold_case) { unsigned char ca, cb; - int ai, bi; + unsigned int ai, bi; int fractional, result; ai = bi = 0; @@ -239,7 +239,7 @@ PHPAPI int u_strnatcmp_ex(UChar const *a, size_t a_len, UChar const *b, size_t b UChar const *ap, *bp; int fractional, result; int a_off, b_off; - int a_curr, b_curr; + unsigned int a_curr, b_curr; if (a_len == 0 || b_len == 0) return a_len - b_len; diff --git a/main/rfc1867.c b/main/rfc1867.c index 90e8f5ed41..242125a066 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -842,12 +842,12 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) } } - if (PG(upload_max_filesize) > 0 && (total_bytes+blen) > PG(upload_max_filesize)) { + if (PG(upload_max_filesize) > 0 && (int)(total_bytes+blen) > PG(upload_max_filesize)) { #if DEBUG_FILE_UPLOAD sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename); #endif cancel_upload = UPLOAD_ERROR_A; - } else if (max_file_size && ((total_bytes+blen) > max_file_size)) { + } else if (max_file_size && ((int)(total_bytes+blen) > max_file_size)) { #if DEBUG_FILE_UPLOAD sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename); #endif diff --git a/main/snprintf.c b/main/snprintf.c index b64abac3d2..7279c66d5b 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -1263,7 +1263,7 @@ static void strx_printv(int *ccp, char *buf, size_t len, const char *format, va_ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) /* {{{ */ { - int cc; + unsigned int cc; va_list ap; va_start(ap, format); @@ -1279,7 +1279,7 @@ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) /* {{{ PHPAPI int ap_php_vslprintf(char *buf, size_t len, const char *format, va_list ap) /* {{{ */ { - int cc; + unsigned int cc; strx_printv(&cc, buf, len, format, ap); if (cc >= len) { diff --git a/main/streams/filter.c b/main/streams/filter.c index b20ed7068c..55fd28974a 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -428,7 +428,7 @@ PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_strea php_stream_bucket_append(brig_inp, bucket TSRMLS_CC); status = filter->fops->filter(stream, filter, brig_inp, brig_outp, &consumed, PSFS_FLAG_NORMAL TSRMLS_CC); - if (stream->readpos + consumed > stream->writepos || consumed < 0) { + if ((int) (stream->readpos + consumed) > stream->writepos || consumed < 0) { /* No behaving filter should cause this. */ status = PSFS_ERR_FATAL; } @@ -484,9 +484,8 @@ PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_strea php_stream_bucket_convert_notranscode(bucket, stream->readbuf_type); } - /* Grow buffer to hold this bucket if need be. - TODO: See warning in main/stream/streams.c::php_stream_fill_read_buffer */ - if (stream->readbuflen - stream->writepos < bucket->buflen) { + /* Grow buffer to hold this bucket if need be */ + if (stream->readbuflen - stream->writepos < (unsigned int)bucket->buflen) { stream->readbuflen += bucket->buflen; stream->readbuf.v = perealloc(stream->readbuf.v, PS_ULEN(stream->readbuf_type == IS_UNICODE, stream->readbuflen), stream->is_persistent); } @@ -660,7 +659,7 @@ PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish TSRMLS if (chain == &(stream->readfilters)) { /* Dump any newly flushed data to the read buffer */ - if (stream->readpos > stream->chunk_size) { + if ((unsigned int)stream->readpos > stream->chunk_size) { /* Back the buffer up */ memcpy(stream->readbuf.s, stream->readbuf.s + PS_ULEN(stream->readbuf_type == IS_UNICODE, stream->readpos), PS_ULEN(stream->readbuf_type == IS_UNICODE, stream->writepos - stream->readpos)); stream->writepos -= stream->readpos; diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c index 9c7f994982..da489ceb33 100755 --- a/main/streams/glob_wrapper.c +++ b/main/streams/glob_wrapper.c @@ -144,7 +144,7 @@ static size_t php_glob_stream_read(php_stream *stream, char *buf, size_t count T /* avoid problems if someone mis-uses the stream */ if (count == sizeof(php_stream_dirent) && pglob) { - if (pglob->index < pglob->glob.gl_pathc) { + if (pglob->index < (unsigned int) pglob->glob.gl_pathc) { php_glob_stream_path_split(pglob, pglob->glob.gl_pathv[pglob->index++], pglob->flags & GLOB_APPEND, &path TSRMLS_CC); PHP_STRLCPY(ent->d_name, path, sizeof(ent->d_name), strlen(path)); return sizeof(php_stream_dirent); diff --git a/main/streams/streams.c b/main/streams/streams.c index b3c834b286..ca628a16f6 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -514,7 +514,7 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D /* grow buffer to hold this bucket * TODO: this can fail for persistent streams */ - if (stream->readbuflen - stream->writepos < bucket->buflen) { + if (stream->readbuflen - stream->writepos < (unsigned int)bucket->buflen) { stream->readbuflen += bucket->buflen; stream->readbuf.v = perealloc(stream->readbuf.v, PS_ULEN(stream->readbuf_type == IS_UNICODE, stream->readbuflen), stream->is_persistent); }