Skip to content

Commit aa6a741

Browse files
gengjiawenBethGriggs
authored andcommitted
src: replace c-style cast
PR-URL: #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> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent 1b2a078 commit aa6a741

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/api/exceptions.cc

+12-6
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,21 @@ static const char* winapi_strerror(const int errorno, bool* must_free) {
162162
char* errmsg = nullptr;
163163

164164
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
165-
FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorno,
166-
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&errmsg, 0, nullptr);
165+
FORMAT_MESSAGE_IGNORE_INSERTS,
166+
nullptr,
167+
errorno,
168+
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
169+
reinterpret_cast<LPTSTR>(&errmsg),
170+
0,
171+
nullptr);
167172

168173
if (errmsg) {
169174
*must_free = true;
170175

171176
// Remove trailing newlines
172177
for (int i = strlen(errmsg) - 1;
173-
i >= 0 && (errmsg[i] == '\n' || errmsg[i] == '\r'); i--) {
178+
i >= 0 && (errmsg[i] == '\n' || errmsg[i] == '\r');
179+
i--) {
174180
errmsg[i] = '\0';
175181
}
176182

@@ -182,7 +188,6 @@ static const char* winapi_strerror(const int errorno, bool* must_free) {
182188
}
183189
}
184190

185-
186191
Local<Value> WinapiErrnoException(Isolate* isolate,
187192
int errorno,
188193
const char* syscall,
@@ -231,8 +236,9 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
231236
.FromJust();
232237
}
233238

234-
if (must_free)
235-
LocalFree((HLOCAL)msg);
239+
if (must_free) {
240+
LocalFree(const_cast<char*>(msg));
241+
}
236242

237243
return e;
238244
}

0 commit comments

Comments
 (0)