[llvm-commits] [ASan] Use WriteFile instead of fwrite in AsanWrite (issue 5795052)
timurrrr at google.com
timurrrr at google.com
Sun Mar 11 05:43:44 PDT 2012
Reviewers: glider,
Message:
Hi Alexander,
Can you please review this small CL?
See MSDN
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683231(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747(v=vs.85).aspx
if you need a reference for the functions.
Thanks,
Timur
Description:
Use WriteFile istead of fwrite in AsanWrite
Please review this at http://codereview.appspot.com/5795052/
Affected files:
M lib/asan/asan_win.cc
Index: lib/asan/asan_win.cc
diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc
index
5df110330b633f538154cf1c20e5b5343d302697..3c15baf785728e6ec7971b19280c8a9fb37b24e2
100644
--- a/lib/asan/asan_win.cc
+++ b/lib/asan/asan_win.cc
@@ -59,8 +59,13 @@ size_t AsanWrite(int fd, const void *buf, size_t count) {
if (fd != 2)
UNIMPLEMENTED();
- // FIXME: use WriteFile instead?
- return fwrite(buf, 1, count, stderr);
+ HANDLE err = GetStdHandle(STD_ERROR_HANDLE);
+ if (err == NULL)
+ return 0; // FIXME: this might not work on interactive apps
+ DWORD ret;
+ if (!WriteFile(err, buf, count, &ret, NULL))
+ return 0;
+ return ret;
}
// FIXME: Looks like these functions are not needed and are linked in by
the
More information about the llvm-commits
mailing list