Skip to content

Commit e25c5ef

Browse files
danbevaddaleax
authored andcommitted
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: #14104 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 3683f6b commit e25c5ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/addons-napi/test_general/test_general.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ napi_value testNapiTypeof(napi_env env, napi_callback_info info) {
9898
napi_valuetype argument_type;
9999
NAPI_CALL(env, napi_typeof(env, args[0], &argument_type));
100100

101-
napi_value result;
101+
napi_value result = NULL;
102102
if (argument_type == napi_number) {
103103
NAPI_CALL(env, napi_create_string_utf8(env, "number", -1, &result));
104104
} else if (argument_type == napi_string) {

0 commit comments

Comments
 (0)