]> granicus.if.org Git - php/commitdiff
Fix unsigned comparisons and remove dead code
authorAnatol Belski <ab@php.net>
Fri, 17 Nov 2017 20:35:22 +0000 (21:35 +0100)
committerAnatol Belski <ab@php.net>
Fri, 17 Nov 2017 21:38:44 +0000 (22:38 +0100)
Fix unsigned comparison

Cleanup never executed block

Fix unsigned comparison

Fix unsigned comparison, diff can't be < 0

Fix unsigned comparison

Fix unsigned comparison

Remove dead code

Zend/zend_inheritance.c
Zend/zend_ini.c
Zend/zend_llist.c
Zend/zend_virtual_cwd.c
ext/hash/hash.c
ext/standard/string.c
ext/standard/uuencode.c
ext/standard/var.c

index 288f9d1670f7eb04c2b640c3de76d5273ce432fc..c7391f96f7eb373607e6269483ad63cac8a9456e 100644 (file)
@@ -1698,7 +1698,7 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce)
 ZEND_API void zend_do_bind_traits(zend_class_entry *ce) /* {{{ */
 {
 
-       if (ce->num_traits <= 0) {
+       if (ce->num_traits == 0) {
                return;
        }
 
index bf36c1f7b55fa9fe11f659bedd8f056496594668..129c7824995fe40fffda1d116436321037b15fb3 100644 (file)
@@ -189,7 +189,12 @@ static int ini_key_compare(const void *a, const void *b) /* {{{ */
        s = (const Bucket *) b;
 
        if (!f->key && !s->key) { /* both numeric */
-               return ZEND_NORMALIZE_BOOL(f->h - s->h);
+               if (f->h > s->h) {
+                       return -1;
+               } else if (f->h < s->h) {
+                       return 1;
+               }
+               return 0;
        } else if (!f->key) { /* f is numeric, s is not */
                return -1;
        } else if (!s->key) { /* s is numeric, f is not */
index 7d9b501da1e1d4c491fc49486a53fba953fc6370..4dd14775b3a7ec0d8f8f44b5572466ef09eedec8 100644 (file)
@@ -200,7 +200,7 @@ ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func)
        zend_llist_element **elements;
        zend_llist_element *element, **ptr;
 
-       if (l->count <= 0) {
+       if (l->count == 0) {
                return;
        }
 
index 5f578fb4a2baa4f2642831afa8c9f09409293204..132b68f39c8d63cbcf0996b067338857f982da1a 100644 (file)
@@ -155,7 +155,6 @@ typedef struct {
 static inline time_t FileTimeToUnixTime(const FILETIME *FileTime)
 {
        __int64 UnixTime;
-       long *nsec = NULL;
        SYSTEMTIME SystemTime;
        FileTimeToSystemTime(FileTime, &SystemTime);
 
@@ -164,10 +163,6 @@ static inline time_t FileTimeToUnixTime(const FILETIME *FileTime)
 
        UnixTime -= (SECS_BETWEEN_EPOCHS * SECS_TO_100NS);
 
-       if (nsec) {
-               *nsec = (UnixTime % SECS_TO_100NS) * (__int64)100;
-       }
-
        UnixTime /= SECS_TO_100NS; /* now convert to seconds */
 
        if ((time_t)UnixTime != UnixTime) {
index 9819a6e7ed98d5a1008a0ae79bc7f7180af3f5a5..d8e95ea1a0e35d101a4ea79ab705ec10518469de 100644 (file)
@@ -357,7 +357,7 @@ static void php_hashcontext_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *objval) {
                        zval_dtor(return_value);
                        RETURN_FALSE;
                }
-               if (!key || (ZSTR_LEN(key) <= 0)) {
+               if (!key || (ZSTR_LEN(key) == 0)) {
                        /* Note: a zero length key is no key at all */
                        php_error_docref(NULL, E_WARNING, "HMAC requested without a key");
                        zval_dtor(return_value);
index 9211c4b506470af9fbc898341655f1b0a86511c3..0bbff627008da89e13a8a32705475c215132df0c 100644 (file)
@@ -1011,7 +1011,7 @@ PHP_FUNCTION(wordwrap)
 
                laststart = lastspace = 0;
                for (current = 0; current < (zend_long)ZSTR_LEN(text); current++) {
-                       if (chk <= 0) {
+                       if (chk == 0) {
                                alloced += (size_t) (((ZSTR_LEN(text) - current + 1)/linelength + 1) * breakchar_len) + 1;
                                newtext = zend_string_extend(newtext, alloced, 0);
                                chk = (size_t) ((ZSTR_LEN(text) - current)/linelength) + 1;
@@ -4292,7 +4292,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
                while ((!max_chars || (max_chars > 0 && char_count < max_chars)) && begin > 0) {
                        char_count++;
                        begin--;
-                       if (begin <= 0 || _isnewline(heb_str[begin])) {
+                       if (_isnewline(heb_str[begin])) {
                                while (begin > 0 && _isnewline(heb_str[begin-1])) {
                                        begin--;
                                        char_count++;
@@ -4332,7 +4332,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
                }
                begin=orig_begin;
 
-               if (begin <= 0) {
+               if (begin == 0) {
                        *target = 0;
                        break;
                }
@@ -4627,7 +4627,7 @@ int php_tag_find(char *tag, size_t len, const char *set) {
        int state=0, done=0;
        char *norm;
 
-       if (len <= 0) {
+       if (len == 0) {
                return 0;
        }
 
index 583c6c3453520175adf367323f361bee09e73bc6..dbd3e842ad1e0a759a522303e09a60b63368499e 100644 (file)
@@ -141,7 +141,7 @@ PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */
        e = src + src_len;
 
        while (s < e) {
-               if ((len = PHP_UU_DEC(*s++)) <= 0) {
+               if ((len = PHP_UU_DEC(*s++)) == 0) {
                        break;
                }
                /* sanity check */
index 60961faa3986201fa0826a2e676a60ce099a3f34..70f9ab65f2b08157e7c965d707fc6707597a737b 100644 (file)
@@ -128,7 +128,6 @@ again:
                        }
                        count = zend_array_count(myht);
                        php_printf("%sarray(%d) {\n", COMMON, count);
-                       is_temp = 0;
 
                        ZEND_HASH_FOREACH_KEY_VAL_IND(myht, num, key, val) {
                                php_array_element_dump(val, num, key, level);
@@ -136,10 +135,6 @@ again:
                        if (level > 1 && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
                                GC_UNPROTECT_RECURSION(myht);
                        }
-                       if (is_temp) {
-                               zend_hash_destroy(myht);
-                               efree(myht);
-                       }
                        if (level > 1) {
                                php_printf("%*c", level-1, ' ');
                        }