[Cmake-commits] CMake branch, next, updated. v3.1.0-rc2-1130-gb2dde04

Brad King brad.king at kitware.com
Fri Dec 5 13:01:47 EST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  b2dde0459e93b316d1c9700a466b9fb78c0f1c4f (commit)
       via  97841dad2ba5a79acb0b22db9a01ae45f7b2e80b (commit)
      from  fe1b22fc00e60e37e88eacf31c369018f3eeabe9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b2dde0459e93b316d1c9700a466b9fb78c0f1c4f
commit b2dde0459e93b316d1c9700a466b9fb78c0f1c4f
Merge: fe1b22f 97841da
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Dec 5 13:01:46 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Dec 5 13:01:46 2014 -0500

    Merge topic 'file-LOCK-timeout-type' into next
    
    97841dad file: Use 'long' to represent the parsed LOCK TIMEOUT value


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97841dad2ba5a79acb0b22db9a01ae45f7b2e80b
commit 97841dad2ba5a79acb0b22db9a01ae45f7b2e80b
Author:     Ruslan Baratov <ruslan_baratov at yahoo.com>
AuthorDate: Fri Dec 5 17:18:11 2014 +0300
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Dec 5 12:59:37 2014 -0500

    file: Use 'long' to represent the parsed LOCK TIMEOUT value
    
    Convert the StringToInt helper into a StringToLong helper with a 'long'
    result type.  This will make the helper more useful to other callers
    that want to use strtol.
    
    While at it, also check errno after calling strtol in case the
    conversion fails with a range error.

diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index a6eb8c4..3c2dfa5 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -3521,7 +3521,7 @@ bool cmFileCommand::HandleLockCommand(
   };
   Guard guard = GUARD_PROCESS;
   std::string resultVariable;
-  unsigned timeout = static_cast<unsigned>(-1);
+  unsigned long timeout = static_cast<unsigned long>(-1);
 
   // Parse arguments
   if(args.size() < 2)
@@ -3597,15 +3597,16 @@ bool cmFileCommand::HandleLockCommand(
             "expected timeout value after TIMEOUT");
         return false;
         }
-      int scanned;
-      if(!cmSystemTools::StringToInt(args[i].c_str(), &scanned) || scanned < 0)
+      long scanned;
+      if(!cmSystemTools::StringToLong(args[i].c_str(), &scanned)
+         || scanned < 0)
         {
         cmOStringStream e;
         e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer.";
         this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
         return false;
         }
