summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2015-07-17 17:19:06 +0200
committerNikita Popov <nikic@php.net>2015-07-17 17:19:23 +0200
commit0039a3e96f52b419758c93b10f581251d5e6daa1 (patch)
tree91793b0a21a5950d1a44fd6f1a0f7eca55745fb2
parente97cb1427fac3a37686064e95e7d51cedd84d9b1 (diff)
downloadphp-git-0039a3e96f52b419758c93b10f581251d5e6daa1.tar.gz
Fixed signed/unsigned warnings in wddx
Also added extra const annotation to zend_memnstr.
-rw-r--r--Zend/zend_operators.c4
-rw-r--r--Zend/zend_operators.h6
-rw-r--r--ext/wddx/wddx.c28
3 files changed, 17 insertions, 21 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index b38beb283b..77916f25a3 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -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;
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 541d6f978f..21bf9dd67f 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -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];
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index d364115799..33298727b7 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -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);