From c7bd41197a95b7fb610a08c4238bb96e230c88ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A8re=20J=C3=A9r=C3=B4me?= <142095246+frerejerome@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:22:19 +0200 Subject: [PATCH] Explicit cast in JS_NewInt64 & JS_NewUint32 This avoids the two GCC -Wconversion warnings in this public header, which is useful when using extensive error reporting from the compiler, and treating warnings as errors. --- quickjs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quickjs.h b/quickjs.h index 5a99e029..d44ebbc9 100644 --- a/quickjs.h +++ b/quickjs.h @@ -501,9 +501,9 @@ static js_force_inline JSValue JS_NewInt64(JSContext *ctx, int64_t val) { JSValue v; if (val >= INT32_MIN && val <= INT32_MAX) { - v = JS_NewInt32(ctx, val); + v = JS_NewInt32(ctx, (int32_t)val); } else { - v = JS_NewFloat64(ctx, val); + v = JS_NewFloat64(ctx, (double)val); } return v; } @@ -512,9 +512,9 @@ static js_force_inline JSValue JS_NewUint32(JSContext *ctx, uint32_t val) { JSValue v; if (val <= 0x7fffffff) { - v = JS_NewInt32(ctx, val); + v = JS_NewInt32(ctx, (int32_t)val); } else { - v = JS_NewFloat64(ctx, val); + v = JS_NewFloat64(ctx, (double)val); } return v; }