diff options
author | cjihrig <cjihrig@gmail.com> | 2019-02-10 20:17:53 +0300 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-02-13 16:19:41 +0300 |
commit | 8ecf313324e619d7211adaee76c6b7bb1882e12b (patch) | |
tree | 9e42767303e0d43629cdb98e0428812910962d73 /src/node_os.cc | |
parent | 0109e121d3a2f87c4bad75ac05436b56c9fd3407 (diff) |
os,report: use UV_MAXHOSTNAMESIZE
UV_MAXHOSTNAMESIZE was introduced in libuv 1.26.0. Use this
instead of including multiple header files, adding fallback
ifdef logic, and remembering to add one to the buffer size
for the terminating nul character with MAXHOSTNAMELEN.
PR-URL: https://github.com/nodejs/node/pull/26038
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_os.cc')
-rw-r--r-- | src/node_os.cc | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/node_os.cc b/src/node_os.cc index 5639453d2c4..fa27b7bac51 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -33,16 +33,9 @@ #ifdef __POSIX__ # include <limits.h> // PATH_MAX on Solaris. -# include <netdb.h> // MAXHOSTNAMELEN on Solaris. # include <unistd.h> // gethostname, sysconf -# include <sys/param.h> // MAXHOSTNAMELEN on Linux and the BSDs. #endif // __POSIX__ -// Add Windows fallback. -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 256 -#endif // MAXHOSTNAMELEN - namespace node { namespace os { @@ -66,7 +59,7 @@ using v8::Value; static void GetHostname(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - char buf[MAXHOSTNAMELEN + 1]; + char buf[UV_MAXHOSTNAMESIZE]; size_t size = sizeof(buf); int r = uv_os_gethostname(buf, &size); |