Skip to content

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.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines n-api, test
Affected core subsystem(s)

Merge request reports

Loading