summaryrefslogtreecommitdiff
path: root/src/api/exceptions.cc
diff options
context:
space:
mode:
authorgengjiawen <technicalcute@gmail.com>2019-03-24 08:29:51 -0400
committerRefael Ackermann <refack@gmail.com>2019-04-02 14:15:53 -0400
commit4d2739453d96310efe257e02d02127a7a71122f4 (patch)
tree0a75b78801fa0b4ebcb404b65f2c4e2dcb04266e /src/api/exceptions.cc
parentda79d30c4a8f5af965dac8427cbf7398ac533220 (diff)
downloadandroid-node-v8-4d2739453d96310efe257e02d02127a7a71122f4.tar.gz
android-node-v8-4d2739453d96310efe257e02d02127a7a71122f4.tar.bz2
android-node-v8-4d2739453d96310efe257e02d02127a7a71122f4.zip
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/exceptions.cc')
-rw-r--r--src/api/exceptions.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/api/exceptions.cc b/src/api/exceptions.cc
index 74987c2673..1025991063 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;
}