Fix a couple compile warnings
authorNikita Popov <nikic@php.net>
Sun, 28 Sep 2014 19:30:49 +0000 (21:30 +0200)
committerNikita Popov <nikic@php.net>
Mon, 29 Sep 2014 18:57:17 +0000 (20:57 +0200)
Zend/zend_builtin_functions.c
ext/standard/basic_functions.c
ext/standard/browscap.c
ext/standard/cyr_convert.c
ext/standard/dns.c
ext/standard/iptc.c
ext/standard/md5.c
ext/standard/sha1.c
ext/standard/string.c

index 9d8cda84d68e5f92ad3821a221f2d1287f9841e1..03a148a473a6219778fb8c785224072614d710da 100644 (file)
@@ -1761,7 +1761,7 @@ static int copy_function_name(zval *zv TSRMLS_DC, int num_args, va_list args, ze
    Returns an array of all defined functions */
 ZEND_FUNCTION(get_defined_functions)
 {
-       zval internal, user, *ret;
+       zval internal, user;
 
        if (zend_parse_parameters_none() == FAILURE) {
                return;
index 36611b812b8a4f785ead463a45589685c28fbec3..e952ad90252b22ce222ca80561f5a58f6787acc3 100644 (file)
@@ -5126,7 +5126,7 @@ PHP_FUNCTION(php_strip_whitespace)
        char *filename;
        size_t filename_len;
        zend_lex_state original_lex_state;
-       zend_file_handle file_handle = {0};
+       zend_file_handle file_handle = {{0}};
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
                RETURN_FALSE;
index a591a67d4424c586dcf15dfc9c300f5113a3c967..a76fb136a3a4546bc868a4bbd766fb9f2d707a74 100644 (file)
@@ -221,7 +221,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
 
 static int browscap_read_file(char *filename, browser_data *browdata, int persistent TSRMLS_DC) /* {{{ */
 {
-       zend_file_handle fh = {0};
+       zend_file_handle fh = {{0}};
        
        if (filename == NULL || filename[0] == '\0') {
                return FAILURE;
@@ -379,15 +379,13 @@ static int browser_reg_compare(zval *browser TSRMLS_DC, int num_args, va_list ar
                   number of characters changed in the user agent being checked versus
                   the previous match found and the current match. */
                if (Z_TYPE_P(found_browser_entry) == IS_ARRAY) {
-                       int i, prev_len = 0, curr_len = 0, ua_len;
-                       zval *current_match;
+                       size_t i, prev_len = 0, curr_len = 0;
+                       zval *current_match = zend_hash_str_find(Z_ARRVAL_P(browser), "browser_name_pattern", sizeof("browser_name_pattern")-1);
 
-                       if ((current_match = zend_hash_str_find(Z_ARRVAL_P(browser), "browser_name_pattern", sizeof("browser_name_pattern")-1)) == NULL) {
+                       if (!current_match) {
                                return 0;
                        }
 
-                       ua_len = lookup_browser_length;
-
                        for (i = 0; i < Z_STRLEN_P(previous_match); i++) {
                                switch (Z_STRVAL_P(previous_match)[i]) {
                                        case '?':
index ea5cc19387007ed4133bdab3fc531604cc9d65d6..1718b757298f2ff7cec979a8e594e7ed1e020d39 100644 (file)
@@ -201,11 +201,11 @@ _cyr_mac = {
 *    d - x-cp866
 *    m - x-mac-cyrillic
 *****************************************************************************/
-static char * php_convert_cyr_string(unsigned char *str, int length, char from, char to TSRMLS_DC)
+static char * php_convert_cyr_string(unsigned char *str, size_t length, char from, char to TSRMLS_DC)
 {
        const unsigned char *from_table, *to_table;
        unsigned char tmp;
-       int i;
+       size_t i;
 
        from_table = NULL;
        to_table   = NULL;
@@ -258,8 +258,7 @@ static char * php_convert_cyr_string(unsigned char *str, int length, char from,
        if (!str)
                return (char *)str;
        
-       for( i = 0; i<length; i++)
-       {
+       for (i = 0; i < length; i++) {
                tmp = (from_table == NULL)? str[i] : from_table[ str[i] ];
                str[i] = (to_table == NULL) ? tmp : to_table[tmp + 256];
        }
@@ -281,7 +280,7 @@ PHP_FUNCTION(convert_cyr_string)
 
        str = zend_string_init(input, input_len, 0);
 
-       php_convert_cyr_string(str->val, str->len, fr_cs[0], to_cs[0] TSRMLS_CC);
+       php_convert_cyr_string((unsigned char *) str->val, str->len, fr_cs[0], to_cs[0] TSRMLS_CC);
        RETVAL_NEW_STR(str);
 }
 /* }}} */
index a000ad9638af3cf9042e268679779c36290426fc..13a1ab75df16589d89b100adf3fb0bf8a11b5161 100644 (file)
@@ -535,7 +535,7 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
                                        }
                                        if (n) {
                                                memcpy(tp->val + l2 , cp + l1 + 1, n);
-                                               add_next_index_stringl(&entries, cp + l1 + 1, n);
+                                               add_next_index_stringl(&entries, (char *) cp + l1 + 1, n);
                                        }
                                        l1 = l1 + n + 1;
                                        l2 = l2 + n;
index 692d856757b09787715b27a9fe44016fb8755be3..75bbdd22ce823fc1af519f7faf2619d4bb029eb8 100644 (file)
@@ -300,8 +300,8 @@ PHP_FUNCTION(iptcparse)
 {
        int inx = 0, len;
        unsigned int tagsfound = 0;
-       unsigned char *buffer, recnum, dataset, key[ 16 ];
-       char *str;
+       unsigned char *buffer, recnum, dataset;
+       char *str, key[16];
        size_t str_len;
        zval values, *element;
 
index dc241180ed8e45eb945f931894cb0ed9a306d444..e5359c2bcfba2bbd0664b86dacca1be0ed632b1e 100644 (file)
@@ -61,7 +61,7 @@ PHP_NAMED_FUNCTION(php_if_md5)
        PHP_MD5Update(&context, arg->val, arg->len);
        PHP_MD5Final(digest, &context);
        if (raw_output) {
-               RETURN_STRINGL(digest, 16);
+               RETURN_STRINGL((char *) digest, 16);
        } else {
                make_digest_ex(md5str, digest, 16);
                RETVAL_STRING(md5str);
@@ -112,7 +112,7 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
        PHP_MD5Final(digest, &context);
 
        if (raw_output) {
-               RETURN_STRINGL(digest, 16);
+               RETURN_STRINGL((char *) digest, 16);
        } else {
                make_digest_ex(md5str, digest, 16);
                RETVAL_STRING(md5str);
index cd8b82f5e1e91c2faddc2e00853e38b58bda6d30..249828fb3d64a91cff68cea57d685b0442270135 100644 (file)
@@ -46,10 +46,10 @@ PHP_FUNCTION(sha1)
 
        sha1str[0] = '\0';
        PHP_SHA1Init(&context);
-       PHP_SHA1Update(&context, arg->val, arg->len);
+       PHP_SHA1Update(&context, (unsigned char *) arg->val, arg->len);
        PHP_SHA1Final(digest, &context);
        if (raw_output) {
-               RETURN_STRINGL(digest, 20);
+               RETURN_STRINGL((char *) digest, 20);
        } else {
                make_digest_ex(sha1str, digest, 20);
                RETVAL_STRING(sha1str);
@@ -71,7 +71,7 @@ PHP_FUNCTION(sha1_file)
        unsigned char buf[1024];
        unsigned char digest[20];
        PHP_SHA1_CTX   context;
-       int           n;
+       size_t         n;
        php_stream    *stream;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|b", &arg, &arg_len, &raw_output) == FAILURE) {
@@ -85,7 +85,7 @@ PHP_FUNCTION(sha1_file)
 
        PHP_SHA1Init(&context);
 
-       while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
+       while ((n = php_stream_read(stream, (char *) buf, sizeof(buf))) > 0) {
                PHP_SHA1Update(&context, buf, n);
        }
 
@@ -93,12 +93,8 @@ PHP_FUNCTION(sha1_file)
 
        php_stream_close(stream);
 
-       if (n<0) {
-               RETURN_FALSE;
-       }
-
        if (raw_output) {
-               RETURN_STRINGL(digest, 20);
+               RETURN_STRINGL((char *) digest, 20);
        } else {
                make_digest_ex(sha1str, digest, 20);
                RETVAL_STRING(sha1str);
index dcd6f09a9c9bf154a02b271d188edc04da8e68fc..4a37f7a5b30bb6798ccb7ce988f400c768b06275 100644 (file)
@@ -3983,7 +3983,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
 
        while (1) {
                char_count=0;
-               while ((!max_chars || max_chars > 0 && char_count < max_chars) && begin > 0) {
+               while ((!max_chars || (max_chars > 0 && char_count < max_chars)) && begin > 0) {
                        char_count++;
                        begin--;
                        if (begin <= 0 || _isnewline(heb_str[begin])) {