From 6e759e079f882fe54afa6da31f9cc86e9f680bf6 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 11 Dec 2024 00:12:13 +0100 Subject: [PATCH] Resolve some MSVC C4244 level 2 warnings These got already approval by the respective code owners in GH-17076. --- ext/ffi/ffi.c | 18 +++++++++--------- ext/mbstring/mbstring.c | 2 +- ext/soap/php_encoding.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 9711eb54952bb..d1713b20d7511 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -7491,10 +7491,10 @@ void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ case ZEND_FFI_TYPE_FLOAT: if (val->kind == ZEND_FFI_VAL_UINT32 || val->kind == ZEND_FFI_VAL_UINT64) { val->kind = ZEND_FFI_VAL_FLOAT; - val->d = val->u64; + val->d = (zend_ffi_double) val->u64; } else if (val->kind == ZEND_FFI_VAL_INT32 || val->kind == ZEND_FFI_VAL_INT64) { val->kind = ZEND_FFI_VAL_FLOAT; - val->d = val->i64; + val->d = (zend_ffi_double) val->i64; } else if (val->kind == ZEND_FFI_VAL_FLOAT || val->kind == ZEND_FFI_VAL_DOUBLE || val->kind == ZEND_FFI_VAL_LONG_DOUBLE) { val->kind = ZEND_FFI_VAL_FLOAT; } else if (val->kind == ZEND_FFI_VAL_CHAR) { @@ -7507,10 +7507,10 @@ void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ case ZEND_FFI_TYPE_DOUBLE: if (val->kind == ZEND_FFI_VAL_UINT32 || val->kind == ZEND_FFI_VAL_UINT64) { val->kind = ZEND_FFI_VAL_DOUBLE; - val->d = val->u64; + val->d = (zend_ffi_double) val->u64; } else if (val->kind == ZEND_FFI_VAL_INT32 || val->kind == ZEND_FFI_VAL_INT64) { val->kind = ZEND_FFI_VAL_DOUBLE; - val->d = val->i64; + val->d = (zend_ffi_double) val->i64; } else if (val->kind == ZEND_FFI_VAL_FLOAT || val->kind == ZEND_FFI_VAL_DOUBLE || val->kind == ZEND_FFI_VAL_LONG_DOUBLE) { val->kind = ZEND_FFI_VAL_DOUBLE; } else if (val->kind == ZEND_FFI_VAL_CHAR) { @@ -7546,7 +7546,7 @@ void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ val->kind = ZEND_FFI_VAL_UINT32; } else if (val->kind == ZEND_FFI_VAL_FLOAT || val->kind == ZEND_FFI_VAL_DOUBLE || val->kind == ZEND_FFI_VAL_LONG_DOUBLE) { val->kind = ZEND_FFI_VAL_UINT32; - val->u64 = val->d; + val->u64 = (uint64_t) val->d; } else if (val->kind == ZEND_FFI_VAL_CHAR) { val->kind = ZEND_FFI_VAL_UINT32; val->u64 = val->ch; @@ -7561,7 +7561,7 @@ void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ val->kind = ZEND_FFI_VAL_INT32; } else if (val->kind == ZEND_FFI_VAL_FLOAT || val->kind == ZEND_FFI_VAL_DOUBLE || val->kind == ZEND_FFI_VAL_LONG_DOUBLE) { val->kind = ZEND_FFI_VAL_INT32; - val->i64 = val->d; + val->i64 = (uint64_t) val->d; } else if (val->kind == ZEND_FFI_VAL_CHAR) { val->kind = ZEND_FFI_VAL_INT32; val->i64 = val->ch; @@ -7574,7 +7574,7 @@ void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ val->kind = ZEND_FFI_VAL_UINT64; } else if (val->kind == ZEND_FFI_VAL_FLOAT || val->kind == ZEND_FFI_VAL_DOUBLE || val->kind == ZEND_FFI_VAL_LONG_DOUBLE) { val->kind = ZEND_FFI_VAL_UINT64; - val->u64 = val->d; + val->u64 = (uint64_t) val->d; } else if (val->kind == ZEND_FFI_VAL_CHAR) { val->kind = ZEND_FFI_VAL_UINT64; val->u64 = val->ch; @@ -7591,7 +7591,7 @@ void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ val->ch = val->i64; } else if (val->kind == ZEND_FFI_VAL_FLOAT || val->kind == ZEND_FFI_VAL_DOUBLE || val->kind == ZEND_FFI_VAL_LONG_DOUBLE) { val->kind = ZEND_FFI_VAL_CHAR; - val->ch = val->d; + val->ch = (char) val->d; } else if (val->kind == ZEND_FFI_VAL_CHAR) { } else { val->kind = ZEND_FFI_VAL_ERROR; @@ -7602,7 +7602,7 @@ void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ val->kind = ZEND_FFI_VAL_UINT32; } else if (val->kind == ZEND_FFI_VAL_FLOAT || val->kind == ZEND_FFI_VAL_DOUBLE || val->kind == ZEND_FFI_VAL_LONG_DOUBLE) { val->kind = ZEND_FFI_VAL_UINT32; - val->u64 = val->d; + val->u64 = (uint64_t) val->d; } else if (val->kind == ZEND_FFI_VAL_CHAR) { val->kind = ZEND_FFI_VAL_UINT32; val->u64 = val->ch; diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 9c2ecc44550bd..a6a4d02f50ac1 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -3348,7 +3348,7 @@ try_next_encoding:; } for (size_t i = 0; i < length; i++) { - array[i].demerits *= array[i].multiplier; + array[i].demerits = (uint64_t) (array[i].demerits * array[i].multiplier); } return length; diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 57f92fa9a72a7..7c6a94e796d76 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1028,7 +1028,7 @@ static zval *to_zval_double(zval *ret, encodeTypePtr type, xmlNodePtr data) whiteSpace_collapse(data->children->content); switch (is_numeric_string((char*)data->children->content, strlen((char*)data->children->content), &lval, &dval, 0)) { case IS_LONG: - ZVAL_DOUBLE(ret, lval); + ZVAL_DOUBLE(ret, (double) lval); break; case IS_DOUBLE: ZVAL_DOUBLE(ret, dval);