diff options
author | Darshan Sen <raisinten@gmail.com> | 2021-05-21 18:48:44 +0300 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2021-05-31 22:34:53 +0300 |
commit | 3e6b3b22c5f687e170944a1cef51caa41a4caea1 (patch) | |
tree | 2d7f600ec44eb3f7309b6665bda2e882be2c4ccf /src | |
parent | bc8400122c9f2ee57ce0ed7188013f74b478d2ef (diff) |
src: use SPrintF in ProcessEmitWarning
PR-URL: https://github.com/nodejs/node/pull/38758
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/api/hooks.cc | 2 | ||||
-rw-r--r-- | src/crypto/crypto_cipher.cc | 2 | ||||
-rw-r--r-- | src/env.cc | 2 | ||||
-rw-r--r-- | src/inspector_agent.cc | 2 | ||||
-rw-r--r-- | src/module_wrap.cc | 2 | ||||
-rw-r--r-- | src/node.cc | 2 | ||||
-rw-r--r-- | src/node_dir.cc | 2 | ||||
-rw-r--r-- | src/node_env_var.cc | 2 | ||||
-rw-r--r-- | src/node_errors.cc | 2 | ||||
-rw-r--r-- | src/node_file.cc | 2 | ||||
-rw-r--r-- | src/node_messaging.cc | 2 | ||||
-rw-r--r-- | src/node_perf.cc | 2 | ||||
-rw-r--r-- | src/node_process-inl.h | 26 | ||||
-rw-r--r-- | src/node_process.h | 5 | ||||
-rw-r--r-- | src/node_process_events.cc | 15 | ||||
-rw-r--r-- | src/node_process_methods.cc | 2 | ||||
-rw-r--r-- | src/node_process_object.cc | 2 | ||||
-rw-r--r-- | src/node_task_queue.cc | 2 | ||||
-rw-r--r-- | src/signal_wrap.cc | 2 | ||||
-rw-r--r-- | src/uv.cc | 2 |
20 files changed, 48 insertions, 32 deletions
diff --git a/src/api/hooks.cc b/src/api/hooks.cc index cb46c5c1b87..c19d8c5b910 100644 --- a/src/api/hooks.cc +++ b/src/api/hooks.cc @@ -1,6 +1,6 @@ #include "env-inl.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "async_wrap.h" namespace node { diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc index 5ce46658282..4629143d47e 100644 --- a/src/crypto/crypto_cipher.cc +++ b/src/crypto/crypto_cipher.cc @@ -6,7 +6,7 @@ #include "memory_tracker-inl.h" #include "node_buffer.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "v8.h" namespace node { diff --git a/src/env.cc b/src/env.cc index 28a1c2fd3c3..4ee4b675d87 100644 --- a/src/env.cc +++ b/src/env.cc @@ -10,7 +10,7 @@ #include "node_errors.h" #include "node_internals.h" #include "node_options-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_v8_platform-inl.h" #include "node_worker.h" #include "req_wrap-inl.h" diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 4b30c177bea..a3c901dca2e 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -12,7 +12,7 @@ #include "node_errors.h" #include "node_internals.h" #include "node_options-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_url.h" #include "util-inl.h" #include "timer_wrap.h" diff --git a/src/module_wrap.cc b/src/module_wrap.cc index ed48c0bc5f4..f45ee7627b0 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -5,7 +5,7 @@ #include "node_contextify.h" #include "node_errors.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_url.h" #include "node_watchdog.h" #include "util-inl.h" diff --git a/src/node.cc b/src/node.cc index b7dd3e10cdb..466787750fc 100644 --- a/src/node.cc +++ b/src/node.cc @@ -35,7 +35,7 @@ #include "node_native_module_env.h" #include "node_options-inl.h" #include "node_perf.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_report.h" #include "node_revert.h" #include "node_v8_platform-inl.h" diff --git a/src/node_dir.cc b/src/node_dir.cc index b103c08262a..c530da0cc3b 100644 --- a/src/node_dir.cc +++ b/src/node_dir.cc @@ -1,7 +1,7 @@ #include "node_dir.h" #include "node_external_reference.h" #include "node_file-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "memory_tracker-inl.h" #include "util.h" diff --git a/src/node_env_var.cc b/src/node_env_var.cc index b13f7fcd16f..27c833d498e 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -3,7 +3,7 @@ #include "node_errors.h" #include "node_external_reference.h" #include "node_i18n.h" -#include "node_process.h" +#include "node_process-inl.h" #include <time.h> // tzset(), _tzset() diff --git a/src/node_errors.cc b/src/node_errors.cc index 47b13f61495..3aee2533a8c 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -5,7 +5,7 @@ #include "node_errors.h" #include "node_external_reference.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_report.h" #include "node_v8_platform-inl.h" #include "util-inl.h" diff --git a/src/node_file.cc b/src/node_file.cc index 228e2260661..7eb0de310f7 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -24,7 +24,7 @@ #include "memory_tracker-inl.h" #include "node_buffer.h" #include "node_external_reference.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_stat_watcher.h" #include "util-inl.h" diff --git a/src/node_messaging.cc b/src/node_messaging.cc index ac4abc3af01..7dd18979530 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -7,7 +7,7 @@ #include "node_contextify.h" #include "node_errors.h" #include "node_external_reference.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" using node::contextify::ContextifyContext; diff --git a/src/node_perf.cc b/src/node_perf.cc index c1a0b2cf3a1..8c5778ecb10 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -5,7 +5,7 @@ #include "node_internals.h" #include "node_perf.h" #include "node_buffer.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include <cinttypes> diff --git a/src/node_process-inl.h b/src/node_process-inl.h new file mode 100644 index 00000000000..21a448cfdb2 --- /dev/null +++ b/src/node_process-inl.h @@ -0,0 +1,26 @@ +#ifndef SRC_NODE_PROCESS_INL_H_ +#define SRC_NODE_PROCESS_INL_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "node_process.h" +#include "v8.h" +#include "debug_utils-inl.h" + +namespace node { + +// Call process.emitWarning(str), fmt is a snprintf() format string +template <typename... Args> +inline v8::Maybe<bool> ProcessEmitWarning(Environment* env, + const char* fmt, + Args&&... args) { + std::string warning = SPrintF(fmt, std::forward<Args>(args)...); + + return ProcessEmitWarningGeneric(env, warning.c_str()); +} + +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_NODE_PROCESS_INL_H_ diff --git a/src/node_process.h b/src/node_process.h index 2e87385348d..14c8f659168 100644 --- a/src/node_process.h +++ b/src/node_process.h @@ -25,7 +25,10 @@ v8::Maybe<bool> ProcessEmitWarningGeneric(Environment* env, const char* type = nullptr, const char* code = nullptr); -v8::Maybe<bool> ProcessEmitWarning(Environment* env, const char* fmt, ...); +template <typename... Args> +inline v8::Maybe<bool> ProcessEmitWarning(Environment* env, + const char* fmt, + Args&&... args); v8::Maybe<bool> ProcessEmitExperimentalWarning(Environment* env, const char* warning); v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env, diff --git a/src/node_process_events.cc b/src/node_process_events.cc index 0c149b26e33..34f0251cabc 100644 --- a/src/node_process_events.cc +++ b/src/node_process_events.cc @@ -1,8 +1,7 @@ -#include <cstdarg> #include <set> #include "env-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util.h" namespace node { @@ -84,18 +83,6 @@ Maybe<bool> ProcessEmitWarningGeneric(Environment* env, return Just(true); } -// Call process.emitWarning(str), fmt is a snprintf() format string -Maybe<bool> ProcessEmitWarning(Environment* env, const char* fmt, ...) { - char warning[1024]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(warning, sizeof(warning), fmt, ap); - va_end(ap); - - return ProcessEmitWarningGeneric(env, warning); -} - std::set<std::string> experimental_warnings; diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 5030ab872f4..3bb56458d0e 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -6,7 +6,7 @@ #include "node_errors.h" #include "node_external_reference.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include "uv.h" #include "v8-fast-api-calls.h" diff --git a/src/node_process_object.cc b/src/node_process_object.cc index 3d573d53460..587b4ecb936 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -4,7 +4,7 @@ #include "node_internals.h" #include "node_metadata.h" #include "node_options-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_revert.h" #include "util-inl.h" diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc index 004eb6a6529..9bbdb318021 100644 --- a/src/node_task_queue.cc +++ b/src/node_task_queue.cc @@ -4,7 +4,7 @@ #include "node_errors.h" #include "node_external_reference.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include "v8.h" diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index cdf063c035a..e8a1500d2e9 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -22,7 +22,7 @@ #include "async_wrap-inl.h" #include "env-inl.h" #include "handle_wrap.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include "v8.h" diff --git a/src/uv.cc b/src/uv.cc index 0e6672c4726..2b0c424587e 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -23,7 +23,7 @@ #include "env-inl.h" #include "node.h" #include "node_external_reference.h" -#include "node_process.h" +#include "node_process-inl.h" namespace node { |