From 4806d55491faa5205b097ce8e23631b000bb6200 Mon Sep 17 00:00:00 2001 From: Momtchil Momtchev Date: Thu, 21 Apr 2022 15:45:23 +0200 Subject: [PATCH 1/5] fix gcc8 incompatible function pointer cast warning --- nan.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/nan.h b/nan.h index ae39e8a2..d6cc89d2 100644 --- a/nan.h +++ b/nan.h @@ -159,6 +159,33 @@ namespace Nan { #define NAN_MODULE_INIT(name) \ void name(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) +#if NODE_MODULE_VERSION >= NODE_14_MODULE_VERSION +#undef NODE_MODULE_X +#define NODE_MODULE_X(modname, regfunc, priv, flags) \ + extern "C" { \ + static void trampoline(v8::Local target, \ + v8::Local, \ + void *) { \ + regfunc(target); \ + } \ + static node::node_module _module = \ + { \ + NODE_MODULE_VERSION, \ + flags, \ + NULL, /* NOLINT (readability/null_usage) */ \ + __FILE__, \ + (node::addon_register_func) (trampoline), \ + NULL, /* NOLINT (readability/null_usage) */ \ + NODE_STRINGIFY(modname), \ + priv, \ + NULL /* NOLINT (readability/null_usage) */ \ + }; \ + NODE_C_CTOR(_register_ ## modname) { \ + node_module_register(&_module); \ + } \ + } +#endif + #if NODE_MAJOR_VERSION >= 10 || \ NODE_MAJOR_VERSION == 9 && NODE_MINOR_VERSION >= 3 #define NAN_MODULE_WORKER_ENABLED(module_name, registration) \ From ca03c93c8da6886b11af67d6bd7a039b42db8afc Mon Sep 17 00:00:00 2001 From: Momtchil Momtchev Date: Thu, 21 Apr 2022 16:34:41 +0200 Subject: [PATCH 2/5] fix class-memaccess warnings --- nan_weak.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nan_weak.h b/nan_weak.h index 7e7ab07b..d0b2917a 100644 --- a/nan_weak.h +++ b/nan_weak.h @@ -55,7 +55,7 @@ class WeakCallbackInfo { , void *field1 = 0 , void *field2 = 0) : callback_(callback), isolate_(0), parameter_(parameter) { - std::memcpy(&persistent_, persistent, sizeof (v8::Persistent)); + std::memcpy((void*)&persistent_, (void*)persistent, sizeof (v8::Persistent)); internal_fields_[0] = field1; internal_fields_[1] = field2; } From cf9807a214f6e82ba15568d2e759f47d363db2f1 Mon Sep 17 00:00:00 2001 From: Momtchil Momtchev Date: Thu, 21 Apr 2022 16:34:57 +0200 Subject: [PATCH 3/5] use a better name --- nan.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nan.h b/nan.h index d6cc89d2..4e9cff53 100644 --- a/nan.h +++ b/nan.h @@ -163,7 +163,7 @@ namespace Nan { #undef NODE_MODULE_X #define NODE_MODULE_X(modname, regfunc, priv, flags) \ extern "C" { \ - static void trampoline(v8::Local target, \ + void nan_mod_init(v8::Local target, \ v8::Local, \ void *) { \ regfunc(target); \ @@ -174,7 +174,7 @@ namespace Nan { flags, \ NULL, /* NOLINT (readability/null_usage) */ \ __FILE__, \ - (node::addon_register_func) (trampoline), \ + (node::addon_register_func) (nan_mod_init), \ NULL, /* NOLINT (readability/null_usage) */ \ NODE_STRINGIFY(modname), \ priv, \ From c76c2299e4ae6c1541b643d54707f89177385cf6 Mon Sep 17 00:00:00 2001 From: Momtchil Momtchev Date: Thu, 21 Apr 2022 16:35:08 +0200 Subject: [PATCH 4/5] fix class memaccess warnings --- test/cpp/persistent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/persistent.cpp b/test/cpp/persistent.cpp index e9bfffdf..a3b6c863 100644 --- a/test/cpp/persistent.cpp +++ b/test/cpp/persistent.cpp @@ -29,7 +29,7 @@ NAN_METHOD(ToPersistentAndBackAgain) { Persistent persistent(To(info[0]).ToLocalChecked()); v8::Local object = New(persistent); persistent.Reset(); - memset(&persistent, -1, sizeof(persistent)); // Clobber it good. + memset((void*)&persistent, -1, sizeof(persistent)); // Clobber it good. info.GetReturnValue().Set(object); } From db7a59dec9248106f08471c25c067616c1af725b Mon Sep 17 00:00:00 2001 From: Momtchil Momtchev Date: Thu, 21 Apr 2022 16:35:28 +0200 Subject: [PATCH 5/5] fix strncat Wrestrict warnings --- test/cpp/accessors.cpp | 12 ++++++------ test/cpp/accessors2.cpp | 12 ++++++------ test/cpp/methodswithdata.cpp | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/cpp/accessors.cpp b/test/cpp/accessors.cpp index 5848a409..21c42cec 100644 --- a/test/cpp/accessors.cpp +++ b/test/cpp/accessors.cpp @@ -97,8 +97,8 @@ NAN_GETTER(SetterGetter::GetProp1) { , "Prop1:GETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop1 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); @@ -119,8 +119,8 @@ NAN_GETTER(SetterGetter::GetProp2) { , "Prop2:GETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop2 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); @@ -146,8 +146,8 @@ NAN_SETTER(SetterGetter::SetProp2) { , "Prop2:SETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop2 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); diff --git a/test/cpp/accessors2.cpp b/test/cpp/accessors2.cpp index f5a2b312..b8a3cccd 100644 --- a/test/cpp/accessors2.cpp +++ b/test/cpp/accessors2.cpp @@ -95,8 +95,8 @@ NAN_GETTER(SetterGetter::GetProp1) { , "Prop1:GETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop1 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); @@ -117,8 +117,8 @@ NAN_GETTER(SetterGetter::GetProp2) { , "Prop2:GETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop2 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); @@ -144,8 +144,8 @@ NAN_SETTER(SetterGetter::SetProp2) { , "Prop2:SETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop2 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); diff --git a/test/cpp/methodswithdata.cpp b/test/cpp/methodswithdata.cpp index 1eb87f3a..e383f2d2 100644 --- a/test/cpp/methodswithdata.cpp +++ b/test/cpp/methodswithdata.cpp @@ -81,8 +81,8 @@ NAN_GETTER(SetterGetter::GetProp1) { , "Prop1:GETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop1 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); @@ -106,8 +106,8 @@ NAN_GETTER(SetterGetter::GetProp2) { , "Prop2:GETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop2 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); @@ -136,8 +136,8 @@ NAN_SETTER(SetterGetter::SetProp2) { , "Prop2:SETTER(" , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log)); - strncat( - settergetter->log + strncpy( + settergetter->log + strlen(settergetter->log) , settergetter->prop2 , sizeof (settergetter->log) - 1 - strlen(settergetter->log)); assert(strlen(settergetter->log) < sizeof (settergetter->log));