diff --git a/src/node_options.cc b/src/node_options.cc index a3a5e0233aa67c..6d141f52aa624d 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -36,29 +36,45 @@ void PerProcessOptions::CheckOptions(std::vector* errors) { void PerIsolateOptions::CheckOptions(std::vector* errors) { per_env->CheckOptions(errors); #ifdef NODE_REPORT - if (!report_directory.empty() && !per_env->experimental_report) + if (per_env->experimental_report) + return; + + if (!report_directory.empty()) { errors->push_back("--diagnostic-report-directory option is valid only when " "--experimental-report is set"); - if (!report_filename.empty() && !per_env->experimental_report) + } + + if (!report_filename.empty()) { errors->push_back("--diagnostic-report-filename option is valid only when " "--experimental-report is set"); - if (!report_signal.empty() && !per_env->experimental_report) + } + + if (!report_signal.empty()) { errors->push_back("--diagnostic-report-signal option is valid only when " "--experimental-report is set"); - if (report_on_fatalerror && !per_env->experimental_report) + } + + if (report_on_fatalerror) { errors->push_back( "--diagnostic-report-on-fatalerror option is valid only when " "--experimental-report is set"); - if (report_on_signal && !per_env->experimental_report) + } + + if (report_on_signal) { errors->push_back("--diagnostic-report-on-signal option is valid only when " "--experimental-report is set"); - if (report_uncaught_exception && !per_env->experimental_report) + } + + if (report_uncaught_exception) { errors->push_back( "--diagnostic-report-uncaught-exception option is valid only when " "--experimental-report is set"); - if (report_verbose && !per_env->experimental_report) + } + + if (report_verbose) { errors->push_back("--diagnostic-report-verbose option is valid only when " "--experimental-report is set"); + } #endif // NODE_REPORT } diff --git a/src/node_report.cc b/src/node_report.cc index bb4c4e1a3a8e24..9b936a506d332a 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -107,9 +107,8 @@ std::string TriggerNodeReport(Isolate* isolate, // Obtain the current time and the pid (platform dependent) TIME_TYPE tm_struct; - PID_TYPE pid; LocalTime(&tm_struct); - pid = uv_os_getpid(); + uv_pid_t pid = uv_os_getpid(); // Determine the required report filename. In order of priority: // 1) supplied on API 2) configured on startup 3) default generated if (!name.empty()) { @@ -224,7 +223,7 @@ static void WriteNodeReport(Isolate* isolate, Local stackstr, TIME_TYPE* tm_struct) { std::ostringstream buf; - PID_TYPE pid = uv_os_getpid(); + uv_pid_t pid = uv_os_getpid(); // Save formatting for output stream. std::ios old_state(nullptr); @@ -749,36 +748,20 @@ static void PrintSystemInformation(JSONWriter* writer) { writer->json_objectstart("userLimits"); struct rlimit limit; - char buf[64]; std::string soft, hard; for (size_t i = 0; i < arraysize(rlimit_strings); i++) { if (getrlimit(rlimit_strings[i].id, &limit) == 0) { - if (limit.rlim_cur == RLIM_INFINITY) { + if (limit.rlim_cur == RLIM_INFINITY) soft = std::string("unlimited"); - } else { -#if defined(_AIX) || defined(__sun) - snprintf(buf, sizeof(buf), "%ld", limit.rlim_cur); - soft = std::string(buf); -#elif defined(__linux__) && !defined(__GLIBC__) - snprintf(buf, sizeof(buf), "%ld", limit.rlim_cur); - soft = std::string(buf); -#else - snprintf(buf, sizeof(buf), "%16" PRIu64, limit.rlim_cur); - soft = std::string(soft); -#endif - } - if (limit.rlim_max == RLIM_INFINITY) { + else + soft = std::to_string(limit.rlim_cur); + + if (limit.rlim_max == RLIM_INFINITY) hard = std::string("unlimited"); - } else { -#ifdef _AIX - snprintf(buf, sizeof(buf), "%lu", limit.rlim_max); - hard = std::string(buf); -#else - snprintf(buf, sizeof(buf), "%llu", limit.rlim_max); - hard = std::string(buf); -#endif - } + else + hard = std::to_string(limit.rlim_max); + writer->json_objectstart(rlimit_strings[i].description); writer->json_keyvalue("soft", soft); writer->json_keyvalue("hard", hard); diff --git a/src/node_report.h b/src/node_report.h index c64b9c9a20c116..4c29c13afc3670 100644 --- a/src/node_report.h +++ b/src/node_report.h @@ -32,11 +32,9 @@ namespace report { #ifdef _WIN32 typedef SYSTEMTIME TIME_TYPE; -typedef DWORD PID_TYPE; #define PATHSEP "\\" #else // UNIX, OSX typedef struct tm TIME_TYPE; -typedef pid_t PID_TYPE; #define PATHSEP "/" #endif diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index e93f230d318a6d..f09ee507d3aeb5 100644 --- a/src/node_report_utils.cc +++ b/src/node_report_utils.cc @@ -1,10 +1,5 @@ -#include -#include "env.h" #include "node_internals.h" -#include "node_options.h" #include "node_report.h" -#include "util.h" -#include "v8.h" namespace report { @@ -232,8 +227,7 @@ void WalkHandle(uv_handle_t* h, void* arg) { if (h->type == UV_TCP || h->type == UV_NAMED_PIPE || h->type == UV_TTY || h->type == UV_UDP || h->type == UV_POLL) { uv_os_fd_t fd_v; - uv_os_fd_t* fd = &fd_v; - int rc = uv_fileno(h, fd); + int rc = uv_fileno(h, &fd_v); // uv_os_fd_t is an int on Unix and HANDLE on Windows. #ifndef _WIN32 if (rc == 0) {