Hi all,

There are 174 compiler warnings in the PHP_5_1 branch under MSVC at present, so this is an attempt to get the number down a bit (like, by around 20%) by getting rid of the simpler ones.

I've separated out those I'm really not sure about (warnings_php5_unsure.txt), the rest are all simple casts. The test suite shows no changes if all three of these patches are applied, but obviously array.c and string.c are a bit close to the bone for 'probably works' so please use judgement if applying!

Note: nearly half the remaining compiler warnings are due to type conversions in ext/date, which is only to be expected of a new extension, so it's not _quite_ as bad as it looks...

Cheers,

- Steph
Index: Zend/zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.716.2.11
diff -u -r1.716.2.11 zend_execute.c
--- Zend/zend_execute.c 19 Jan 2006 07:23:32 -0000      1.716.2.11
+++ Zend/zend_execute.c 24 Feb 2006 01:20:12 -0000
@@ -177,8 +177,8 @@
                should_free->var = ptr;

                if (T->str_offset.str->type != IS_STRING
-                       || ((int)T->str_offset.offset<0)
-                       || (T->str_offset.str->value.str.len <= 
T->str_offset.offset)) {
+                       || ((int)T->str_offset.offset < 0)
+                       || (T->str_offset.str->value.str.len <= 
(int)T->str_offset.offset)) {
                        zend_error(E_NOTICE, "Uninitialized string offset:  %d", 
T->str_offset.offset);
                        ptr->value.str.val = STR_EMPTY_ALLOC();
                        ptr->value.str.len = 0;
@@ -658,7 +658,7 @@
                                zend_error(E_WARNING, "Illegal string offset:  
%d", T->str_offset.offset);
                                break;
                        }
-                       if (T->str_offset.offset >= 
T->str_offset.str->value.str.len) {
+                       if ((int)T->str_offset.offset >= 
T->str_offset.str->value.str.len) {
                                zend_uint i;

                                if (T->str_offset.str->value.str.len==0) {
Index: Zend/zend_execute_API.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute_API.c,v
retrieving revision 1.331.2.13
diff -u -r1.331.2.13 zend_execute_API.c
--- Zend/zend_execute_API.c     22 Jan 2006 22:14:32 -0000      1.331.2.13
+++ Zend/zend_execute_API.c     24 Feb 2006 01:21:21 -0000
@@ -482,7 +482,7 @@
                                continue;
                        }

-                       if (const_value.type == IS_STRING && const_value.value.str.len 
== str_index_len-1 &&
+                       if (const_value.type == IS_STRING && const_value.value.str.len 
== (int)str_index_len-1 &&
                           !strncmp(const_value.value.str.val, str_index, 
str_index_len)) {
                                /* constant value is the same as its name */
                                zval_dtor(&const_value);
Index: Zend/zend_interfaces.c
===================================================================
RCS file: /repository/ZendEngine2/zend_interfaces.c,v
retrieving revision 1.33.2.2
diff -u -r1.33.2.2 zend_interfaces.c
--- Zend/zend_interfaces.c      4 Jan 2006 23:53:04 -0000       1.33.2.2
+++ Zend/zend_interfaces.c      24 Feb 2006 01:21:21 -0000
@@ -336,7 +336,7 @@
                } else if (class_type->get_iterator != 
zend_user_it_get_new_iterator) {
                        /* c-level get_iterator cannot be changed (exception 
being only Traversable is implmented) */
                        if (class_type->num_interfaces) {
-                               for (i = 0; i < class_type->num_interfaces; 
i++) {
+                               for (i = 0; i < 
(int)class_type->num_interfaces; i++) {
                                        if (class_type->interfaces[i] == 
zend_ce_iterator) {
                                                return FAILURE;
                                        }
Index: Zend/zend_vm_execute.h
===================================================================
RCS file: /repository/ZendEngine2/zend_vm_execute.h,v
retrieving revision 1.62.2.24
diff -u -r1.62.2.24 zend_vm_execute.h
--- Zend/zend_vm_execute.h      6 Feb 2006 11:45:56 -0000       1.62.2.24
+++ Zend/zend_vm_execute.h      24 Feb 2006 01:27:44 -0000
@@ -7553,7 +7553,7 @@
        HashTable *fe_ht;
        zend_object_iterator *iter = NULL;
        int key_type;
-       zend_bool use_key = opline->extended_value & ZEND_FE_FETCH_WITH_KEY;
+       zend_bool use_key = (zend_bool)opline->extended_value & 
ZEND_FE_FETCH_WITH_KEY;

        PZVAL_LOCK(array);

Index: ext/com_dotnet/com_saproxy.c
===================================================================
RCS file: /repository/php-src/ext/com_dotnet/com_saproxy.c,v
retrieving revision 1.15.2.2
diff -u -r1.15.2.2 com_saproxy.c
--- ext/com_dotnet/com_saproxy.c        1 Jan 2006 12:50:00 -0000       1.15.2.2
+++ ext/com_dotnet/com_saproxy.c        24 Feb 2006 00:34:20 -0000
@@ -145,7 +145,7 @@
        sa = V_ARRAY(&proxy->obj->v);
        dims = SafeArrayGetDim(sa);

-       if (proxy->dimensions >= dims) {
+       if (proxy->dimensions >= (int)dims) {
                /* too many dimensions */
                php_com_throw_exception(E_INVALIDARG, "too many dimensions!" 
TSRMLS_CC);
                return return_value;
@@ -160,7 +160,7 @@
                return return_value;
        }
        
-       if (dims - 1 == proxy->dimensions) {
+       if ((int)dims - 1 == proxy->dimensions) {
                LONG *indices;
                VARTYPE vt;
                VARIANT v;
@@ -171,7 +171,7 @@
                indices = safe_emalloc(dims, sizeof(LONG), 0);

                /* copy indices from proxy */
-               for (i = 0; i < dims; i++) {
+               for (i = 0; i < (int)dims; i++) {
                        convert_to_long(proxy->indices[i]);
                        indices[i] = Z_LVAL_P(proxy->indices[i]);
                }
@@ -246,7 +246,7 @@
                dims = SafeArrayGetDim(V_ARRAY(&proxy->obj->v));
                indices = safe_emalloc(dims, sizeof(LONG), 0);
                /* copy indices from proxy */
-               for (i = 0; i < dims; i++) {
+               for (i = 0; i < (int)dims; i++) {
                        convert_to_long(proxy->indices[i]);
                        indices[i] = Z_LVAL_P(proxy->indices[i]);
                }
Index: ext/reflection/php_reflection.c
===================================================================
RCS file: /repository/php-src/ext/reflection/php_reflection.c,v
retrieving revision 1.164.2.25
diff -u -r1.164.2.25 php_reflection.c
--- ext/reflection/php_reflection.c     20 Feb 2006 23:33:32 -0000      
1.164.2.25
+++ ext/reflection/php_reflection.c     24 Feb 2006 00:38:06 -0000
@@ -553,7 +553,7 @@
        ++offset;
        while (op < end) {
                if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) &&
-                   op->op1.u.constant.value.lval == offset) {
+                   op->op1.u.constant.value.lval == (int)offset) {
                  return op;
          }
          ++op;
Index: ext/standard/dir.c
===================================================================
RCS file: /repository/php-src/ext/standard/dir.c,v
retrieving revision 1.147.2.2
diff -u -r1.147.2.2 dir.c
--- ext/standard/dir.c  1 Jan 2006 12:50:14 -0000       1.147.2.2
+++ ext/standard/dir.c  24 Feb 2006 00:40:19 -0000
@@ -370,7 +370,7 @@
        int pattern_len;
        long flags = 0;
        glob_t globbuf;
-       unsigned int n;
+       int n;
        int ret;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &pattern, &pattern_len, &flags) == FAILURE) Index: ext/standard/exec.c
===================================================================
RCS file: /repository/php-src/ext/standard/exec.c,v
retrieving revision 1.113.2.2
diff -u -r1.113.2.2 exec.c
--- ext/standard/exec.c 1 Jan 2006 12:50:14 -0000       1.113.2.2
+++ ext/standard/exec.c 24 Feb 2006 02:08:25 -0000
@@ -135,7 +135,7 @@
                                /* strip trailing whitespaces */        
                                l = bufl;
                                while (l-- && isspace(((unsigned char 
*)buf)[l]));
-                               if (l != (bufl - 1)) {
+                               if (l != (int)(bufl - 1)) {
                                        bufl = l + 1;
                                        buf[bufl] = '\0';
                                }
@@ -148,7 +148,7 @@
                        if (type != 2) {
                                l = bufl;
                                while (l-- && isspace(((unsigned char 
*)buf)[l]));
-                               if (l != (bufl - 1)) {
+                               if (l != (int)(bufl - 1)) {
                                        bufl = l + 1;
                                        buf[bufl] = '\0';
                                }
Index: ext/standard/pack.c
===================================================================
RCS file: /repository/php-src/ext/standard/pack.c,v
retrieving revision 1.57.2.4
diff -u -r1.57.2.4 pack.c
--- ext/standard/pack.c 26 Jan 2006 15:45:33 -0000      1.57.2.4
+++ ext/standard/pack.c 24 Feb 2006 00:43:01 -0000
@@ -55,7 +55,7 @@
#endif

#define INC_OUTPUTPOS(a,b) \
-       if ((a) < 0 || ((INT_MAX - outputpos)/(b)) < (a)) { \
+       if ((a) < 0 || ((INT_MAX - outputpos)/((int)b)) < (a)) { \
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type %c: integer 
overflow in format string", code); \
                RETURN_FALSE; \
        } \
Index: ext/standard/reg.c
===================================================================
RCS file: /repository/php-src/ext/standard/reg.c,v
retrieving revision 1.82.2.2
diff -u -r1.82.2.2 reg.c
--- ext/standard/reg.c  1 Jan 2006 12:50:15 -0000       1.82.2.2
+++ ext/standard/reg.c  24 Feb 2006 00:44:18 -0000
@@ -355,7 +355,7 @@
                        new_l = strlen(buf) + subs[0].rm_so; /* part before the 
match */
                        walk = replace;
                        while (*walk) {
-                               if ('\\' == *walk && isdigit((unsigned char)walk[1]) 
&& ((unsigned char)walk[1]) - '0' <= re.re_nsub) {
+                               if ('\\' == *walk && isdigit((unsigned char)walk[1]) 
&& ((unsigned char)walk[1]) - '0' <= (int)re.re_nsub) {
                                        if (subs[walk[1] - '0'].rm_so > -1 && 
subs[walk[1] - '0'].rm_eo > -1) {
                                                new_l += subs[walk[1] - 
'0'].rm_eo - subs[walk[1] - '0'].rm_so;
} Index: ext/standard/user_filters.c
===================================================================
RCS file: /repository/php-src/ext/standard/user_filters.c,v
retrieving revision 1.31.2.1
diff -u -r1.31.2.1 user_filters.c
--- ext/standard/user_filters.c 1 Jan 2006 12:50:15 -0000       1.31.2.1
+++ ext/standard/user_filters.c 24 Feb 2006 00:49:22 -0000
@@ -406,7 +406,7 @@
                if (!bucket->own_buf) {
                        bucket = php_stream_bucket_make_writeable(bucket 
TSRMLS_CC);
                }
-               if (bucket->buflen != Z_STRLEN_PP(pzdata)) {
+               if ((int)bucket->buflen != Z_STRLEN_PP(pzdata)) {
                        bucket->buf = perealloc(bucket->buf, Z_STRLEN_PP(pzdata), 
bucket->is_persistent);
                        bucket->buflen = Z_STRLEN_PP(pzdata);
                }
Index: main/main.c
===================================================================
RCS file: /repository/php-src/main/main.c,v
retrieving revision 1.640.2.15
diff -u -r1.640.2.15 main.c
--- main/main.c 3 Feb 2006 09:31:59 -0000       1.640.2.15
+++ main/main.c 24 Feb 2006 00:51:11 -0000
@@ -659,7 +659,7 @@
                 * be NULL if PG(last_error_message) is not NULL */
                if (strcmp(PG(last_error_message), buffer)
                        || (!PG(ignore_repeated_source)
-                               && ((PG(last_error_lineno) != error_lineno)
+                               && ((PG(last_error_lineno) != (int)error_lineno)
                                        || strcmp(PG(last_error_file), 
error_filename)))) {
                        display = 1;
                } else {
Index: main/streams/filter.c
===================================================================
RCS file: /repository/php-src/main/streams/filter.c,v
retrieving revision 1.17.2.2
diff -u -r1.17.2.2 filter.c
--- main/streams/filter.c       10 Jan 2006 16:14:16 -0000      1.17.2.2
+++ main/streams/filter.c       24 Feb 2006 01:46:13 -0000
@@ -351,7 +351,7 @@
                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 (stream->readpos + consumed > (uint)stream->writepos || 
consumed < 0) {
                        /* No behaving filter should cause this. */
                        status = PSFS_ERR_FATAL;
                }
Index: sapi/cgi/fastcgi.c
===================================================================
RCS file: /repository/php-src/sapi/cgi/fastcgi.c,v
retrieving revision 1.4.2.4
diff -u -r1.4.2.4 fastcgi.c
--- sapi/cgi/fastcgi.c  4 Feb 2006 23:54:21 -0000       1.4.2.4
+++ sapi/cgi/fastcgi.c  24 Feb 2006 00:52:38 -0000
@@ -531,7 +531,7 @@
                }
                len = p - buf - sizeof(fcgi_header);
                len += fcgi_make_header((fcgi_header*)buf, 
FCGI_GET_VALUES_RESULT, 0, len);
-               if (safe_write(req, buf, sizeof(fcgi_header)+len) != 
sizeof(fcgi_header)+len) {
+               if (safe_write(req, buf, sizeof(fcgi_header)+len) != 
(int)sizeof(fcgi_header)+len) {
                        return 0;
                }
                return 0;
Index: win32/select.c
===================================================================
RCS file: /repository/php-src/win32/select.c,v
retrieving revision 1.10.2.1
diff -u -r1.10.2.1 select.c
--- win32/select.c      1 Jan 2006 12:50:20 -0000       1.10.2.1
+++ win32/select.c      24 Feb 2006 02:07:30 -0000
@@ -67,13 +67,13 @@
                        if ((DWORD)handles[n_handles] == 0xffffffff) {
                                /* socket */
                                if (SAFE_FD_ISSET(i, rfds)) {
-                                       FD_SET(i, &sock_read);
+                                       FD_SET((uint)i, &sock_read);
                                }
                                if (SAFE_FD_ISSET(i, wfds)) {
-                                       FD_SET(i, &sock_write);
+                                       FD_SET((uint)i, &sock_write);
                                }
                                if (SAFE_FD_ISSET(i, efds)) {
-                                       FD_SET(i, &sock_except);
+                                       FD_SET((uint)i, &sock_except);
                                }
                                if (i > sock_max_fd) {
                                        sock_max_fd = i;
@@ -136,13 +136,13 @@
                                for (i = 0; i < n_handles; i++) {
                                        if (WAIT_OBJECT_0 == 
WaitForSingleObject(handles[i], 0)) {
                                                if 
(SAFE_FD_ISSET(handle_slot_to_fd[i], rfds)) {
-                                                       
FD_SET(handle_slot_to_fd[i], &aread);
+                                                       
FD_SET((uint)handle_slot_to_fd[i], &aread);
                                                }
                                                if 
(SAFE_FD_ISSET(handle_slot_to_fd[i], wfds)) {
-                                                       
FD_SET(handle_slot_to_fd[i], &awrite);
+                                                       
FD_SET((uint)handle_slot_to_fd[i], &awrite);
                                                }
                                                if 
(SAFE_FD_ISSET(handle_slot_to_fd[i], efds)) {
-                                                       
FD_SET(handle_slot_to_fd[i], &aexcept);
+                                                       
FD_SET((uint)handle_slot_to_fd[i], &aexcept);
                                                }
                                                retcode++;
                                        }
Index: ext/com_dotnet/com_iterator.c
===================================================================
RCS file: /repository/php-src/ext/com_dotnet/com_iterator.c,v
retrieving revision 1.9.2.2
diff -u -r1.9.2.2 com_iterator.c
--- ext/com_dotnet/com_iterator.c       7 Feb 2006 11:50:54 -0000       1.9.2.2
+++ ext/com_dotnet/com_iterator.c       24 Feb 2006 00:31:53 -0000
@@ -32,7 +32,7 @@
struct php_com_iterator {
        zend_object_iterator iter;
        IEnumVARIANT *ev;
-       ulong key;
+       long key;
        VARIANT v; /* cached element */
        int code_page;
        VARIANT safe_array;
@@ -112,7 +112,7 @@
        } else {
                /* safe array */
                if (I->key >= I->sa_max) {
-                       I->key = (ulong)-1;
+                       I->key = -1;
                        return FAILURE;
                }
                I->key++;
Index: ext/iconv/iconv.c
===================================================================
RCS file: /repository/php-src/ext/iconv/iconv.c,v
retrieving revision 1.124.2.5
diff -u -r1.124.2.5 iconv.c
--- ext/iconv/iconv.c   1 Jan 2006 12:50:08 -0000       1.124.2.5
+++ ext/iconv/iconv.c   24 Feb 2006 00:37:08 -0000
@@ -583,7 +583,7 @@
        size_t out_left;

        unsigned int cnt;
-       unsigned int total_len;
+       int total_len;
        
        err = _php_iconv_strlen(&total_len, str, nbytes, enc);
        if (err != PHP_ICONV_ERR_SUCCESS) {
Index: ext/standard/array.c
===================================================================
RCS file: /repository/php-src/ext/standard/array.c,v
retrieving revision 1.308.2.17
diff -u -r1.308.2.17 array.c
--- ext/standard/array.c        7 Feb 2006 17:54:24 -0000       1.308.2.17
+++ ext/standard/array.c        24 Feb 2006 12:41:17 -0000
@@ -1810,14 +1810,14 @@
        /* Clamp the offset.. */
        if (offset > num_in)
                offset = num_in;
-       else if (offset < 0 && (offset=num_in+offset) < 0)
+       else if (offset < 0 && (offset = num_in + offset) < 0)
                offset = 0;
        
        /* ..and the length */
        if (length < 0) {
-               length = num_in-offset+length;
-       } else if (((unsigned) offset + (unsigned) length) > num_in) {
-               length = num_in-offset;
+               length = num_in - offset + length;
+       } else if (((unsigned)offset + (unsigned)length) > (unsigned)num_in) {
+               length = num_in - offset;
        }

        /* Create and initialize output hash */
@@ -2204,14 +2204,14 @@
        /* Clamp the offset.. */
        if (offset_val > num_in)
                return;
-       else if (offset_val < 0 && (offset_val=num_in+offset_val) < 0)
+       else if (offset_val < 0 && (offset_val = num_in + offset_val) < 0)
                offset_val = 0;
        
        /* ..and the length */
        if (length_val < 0) {
-               length_val = num_in-offset_val+length_val;
-       } else if (((unsigned) offset_val + (unsigned) length_val) > num_in) {
-               length_val = num_in-offset_val;
+               length_val = num_in - offset_val + length_val;
+       } else if (((unsigned)offset_val + (unsigned)length_val) > 
(unsigned)num_in) {
+               length_val = num_in - offset_val;
        }
        
        if (length_val == 0)
Index: ext/standard/string.c
===================================================================
RCS file: /repository/php-src/ext/standard/string.c,v
retrieving revision 1.445.2.8
diff -u -r1.445.2.8 string.c
--- ext/standard/string.c       29 Jan 2006 17:54:45 -0000      1.445.2.8
+++ ext/standard/string.c       24 Feb 2006 13:25:22 -0000
@@ -237,7 +237,7 @@
                }
        }
        
-       if (((unsigned) start + (unsigned) len) > len1) {
+       if ((start + len) > len1) {
                len = len1 - start;
        }

@@ -1166,7 +1166,7 @@
        if (state == 1) {
                cend = c;
        }
-       if (suffix != NULL && sufflen < (cend - comp) &&
+       if (suffix != NULL && sufflen < (uint)(cend - comp) &&
                        memcmp(cend - sufflen, suffix, sufflen) == 0) {
                cend -= sufflen;
        }
@@ -1983,7 +1983,7 @@
                RETURN_FALSE;
        }

-       if (((unsigned) f + (unsigned) l) > Z_STRLEN_PP(str)) {
+       if ((f + l) > Z_STRLEN_PP(str)) {
                l = Z_STRLEN_PP(str) - f;
        }

@@ -2080,7 +2080,7 @@
                                }
                        }

-                       if (((unsigned) f + (unsigned) l) > Z_STRLEN_PP(str)) {
+                       if ((f + l) > Z_STRLEN_PP(str)) {
                                l = Z_STRLEN_PP(str) - f;
                        }
                        if (Z_TYPE_PP(repl) == IS_ARRAY) {
@@ -2176,7 +2176,7 @@
                                }
                        }

-                       if (((unsigned) f + (unsigned) l) > 
Z_STRLEN_PP(tmp_str)) {
+                       if ((f + l) > Z_STRLEN_PP(tmp_str)) {
                                l = Z_STRLEN_PP(tmp_str) - f;
                        }


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to