com php-src: fix signed/unsigned mismatch warnings: ext/standard/string.c

From: Date: Tue, 16 Sep 2014 22:56:38 +0000
Subject: com php-src: fix signed/unsigned mismatch warnings: ext/standard/string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81716@lists.php.net to get a copy of this message
Commit: f2e728616ce184194b8310bbbae76a999950447f Author: Anatol Belski <ab@php.net> Tue, 16 Sep 2014 22:47:30 +0200 Parents: 551ee4165b62ff6dbd32ce0dcc213d66fc8ae083 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f2e728616ce184194b8310bbbae76a999950447f Log: fix signed/unsigned mismatch warnings Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index 7b18acf..a2ec479 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1813,7 +1813,7 @@ PHP_FUNCTION(strpos) ZEND_PARSE_PARAMETERS_END(); #endif - if (offset < 0 || offset > haystack->len) { + if (offset < 0 || (size_t)offset > haystack->len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string"); RETURN_FALSE; } @@ -1863,7 +1863,7 @@ PHP_FUNCTION(stripos) return; } - if (offset < 0 || offset > haystack->len) { + if (offset < 0 || (size_t)offset > haystack->len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string"); RETURN_FALSE; } @@ -1951,20 +1951,20 @@ PHP_FUNCTION(strrpos) } if (offset >= 0) { - if (offset > haystack->len) { + if ((size_t)offset > haystack->len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack->val + offset; + p = haystack->val + (size_t)offset; e = haystack->val + haystack->len - needle_len; } else { - if (offset < -INT_MAX || -offset > haystack->len) { + if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } p = haystack->val; - if (needle_len > -offset) { + if (needle_len > (size_t)(-offset)) { e = haystack->val + haystack->len - needle_len; } else { e = haystack->val + haystack->len + offset;

« previous php.cvs (#81716) next »