-      timeout = static_cast<unsigned>(scanned);
+      timeout = static_cast<unsigned long>(scanned);
       }
     else
       {
diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx
index 5f75637..e6aa5f4 100644
--- a/Source/cmFileLock.cxx
+++ b/Source/cmFileLock.cxx
@@ -28,7 +28,7 @@ cmFileLock::~cmFileLock()
 }
 
 cmFileLockResult cmFileLock::Lock(
-    const std::string& filename, unsigned timeout)
+    const std::string& filename, unsigned long timeout)
 {
   if (filename.empty())
     {
@@ -48,7 +48,7 @@ cmFileLockResult cmFileLock::Lock(
   cmFileLockResult result = this->OpenFile();
   if (result.IsOk())
     {
-    if (timeout == static_cast<unsigned>(-1))
+    if (timeout == static_cast<unsigned long>(-1))
       {
       result = this->LockWithoutTimeout();
       }
diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h
index 4d922a0..dd959a7 100644
--- a/Source/cmFileLock.h
+++ b/Source/cmFileLock.h
@@ -37,7 +37,7 @@ class cmFileLock
     * @brief Lock the file.
     * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
     */
-  cmFileLockResult Lock(const std::string& filename, unsigned timeoutSec);
+  cmFileLockResult Lock(const std::string& filename, unsigned long timeoutSec);
 
   /**
     * @brief Unlock the file.
@@ -57,7 +57,7 @@ class cmFileLock
 
   cmFileLockResult OpenFile();
   cmFileLockResult LockWithoutTimeout();
-  cmFileLockResult LockWithTimeout(unsigned timeoutSec);
+  cmFileLockResult LockWithTimeout(unsigned long timeoutSec);
 
 #if defined(_WIN32)
   typedef HANDLE FileId;
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index e84e71a..551a75a 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -60,7 +60,7 @@ void cmFileLockPool::PopFileScope()
 }
 
 cmFileLockResult cmFileLockPool::LockFunctionScope(
-    const std::string& filename, unsigned timeoutSec)
+    const std::string& filename, unsigned long timeoutSec)
 {
   if (this->IsAlreadyLocked(filename))
     {
@@ -74,7 +74,7 @@ cmFileLockResult cmFileLockPool::LockFunctionScope(
 }
 
 cmFileLockResult cmFileLockPool::LockFileScope(
-    const std::string& filename, unsigned timeoutSec)
+    const std::string& filename, unsigned long timeoutSec)
 {
   if (this->IsAlreadyLocked(filename))
     {
@@ -85,7 +85,7 @@ cmFileLockResult cmFileLockPool::LockFileScope(
 }
 
 cmFileLockResult cmFileLockPool::LockProcessScope(
-    const std::string& filename, unsigned timeoutSec)
+    const std::string& filename, unsigned long timeoutSec)
 {
   if (this->IsAlreadyLocked(filename))
     {
@@ -155,7 +155,7 @@ cmFileLockPool::ScopePool::~ScopePool()
 }
 
 cmFileLockResult cmFileLockPool::ScopePool::Lock(
-    const std::string& filename, unsigned timeoutSec)
+    const std::string& filename, unsigned long timeoutSec)
 {
   cmFileLock *lock = new cmFileLock();
   const cmFileLockResult result = lock->Lock(filename, timeoutSec);
diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h
index a63540c..baef310 100644
--- a/Source/cmFileLockPool.h
+++ b/Source/cmFileLockPool.h
@@ -45,13 +45,13 @@ class cmFileLockPool
     * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
     */
   cmFileLockResult LockFunctionScope(
-      const std::string& filename, unsigned timeoutSec
+      const std::string& filename, unsigned long timeoutSec
   );
   cmFileLockResult LockFileScope(
-      const std::string& filename, unsigned timeoutSec
+      const std::string& filename, unsigned long timeoutSec
   );
   cmFileLockResult LockProcessScope(
-      const std::string& filename, unsigned timeoutSec
+      const std::string& filename, unsigned long timeoutSec
   );
   //@}
 
@@ -72,7 +72,9 @@ class cmFileLockPool
     ScopePool();
     ~ScopePool();
 
-    cmFileLockResult Lock(const std::string& filename, unsigned timeoutSec);
+    cmFileLockResult Lock(
+        const std::string& filename, unsigned long timeoutSec
+    );
     cmFileLockResult Release(const std::string& filename);
     bool IsAlreadyLocked(const std::string& filename) const;
 
diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx
index 038011e..fc18a64 100644
--- a/Source/cmFileLockUnix.cxx
+++ b/Source/cmFileLockUnix.cxx
@@ -66,7 +66,7 @@ cmFileLockResult cmFileLock::LockWithoutTimeout()
     }
 }
 
-cmFileLockResult cmFileLock::LockWithTimeout(unsigned seconds)
+cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
 {
   while (true)
     {
diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx
index 17231ea..4691689 100644
--- a/Source/cmFileLockWin32.cxx
+++ b/Source/cmFileLockWin32.cxx
@@ -86,7 +86,7 @@ cmFileLockResult cmFileLock::LockWithoutTimeout()
     }
 }
 
-cmFileLockResult cmFileLock::LockWithTimeout(unsigned seconds)
+cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
 {
   const DWORD flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
   while (true)
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 9852dd6..c83dc2a 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2925,9 +2925,10 @@ std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
 }
 
 //----------------------------------------------------------------------------
-bool cmSystemTools::StringToInt(const char* str, int* value)
+bool cmSystemTools::StringToLong(const char* str, long* value)
 {
+  errno = 0;
   char *endp;
-  *value = static_cast<int>(strtol(str, &endp, 10));
-  return (*endp == '\0') && (endp != str);
+  *value = strtol(str, &endp, 10);
+  return (*endp == '\0') && (endp != str) && (errno == 0);
 }
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 763389b..d49af74 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -458,8 +458,8 @@ public:
   static std::vector<std::string> tokenize(const std::string& str,
                                            const std::string& sep);
 
-  /** Convert string to int. Expected that the whole string is an integer */
-  static bool StringToInt(const char* str, int* value);
+  /** Convert string to long. Expected that the whole string is an integer */
+  static bool StringToLong(const char* str, long* value);
 
 #ifdef _WIN32
   struct WindowsFileRetry

-----------------------------------------------------------------------

Summary of changes:
 Source/cmFileCommand.cxx   |    9 +++++----
 Source/cmFileLock.cxx      |    4 ++--
 Source/cmFileLock.h        |    4 ++--
 Source/cmFileLockPool.cxx  |    8 ++++----
 Source/cmFileLockPool.h    |   10 ++++++----
 Source/cmFileLockUnix.cxx  |    2 +-
 Source/cmFileLockWin32.cxx |    2 +-
 Source/cmSystemTools.cxx   |    7 ++++---
 Source/cmSystemTools.h     |    4 ++--
 9 files changed, 27 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list