summaryrefslogtreecommitdiff
path: root/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-15 08:11:46 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-15 08:11:46 +0000
commit579fb87ce7c7a407b76fb47da17b605d44db2d17 (patch)
treedbfa79c1ec01a19bcd21a9b180c49950eba72a04 /lib/Support/raw_ostream.cpp
parentab52ae8388aabbd931925bec742adc03556a5313 (diff)
downloadllvm-579fb87ce7c7a407b76fb47da17b605d44db2d17.tar.gz
llvm-579fb87ce7c7a407b76fb47da17b605d44db2d17.tar.bz2
llvm-579fb87ce7c7a407b76fb47da17b605d44db2d17.tar.xz
Detect write failures on raw_fd_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75758 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r--lib/Support/raw_ostream.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 23a756e4df..ef725018ee 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -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 @@ raw_fd_ostream::~raw_fd_ostream() {
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 @@ void raw_fd_ostream::close() {
uint64_t raw_fd_ostream::seek(uint64_t off) {
flush();
- pos = lseek(FD, off, SEEK_SET);
+ pos = ::lseek(FD, off, SEEK_SET);
return pos;
}