[llvm-commits] [llvm] r90275 - /llvm/trunk/lib/Support/MemoryBuffer.cpp
Chris Lattner
sabre at nondot.org
Tue Dec 1 14:51:42 PST 2009
Author: lattner
Date: Tue Dec 1 16:51:41 2009
New Revision: 90275
URL: http://llvm.org/viewvc/llvm-project?rev=90275&view=rev
Log:
return more useful error messages by using strerror to format errno
instead of returning an ambiguous reason.
Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=90275&r1=90274&r2=90275&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Dec 1 16:51:41 2009
@@ -176,7 +176,7 @@
#endif
int FD = ::open(Filename.str().c_str(), O_RDONLY|OpenFlags);
if (FD == -1) {
- if (ErrStr) *ErrStr = "could not open file";
+ if (ErrStr) *ErrStr = strerror(errno);
return 0;
}
@@ -186,7 +186,7 @@
struct stat FileInfo;
// TODO: This should use fstat64 when available.
if (fstat(FD, &FileInfo) == -1) {
- if (ErrStr) *ErrStr = "could not get file length";
+ if (ErrStr) *ErrStr = strerror(errno);
::close(FD);
return 0;
}
@@ -230,8 +230,8 @@
// try again
} else {
// error reading.
+ if (ErrStr) *ErrStr = strerror(errno);
close(FD);
- if (ErrStr) *ErrStr = "error reading file data";
return 0;
}
}
More information about the llvm-commits
mailing list