From 7d610d45a25eb14748b20e472f99dfcfa38c9187 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 6 Jul 2017 14:30:54 +0200 Subject: [PATCH] n-api: fix warning in test_general Currently the following warning is issued when buildning: Building addon /work/nodejs/node/test/addons-napi/test_general/ CC(target) Debug/obj.target/test_general/test_general.o ../test_general.c:116:14: warning: variable 'result' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] } else if (argument_type == napi_null) { ^~~~~~~~~~~~~~~~~~~~~~~~~~ ../test_general.c:119:10: note: uninitialized use occurs here return result; ^~~~~~ ../test_general.c:116:10: note: remove the 'if' if its condition is always true } else if (argument_type == napi_null) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../test_general.c:101:20: note: initialize the variable 'result' to silence this warning napi_value result; ^ = NULL This commit simply initializes result to NULL to avoid this warning. PR-URL: https://github.com/nodejs/node/pull/14104 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson --- test/addons-napi/test_general/test_general.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/addons-napi/test_general/test_general.c b/test/addons-napi/test_general/test_general.c index ab2428b97528ee..bbf7684676aace 100644 --- a/test/addons-napi/test_general/test_general.c +++ b/test/addons-napi/test_general/test_general.c @@ -98,7 +98,7 @@ napi_value testNapiTypeof(napi_env env, napi_callback_info info) { napi_valuetype argument_type; NAPI_CALL(env, napi_typeof(env, args[0], &argument_type)); - napi_value result; + napi_value result = NULL; if (argument_type == napi_number) { NAPI_CALL(env, napi_create_string_utf8(env, "number", -1, &result)); } else if (argument_type == napi_string) {