From bfdcc4759ac5d74f87422c7f4bb4cea2607929e0 Mon Sep 17 00:00:00 2001 From: Jason Ginchereau Date: Fri, 2 Jun 2017 12:32:18 -0700 Subject: [PATCH 1/2] test: fix build warning in addons-napi\test_object --- test/addons-napi/test_object/test_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/addons-napi/test_object/test_object.c b/test/addons-napi/test_object/test_object.c index dd2db123f740c2..9a29d12e2e6181 100644 --- a/test/addons-napi/test_object/test_object.c +++ b/test/addons-napi/test_object/test_object.c @@ -156,7 +156,7 @@ napi_value Unwrap(napi_env env, napi_callback_info info) { NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &arg, NULL, NULL)); int32_t* data; - NAPI_CALL(env, napi_unwrap(env, arg, &data)); + NAPI_CALL(env, napi_unwrap(env, arg, (void**)&data)); napi_value result; NAPI_CALL(env, napi_get_boolean(env, data != NULL && *data == 3, &result)); From 0e62bcb39cc19e7995a630554349b70194ce103f Mon Sep 17 00:00:00 2001 From: Jason Ginchereau Date: Mon, 5 Jun 2017 10:36:55 -0700 Subject: [PATCH 2/2] Address review feedback --- test/addons-napi/test_object/test_object.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/addons-napi/test_object/test_object.c b/test/addons-napi/test_object/test_object.c index 9a29d12e2e6181..383fe46342a340 100644 --- a/test/addons-napi/test_object/test_object.c +++ b/test/addons-napi/test_object/test_object.c @@ -3,6 +3,8 @@ #include #include +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; - NAPI_CALL(env, napi_unwrap(env, arg, (void**)&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; }