[llvm-commits] [llvm] r75758 - /llvm/trunk/lib/Support/raw_ostream.cpp
Daniel Dunbar
daniel at zuster.org
Wed Jul 15 01:12:11 PDT 2009
Author: ddunbar
Date: Wed Jul 15 03:11:46 2009
New Revision: 75758
URL: http://llvm.org/viewvc/llvm-project?rev=75758&view=rev
Log:
Detect write failures on raw_fd_ostream.
Modified:
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=75758&r1=75757&r2=75758&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Wed Jul 15 03:11:46 2009
@@ -18,6 +18,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Config/config.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include <ostream>
#if defined(HAVE_UNISTD_H)
@@ -285,7 +286,8 @@
void raw_fd_ostream::write_impl(const char *Ptr, unsigned Size) {
assert (FD >= 0 && "File already closed.");
pos += Size;
- ::write(FD, Ptr, Size);
+ if (::write(FD, Ptr, Size) != (ssize_t) Size)
+ llvm_report_error("IO failure writing to output stream.");
}
void raw_fd_ostream::close() {
@@ -298,7 +300,7 @@
uint64_t raw_fd_ostream::seek(uint64_t off) {
flush();
- pos = lseek(FD, off, SEEK_SET);
+ pos = ::lseek(FD, off, SEEK_SET);
return pos;
}
More information about the llvm-commits
mailing list