Skip to content

Commit c7bd411

Browse files
frerejeromesaghul
authored andcommitted
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.
1 parent 1746ab8 commit c7bd411

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

quickjs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ static js_force_inline JSValue JS_NewInt64(JSContext *ctx, int64_t val)
501501
{
502502
JSValue v;
503503
if (val >= INT32_MIN && val <= INT32_MAX) {
504-
v = JS_NewInt32(ctx, val);
504+
v = JS_NewInt32(ctx, (int32_t)val);
505505
} else {
506-
v = JS_NewFloat64(ctx, val);
506+
v = JS_NewFloat64(ctx, (double)val);
507507
}
508508
return v;
509509
}
@@ -512,9 +512,9 @@ static js_force_inline JSValue JS_NewUint32(JSContext *ctx, uint32_t val)
512512
{
513513
JSValue v;
514514
if (val <= 0x7fffffff) {
515-
v = JS_NewInt32(ctx, val);
515+
v = JS_NewInt32(ctx, (int32_t)val);
516516
} else {
517-
v = JS_NewFloat64(ctx, val);
517+
v = JS_NewFloat64(ctx, (double)val);
518518
}
519519
return v;
520520
}

0 commit comments

Comments
 (0)