diff options
author | gengjiawen <technicalcute@gmail.com> | 2019-03-24 15:29:51 +0300 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2019-04-02 21:15:53 +0300 |
commit | 4d2739453d96310efe257e02d02127a7a71122f4 (patch) | |
tree | 0a75b78801fa0b4ebcb404b65f2c4e2dcb04266e /src/api | |
parent | da79d30c4a8f5af965dac8427cbf7398ac533220 (diff) |
src: replace c-style cast
PR-URL: https://github.com/nodejs/node/pull/26888
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/exceptions.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/api/exceptions.cc b/src/api/exceptions.cc index 74987c2673b..1025991063e 100644 --- a/src/api/exceptions.cc +++ b/src/api/exceptions.cc @@ -162,15 +162,21 @@ static const char* winapi_strerror(const int errorno, bool* must_free) { char* errmsg = nullptr; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorno, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&errmsg, 0, nullptr); + FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, + errorno, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + reinterpret_cast<LPTSTR>(&errmsg), + 0, + nullptr); if (errmsg) { *must_free = true; // Remove trailing newlines for (int i = strlen(errmsg) - 1; - i >= 0 && (errmsg[i] == '\n' || errmsg[i] == '\r'); i--) { + i >= 0 && (errmsg[i] == '\n' || errmsg[i] == '\r'); + i--) { errmsg[i] = '\0'; } @@ -182,7 +188,6 @@ static const char* winapi_strerror(const int errorno, bool* must_free) { } } - Local<Value> WinapiErrnoException(Isolate* isolate, int errorno, const char* syscall, @@ -231,8 +236,9 @@ Local<Value> WinapiErrnoException(Isolate* isolate, .FromJust(); } - if (must_free) - LocalFree((HLOCAL)msg); + if (must_free) { + LocalFree(const_cast<char*>(msg)); + } return e; } |