Make Unix.h:MakeErrMsg separate the prefix and errno string, so we get:
authorDaniel Dunbar <daniel@zuster.org>
Mon, 20 Apr 2009 20:50:13 +0000 (20:50 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 20 Apr 2009 20:50:13 +0000 (20:50 +0000)
  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/": ").

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69626 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/Memory.inc
lib/System/Unix/Path.inc
lib/System/Unix/Program.inc
lib/System/Unix/Unix.h

index cfc5a6871dc017e5b6a1713a6d05864b0ba578aa..b7a70135bcb76262598dcc8524b57f037da99471 100644 (file)
@@ -76,7 +76,7 @@ llvm::sys::Memory::AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock,
                                 (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 @@ llvm::sys::Memory::AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock,
                   (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
index 4a6b50519980f70b46ea7f3f7eb26a8f031a46ec..6bcb00fa828f3cd61aadef45cf0905589501083e 100644 (file)
@@ -748,7 +748,7 @@ bool
 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 @@ sys::CopyFile(const sys::Path &Dest, const sys::Path &Src, std::string* ErrMsg){
       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 @@ sys::CopyFile(const sys::Path &Dest, const sys::Path &Src, std::string* ErrMsg){
             ::close(inFile);
             ::close(outFile);
             return MakeErrMsg(ErrMsg, Dest.toString() +
-              ": can't write destination file");
+              ": can't write destination file");
           }
         } else {
           Amt -= AmtWritten;
index 2426900578b2696797f2f7923b86e8f6cd801bcb..cdc6fee609491c28f938fcb34f1199229d6815f7 100644 (file)
@@ -99,7 +99,7 @@ static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) {
   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;
   }
 
index b2c3160a415b3e551a348b3148d0e08d358a2f02..452226f4f79ab4bb2eff04964e7ca404782b199a 100644 (file)
@@ -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 @@ static inline bool MakeErrMsg(
   // but, oh well, just use a generic message
   sprintf(buffer, "Error #%d", errnum);
 #endif
-  *ErrMsg = prefix + buffer;
+  *ErrMsg = prefix + ": " + buffer;
   return true;
 }