]> granicus.if.org Git - php/commitdiff
Sync r314808 to 5_3 branch
authorXinchen Hui <laruence@php.net>
Tue, 23 Aug 2011 10:18:48 +0000 (10:18 +0000)
committerXinchen Hui <laruence@php.net>
Tue, 23 Aug 2011 10:18:48 +0000 (10:18 +0000)
Eliminated compiler warnings "comparison is always false",  "cast to pointer from integer of different siz" and tail zero warnings

ext/ereg/ereg.c
ext/ereg/regex/regerror.c
ext/mysqlnd/mysqlnd_charset.c
ext/standard/var.c
main/streams/cast.c

index 475783aa4251771e7902f3e3ff8b8422c8abfe22..b89730221ca843ffb5ef0b7a7a58067a44865c0f 100644 (file)
@@ -475,6 +475,7 @@ PHPAPI char *php_ereg_replace(const char *pattern, const char *replace, const ch
                                buf_len = 1 + buf_len + 2 * new_l;
                                nbuf = emalloc(buf_len);
                                strncpy(nbuf, buf, buf_len-1);
+                               nbuf[buf_len - 1] = '\0';
                                efree(buf);
                                buf = nbuf;
                        }
@@ -486,7 +487,7 @@ PHPAPI char *php_ereg_replace(const char *pattern, const char *replace, const ch
                        walkbuf = &buf[tmp + subs[0].rm_so];
                        walk = replace;
                        while (*walk) {
-                               if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= (int)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
                                                /* this next case shouldn't happen. it does. */
                                                && subs[walk[1] - '0'].rm_so <= subs[walk[1] - '0'].rm_eo) {
index 1c66d4114e37c81eca77a8e438a05b26bf1c3f07..7bf741967ddcb501c3daa32873a9cf71539c7cd0 100644 (file)
@@ -82,10 +82,12 @@ size_t errbuf_size)
                                break;
        
                if (errcode&REG_ITOA) {
-                       if (r->code >= 0)
-                               (void) strncpy(convbuf, r->name, 50);
-                       else
+                       if (r->code >= 0) {
+                               (void) strncpy(convbuf, r->name, sizeof(convbuf) - 1);
+                               convbuf[sizeof(convbuf) - 1] = '\0';
+                       } else {
                                snprintf(convbuf, sizeof(convbuf), "REG_0x%x", target);
+                       }
                        assert(strlen(convbuf) < sizeof(convbuf));
                        s = convbuf;
                } else
index 6c8e7a5cc1b95b051c414d48a519c171383458f8..191fd4ceb4520358a07208376a89ed26f5af22f3 100644 (file)
@@ -125,8 +125,8 @@ static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
                if (!((start[1] ^ 0x80) < 0x40 &&
                        (start[2] ^ 0x80) < 0x40 &&
                        (start[3] ^ 0x80) < 0x40 &&
-                               (c >= 0xf1 || start[1] >= 0x90) &&
-                               (c <= 0xf3 || start[1] <= 0x8F)))
+                               (c >= 0xf1 || start[1] >= (char)0x90) &&
+                               (c <= 0xf3 || start[1] <= (char)0x8F)))
                {
                        return 0;       /* invalid utf8 character */
                }
index 63e3947b92fbc0c3893ec689c04626ca4a3d7e35..ad958b180160177c0b4fc86b83b5157058ef7917 100644 (file)
@@ -598,7 +598,7 @@ static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval *struc
 
        PHP_SET_CLASS_ATTRIBUTES(struc);
        smart_str_appendl(buf, "O:", 2);
-       smart_str_append_long(buf, (long)name_len);
+       smart_str_append_long(buf, (int)name_len);
        smart_str_appendl(buf, ":\"", 2);
        smart_str_appendl(buf, class_name, name_len);
        smart_str_appendl(buf, "\":", 2);
@@ -764,12 +764,12 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
 
                                        if (ce->serialize(struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) {
                                                smart_str_appendl(buf, "C:", 2);
-                                               smart_str_append_long(buf, (long)Z_OBJCE_P(struc)->name_length);
+                                               smart_str_append_long(buf, (int)Z_OBJCE_P(struc)->name_length);
                                                smart_str_appendl(buf, ":\"", 2);
                                                smart_str_appendl(buf, Z_OBJCE_P(struc)->name, Z_OBJCE_P(struc)->name_length);
                                                smart_str_appendl(buf, "\":", 2);
 
-                                               smart_str_append_long(buf, (long)serialized_length);
+                                               smart_str_append_long(buf, (int)serialized_length);
                                                smart_str_appendl(buf, ":{", 2);
                                                smart_str_appendl(buf, serialized_data, serialized_length);
                                                smart_str_appendc(buf, '}');
index debbd82707492dbd242df4e156fe1e431b024ef7..38eb1a987c009d8b5ab7167271ffb1845bda78c7 100644 (file)
@@ -271,7 +271,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
 
                        newstream = php_stream_fopen_tmpfile();
                        if (newstream) {
-                               int retval = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
+                               size_t retval = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL);
 
                                if (ret != SUCCESS) {
                                        php_stream_close(newstream);