[llvm-commits] [llvm] r69626 - in /llvm/trunk/lib/System/Unix: Memory.inc Path.inc Program.inc Unix.h
Daniel Dunbar
daniel at zuster.org
Mon Apr 20 13:50:13 PDT 2009
Author: ddunbar
Date: Mon Apr 20 15:50:13 2009
New Revision: 69626
URL: http://llvm.org/viewvc/llvm-project?rev=69626&view=rev
Log:
Make Unix.h:MakeErrMsg separate the prefix and errno string, so we get:
clang: error: unable to make temporary file: /etc/cc: can't make
unique filename: Permission denied
instead of
clang: error: unable to make temporary file: /etc/cc: can't make
unique filenamePermission denied
for example.
Also, audited the uses of MakeErrMsg to make the prefix strings
consistent (not end with newline/punctuation/space/": ").
Modified:
llvm/trunk/lib/System/Unix/Memory.inc
llvm/trunk/lib/System/Unix/Path.inc
llvm/trunk/lib/System/Unix/Program.inc
llvm/trunk/lib/System/Unix/Unix.h
Modified: llvm/trunk/lib/System/Unix/Memory.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Memory.inc?rev=69626&r1=69625&r2=69626&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Memory.inc (original)
+++ llvm/trunk/lib/System/Unix/Memory.inc Mon Apr 20 15:50:13 2009
@@ -76,7 +76,7 @@
(vm_size_t)(pageSize*NumPages), 0,
VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY);
if (KERN_SUCCESS != kr) {
- MakeErrMsg(ErrMsg, "vm_protect max RX failed\n");
+ MakeErrMsg(ErrMsg, "vm_protect max RX failed");
return sys::MemoryBlock();
}
@@ -84,7 +84,7 @@
(vm_size_t)(pageSize*NumPages), 0,
VM_PROT_READ | VM_PROT_WRITE);
if (KERN_SUCCESS != kr) {
- MakeErrMsg(ErrMsg, "vm_protect RW failed\n");
+ MakeErrMsg(ErrMsg, "vm_protect RW failed");
return sys::MemoryBlock();
}
#endif
Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=69626&r1=69625&r2=69626&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Mon Apr 20 15:50:13 2009
@@ -748,7 +748,7 @@
Path::renamePathOnDisk(const Path& newName, std::string* ErrMsg) {
if (0 != ::rename(path.c_str(), newName.c_str()))
return MakeErrMsg(ErrMsg, std::string("can't rename '") + path + "' as '" +
- newName.toString() + "' ");
+ newName.toString() + "'");
return false;
}
@@ -786,7 +786,7 @@
if (errno != EINTR && errno != EAGAIN) {
::close(inFile);
::close(outFile);
- return MakeErrMsg(ErrMsg, Src.toString()+": can't read source file: ");
+ return MakeErrMsg(ErrMsg, Src.toString()+": can't read source file");
}
} else {
char *BufPtr = Buffer;
@@ -797,7 +797,7 @@
::close(inFile);
::close(outFile);
return MakeErrMsg(ErrMsg, Dest.toString() +
- ": can't write destination file: ");
+ ": can't write destination file");
}
} else {
Amt -= AmtWritten;
Modified: llvm/trunk/lib/System/Unix/Program.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=69626&r1=69625&r2=69626&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Program.inc (original)
+++ llvm/trunk/lib/System/Unix/Program.inc Mon Apr 20 15:50:13 2009
@@ -99,7 +99,7 @@
int InFD = open(File.c_str(), FD == 0 ? O_RDONLY : O_WRONLY|O_CREAT, 0666);
if (InFD == -1) {
MakeErrMsg(ErrMsg, "Cannot open file '" + File + "' for "
- + (FD == 0 ? "input" : "output") + "!\n");
+ + (FD == 0 ? "input" : "output"));
return true;
}
Modified: llvm/trunk/lib/System/Unix/Unix.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Unix.h?rev=69626&r1=69625&r2=69626&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Unix.h (original)
+++ llvm/trunk/lib/System/Unix/Unix.h Mon Apr 20 15:50:13 2009
@@ -70,6 +70,9 @@
/// string and the Unix error number given by \p errnum. If errnum is -1, the
/// default then the value of errno is used.
/// @brief Make an error message
+///
+/// If the error number can be converted to a string, it will be
+/// separated from prefix by ": ".
static inline bool MakeErrMsg(
std::string* ErrMsg, const std::string& prefix, int errnum = -1) {
if (!ErrMsg)
@@ -94,7 +97,7 @@
// but, oh well, just use a generic message
sprintf(buffer, "Error #%d", errnum);
#endif
- *ErrMsg = prefix + buffer;
+ *ErrMsg = prefix + ": " + buffer;
return true;
}
More information about the llvm-commits
mailing list