Fixed signed/unsigned warnings in wddx

Also added extra const annotation to zend_memnstr.
This commit is contained in:
Nikita Popov 2015-07-17 17:19:06 +02:00
parent e97cb1427f
commit 0039a3e96f
3 changed files with 17 additions and 21 deletions

View 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]; unsigned int td[256];
register size_t i; 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]; unsigned int td[256];
register size_t i; register size_t i;

View 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 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_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, 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 #if SIZEOF_ZEND_LONG == 4
# define ZEND_DOUBLE_FITS_LONG(d) (!((d) > ZEND_LONG_MAX || (d) < ZEND_LONG_MIN)) # 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); 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 * 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 *p = haystack;
const char ne = needle[needle_len-1]; const char ne = needle[needle_len-1];

View 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); php_wddx_add_chunk_static(packet, WDDX_STRING_S);
if (Z_STRLEN_P(var) > 0) { if (Z_STRLEN_P(var) > 0) {
zend_string *buf; zend_string *buf = php_escape_html_entities(
(unsigned char *) Z_STRVAL_P(var), Z_STRLEN_P(var), 0, ENT_QUOTES, NULL);
buf = php_escape_html_entities(Z_STRVAL_P(var), Z_STRLEN_P(var), 0, ENT_QUOTES, NULL);
php_wddx_add_chunk_ex(packet, ZSTR_VAL(buf), ZSTR_LEN(buf)); 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) { if (name) {
char *tmp_buf; char *tmp_buf;
zend_string *name_esc; zend_string *name_esc = php_escape_html_entities((unsigned char *) ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES, NULL);
name_esc = php_escape_html_entities(ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES, NULL);
tmp_buf = emalloc(ZSTR_LEN(name_esc) + sizeof(WDDX_VAR_S)); 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)); 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); 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]; char tmp_buf[2];
snprintf(tmp_buf, sizeof(tmp_buf), "%c", (char)strtol((char *)atts[i], NULL, 16)); 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; 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 (atts) for (i = 0; atts[i]; i++) {
if (!strcmp((char *)atts[i], EL_NAME) && atts[++i] && atts[i][0]) { if (!strcmp((char *)atts[i], EL_NAME) && atts[++i] && atts[i][0]) {
stack->varname = estrdup(atts[i]); stack->varname = estrdup((char *)atts[i]);
break; 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]) { if (!strcmp((char *)atts[i], "fieldNames") && atts[++i] && atts[i][0]) {
zval tmp; zval tmp;
char *key; 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]; p1 = (char *)atts[i];
while ((p2 = php_memnstr(p1, ",", sizeof(",")-1, endp)) != NULL) { while ((p2 = php_memnstr(p1, ",", sizeof(",")-1, endp)) != NULL) {
key = estrndup(p1, p2 - p1); 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 && if (wddx_stack_top(stack, (void**)&recordset) == SUCCESS &&
recordset->type == ST_RECORDSET && 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); 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); wddx_stack_top(stack, (void**)&ent1);
if (!strcmp((char *)name, EL_BINARY)) { if (!strcmp((char *)name, EL_BINARY)) {
zend_string *new_str; zend_string *new_str = php_base64_decode(
(unsigned char *)Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
new_str = php_base64_decode(Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
zval_ptr_dtor(&ent1->data); zval_ptr_dtor(&ent1->data);
ZVAL_STR(&ent1->data, new_str); 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; int retval;
wddx_stack_init(&stack); wddx_stack_init(&stack);
parser = XML_ParserCreate("UTF-8"); parser = XML_ParserCreate((XML_Char *) "UTF-8");
XML_SetUserData(parser, &stack); XML_SetUserData(parser, &stack);
XML_SetElementHandler(parser, php_wddx_push_element, php_wddx_pop_element); XML_SetElementHandler(parser, php_wddx_push_element, php_wddx_pop_element);
XML_SetCharacterDataHandler(parser, php_wddx_process_data); XML_SetCharacterDataHandler(parser, php_wddx_process_data);
/* XXX value should be parsed in the loop to exhaust size_t */ /* 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); XML_ParserFree(parser);