]> granicus.if.org Git - php/commitdiff
Avoid abs() type mismatch warnings
authorDavid Carlier <devnexen@gmail.com>
Mon, 18 Dec 2017 22:34:37 +0000 (22:34 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 6 Jan 2018 20:51:31 +0000 (21:51 +0100)
timelib_time z field was mistakenly promoted to 64 bits types in
one place. Otherwise silence warning with explicit cast down to int.

ext/date/php_date.c

index 0442f52d33d3bae64807291388e354c20847e23f..087885ca6096f6643b635e56c05b9fc6ef9f2381 100644 (file)
@@ -2286,7 +2286,7 @@ static HashTable *date_object_get_properties(zval *object) /* {{{ */
                                break;
                        case TIMELIB_ZONETYPE_OFFSET: {
                                zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0);
-                               timelib_sll utc_offset = dateobj->time->z;
+                               int utc_offset = dateobj->time->z;
 
                                ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d",
                                        utc_offset < 0 ? '-' : '+',
@@ -2373,8 +2373,8 @@ static HashTable *date_object_get_properties_timezone(zval *object) /* {{{ */
 
                        ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d",
                                tzobj->tzi.utc_offset < 0 ? '-' : '+',
-                               abs(tzobj->tzi.utc_offset / 3600),
-                               abs(((tzobj->tzi.utc_offset % 3600) / 60)));
+                               abs((int)(tzobj->tzi.utc_offset / 3600)),
+                               abs(((int)(tzobj->tzi.utc_offset % 3600) / 60)));
 
                        ZVAL_NEW_STR(&zv, tmpstr);
                        }
@@ -3899,8 +3899,8 @@ PHP_FUNCTION(timezone_name_get)
 
                        ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d",
                                utc_offset < 0 ? '-' : '+',
-                               abs(utc_offset / 3600),
-                               abs(((utc_offset % 3600) / 60)));
+                               abs((int)(utc_offset / 3600)),
+                               abs(((int)(utc_offset % 3600) / 60)));
 
                        RETURN_NEW_STR(tmpstr);
                        }