From 9bbc654b122b3e2166862fccba59b0e1e90bcbe6 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Mon, 1 Feb 2021 08:04:01 -0800 Subject: [PATCH 1/2] src: remove unnecessary symbol exposure The symbol generated by `NODE_API_MODULE()` is exposed unnecessarily. It is sufficient for it to be a local symbol because it is passed around as a function pointer. Furthermore, making it `static` fixes a warning. Fixes: https://github.com/nodejs/node-addon-api/issues/888 --- napi-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napi-inl.h b/napi-inl.h index ee1c37104..c9ffaf2a2 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -345,7 +345,7 @@ struct AccessorCallbackData { // Register an add-on based on an initializer function. #define NODE_API_MODULE(modname, regfunc) \ - napi_value __napi_ ## regfunc(napi_env env, \ + static napi_value __napi_ ## regfunc(napi_env env, \ napi_value exports) { \ return Napi::RegisterModule(env, exports, regfunc); \ } \ From ebfb0f3690e2b038e88c44e6d80f1da31c913fef Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Mon, 1 Feb 2021 09:10:33 -0800 Subject: [PATCH 2/2] heed the linter --- napi-inl.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index c9ffaf2a2..895e43768 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -344,12 +344,11 @@ struct AccessorCallbackData { //////////////////////////////////////////////////////////////////////////////// // Register an add-on based on an initializer function. -#define NODE_API_MODULE(modname, regfunc) \ - static napi_value __napi_ ## regfunc(napi_env env, \ - napi_value exports) { \ - return Napi::RegisterModule(env, exports, regfunc); \ - } \ - NAPI_MODULE(modname, __napi_ ## regfunc) +#define NODE_API_MODULE(modname, regfunc) \ + static napi_value __napi_##regfunc(napi_env env, napi_value exports) { \ + return Napi::RegisterModule(env, exports, regfunc); \ + } \ + NAPI_MODULE(modname, __napi_##regfunc) // Register an add-on based on a subclass of `Addon` with a custom Node.js // module name.