Skip to content

Commit

Permalink
test: fix compiler warning in test_string.c
Browse files Browse the repository at this point in the history
Currently, the following compiler warnings is generated:

../test_string.c:235:50: warning:
incompatible pointer types passing 'char [1]' to parameter of type
'const char16_t *' (aka 'const unsigned short *')
[-Wincompatible-pointer-types]
NAPI_CALL(env, napi_create_string_utf16(env,
    "", ((size_t)INT_MAX) + 1, &output));
    ^~
../../common.h:50:23: note: expanded from macro 'NAPI_CALL'
  NAPI_CALL_BASE(env, the_call, NULL)
                      ^~~~~~~~
../../common.h:42:10: note: expanded from macro 'NAPI_CALL_BASE'
    if ((the_call) != napi_ok) {                               \
         ^~~~~~~~
/node/src/js_native_api.h:80:66: note:
passing argument to parameter 'str' here const char16_t* str,
                                                         ^
1 warning generated.

This commit adds a cast to silence this warning.

PR-URL: #26539
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
danbev authored and BethGriggs committed Apr 16, 2019
1 parent b7dd0b8 commit 6bc7fd9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/addons-napi/test_string/test_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ static napi_value TestLargeLatin1(napi_env env, napi_callback_info info) {
static napi_value TestLargeUtf16(napi_env env, napi_callback_info info) {
napi_value output;
if (SIZE_MAX > INT_MAX) {
NAPI_CALL(env, napi_create_string_utf16(env, "", ((size_t)INT_MAX) + 1, &output));
NAPI_CALL(env, napi_create_string_utf16(env,
((const char16_t*)""),
((size_t)INT_MAX) + 1, &output));
} else {
// just throw the expected error as there is nothing to test
// in this case since we can't overflow
Expand Down

0 comments on commit 6bc7fd9

Please sign in to comment.