]> granicus.if.org Git - php/commitdiff
Fixed signed/unsigned warnings in wddx
authorNikita Popov <nikic@php.net>
Fri, 17 Jul 2015 15:19:06 +0000 (17:19 +0200)
committerNikita Popov <nikic@php.net>
Fri, 17 Jul 2015 15:19:23 +0000 (17:19 +0200)
Also added extra const annotation to zend_memnstr.

Zend/zend_operators.c
Zend/zend_operators.h
ext/wddx/wddx.c

index b38beb283b54f927f3a06f281180e5a6a3f0d93e..77916f25a3c7838ab64ba8be7ad14091dabfc411 100644 (file)
@@ -2882,7 +2882,7 @@ static zend_always_inline void zend_memnstr_ex_pre(unsigned int td[], const char
 }
 /* }}} */
 
-ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, char *end) /* {{{ */
+ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end) /* {{{ */
 {
        unsigned int td[256];
        register size_t i;
@@ -2913,7 +2913,7 @@ ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const c
 }
 /* }}} */
 
-ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, char *end) /* {{{ */
+ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end) /* {{{ */
 {
        unsigned int td[256];
        register size_t i;
index 541d6f978fa1d4720bf06f586c2732165e7cf829..21bf9dd67ff038b49b8c2af6f743abf56dc0f8bd 100644 (file)
@@ -89,8 +89,8 @@ ZEND_API zend_bool ZEND_FASTCALL instanceof_function(const zend_class_entry *ins
  */
 ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info);
 
-ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, char *end);
-ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, char *end);
+ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end);
+ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end);
 
 #if SIZEOF_ZEND_LONG == 4
 #      define ZEND_DOUBLE_FITS_LONG(d) (!((d) > ZEND_LONG_MAX || (d) < ZEND_LONG_MIN))
@@ -141,7 +141,7 @@ static zend_always_inline zend_uchar is_numeric_string(const char *str, size_t l
 ZEND_API zend_uchar ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval);
 
 static zend_always_inline const char *
-zend_memnstr(const char *haystack, const char *needle, size_t needle_len, char *end)
+zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const char *end)
 {
        const char *p = haystack;
        const char ne = needle[needle_len-1];
index d364115799079df5ef84bb908fce0b8216af2185..33298727b7ce9ee11e78e76ed45a5a74b78ba131 100644 (file)
@@ -390,9 +390,8 @@ static void php_wddx_serialize_string(wddx_packet *packet, zval *var)
        php_wddx_add_chunk_static(packet, WDDX_STRING_S);
 
        if (Z_STRLEN_P(var) > 0) {
-               zend_string *buf;
-
-               buf = php_escape_html_entities(Z_STRVAL_P(var), Z_STRLEN_P(var), 0, ENT_QUOTES, NULL);
+               zend_string *buf = php_escape_html_entities(
+                       (unsigned char *) Z_STRVAL_P(var), Z_STRLEN_P(var), 0, ENT_QUOTES, NULL);
 
                php_wddx_add_chunk_ex(packet, ZSTR_VAL(buf), ZSTR_LEN(buf));
 
@@ -589,9 +588,7 @@ void php_wddx_serialize_var(wddx_packet *packet, zval *var, zend_string *name)
 
        if (name) {
                char *tmp_buf;
-               zend_string *name_esc;
-
-               name_esc = php_escape_html_entities(ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES, NULL);
+               zend_string *name_esc = php_escape_html_entities((unsigned char *) ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES, NULL);
                tmp_buf = emalloc(ZSTR_LEN(name_esc) + sizeof(WDDX_VAR_S));
                snprintf(tmp_buf, ZSTR_LEN(name_esc) + sizeof(WDDX_VAR_S), WDDX_VAR_S, ZSTR_VAL(name_esc));
                php_wddx_add_chunk(packet, tmp_buf);
@@ -736,7 +733,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
                                char tmp_buf[2];
 
                                snprintf(tmp_buf, sizeof(tmp_buf), "%c", (char)strtol((char *)atts[i], NULL, 16));
-                               php_wddx_process_data(user_data, tmp_buf, strlen(tmp_buf));
+                               php_wddx_process_data(user_data, (XML_Char *) tmp_buf, strlen(tmp_buf));
                                break;
                        }
                }
@@ -783,7 +780,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
 
                if (atts) for (i = 0; atts[i]; i++) {
                        if (!strcmp((char *)atts[i], EL_NAME) && atts[++i] && atts[i][0]) {
-                               stack->varname = estrdup(atts[i]);
+                               stack->varname = estrdup((char *)atts[i]);
                                break;
                        }
                }
@@ -798,9 +795,9 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
                        if (!strcmp((char *)atts[i], "fieldNames") && atts[++i] && atts[i][0]) {
                                zval tmp;
                                char *key;
-                               char *p1, *p2, *endp;
+                               const char *p1, *p2, *endp;
 
-                               endp = (char *)atts[i] + strlen(atts[i]);
+                               endp = (char *)atts[i] + strlen((char *)atts[i]);
                                p1 = (char *)atts[i];
                                while ((p2 = php_memnstr(p1, ",", sizeof(",")-1, endp)) != NULL) {
                                        key = estrndup(p1, p2 - p1);
@@ -835,7 +832,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
 
                                if (wddx_stack_top(stack, (void**)&recordset) == SUCCESS &&
                                        recordset->type == ST_RECORDSET &&
-                                       (field = zend_hash_str_find(Z_ARRVAL(recordset->data), (char*)atts[i], strlen(atts[i]))) != NULL) {
+                                       (field = zend_hash_str_find(Z_ARRVAL(recordset->data), (char*)atts[i], strlen((char *)atts[i]))) != NULL) {
                                        ZVAL_COPY_VALUE(&ent.data, field);
                                }
 
@@ -877,9 +874,8 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
                wddx_stack_top(stack, (void**)&ent1);
 
                if (!strcmp((char *)name, EL_BINARY)) {
-                       zend_string *new_str;
-
-                       new_str = php_base64_decode(Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
+                       zend_string *new_str = php_base64_decode(
+                               (unsigned char *)Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
                        zval_ptr_dtor(&ent1->data);
                        ZVAL_STR(&ent1->data, new_str);
                }
@@ -1045,14 +1041,14 @@ int php_wddx_deserialize_ex(const char *value, size_t vallen, zval *return_value
        int retval;
 
        wddx_stack_init(&stack);
-       parser = XML_ParserCreate("UTF-8");
+       parser = XML_ParserCreate((XML_Char *) "UTF-8");
 
        XML_SetUserData(parser, &stack);
        XML_SetElementHandler(parser, php_wddx_push_element, php_wddx_pop_element);
        XML_SetCharacterDataHandler(parser, php_wddx_process_data);
 
        /* XXX value should be parsed in the loop to exhaust size_t */
-       XML_Parse(parser, value, (int)vallen, 1);
+       XML_Parse(parser, (const XML_Char *) value, (int)vallen, 1);
 
        XML_ParserFree(parser);