diff options
author | Jason Ginchereau <jasongin@microsoft.com> | 2017-06-02 12:32:18 -0700 |
---|---|---|
committer | Jason Ginchereau <jasongin@microsoft.com> | 2017-06-05 16:34:13 -0700 |
commit | ddba969321ba19576eae4455f5093b4bc4d1ff25 (patch) | |
tree | 563daa764ac3dd256ce7b7485751602954a1cce5 | |
parent | f29406d735405cc9f3d5f1083e84ecf2914d678d (diff) | |
download | node-new-ddba969321ba19576eae4455f5093b4bc4d1ff25.tar.gz |
test: fix build warning in addons-napi/test_object
PR-URL: https://github.com/nodejs/node/pull/13412
Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rw-r--r-- | test/addons-napi/test_object/test_object.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/addons-napi/test_object/test_object.c b/test/addons-napi/test_object/test_object.c index dd2db123f7..383fe46342 100644 --- a/test/addons-napi/test_object/test_object.c +++ b/test/addons-napi/test_object/test_object.c @@ -3,6 +3,8 @@ #include <string.h> #include <stdlib.h> +static int test_value = 3; + napi_value Get(napi_env env, napi_callback_info info) { size_t argc = 2; napi_value args[2]; @@ -145,7 +147,7 @@ napi_value Wrap(napi_env env, napi_callback_info info) { NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &arg, NULL, NULL)); int32_t* data = malloc(sizeof(int32_t)); - *data = 3; + *data = test_value; NAPI_CALL(env, napi_wrap(env, arg, data, NULL, NULL, NULL)); return NULL; } @@ -155,11 +157,12 @@ napi_value Unwrap(napi_env env, napi_callback_info info) { napi_value arg; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &arg, NULL, NULL)); - int32_t* data; + void* data; NAPI_CALL(env, napi_unwrap(env, arg, &data)); + bool is_expected = (data != NULL && *(int*)data == 3); napi_value result; - NAPI_CALL(env, napi_get_boolean(env, data != NULL && *data == 3, &result)); + NAPI_CALL(env, napi_get_boolean(env, is_expected, &result)); return result; } |