summaryrefslogtreecommitdiffstats
path: root/Source/cmFileLockUnix.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmFileLockUnix.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/cmFileLockUnix.cxx')
-rw-r--r--Source/cmFileLockUnix.cxx61
1 files changed, 23 insertions, 38 deletions
diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx
index f5e77be..6be6abc 100644
--- a/Source/cmFileLockUnix.cxx
+++ b/Source/cmFileLockUnix.cxx
@@ -18,16 +18,16 @@
#include <stdio.h> // SEEK_SET
#include <unistd.h>
-cmFileLock::cmFileLock(): File(-1)
+cmFileLock::cmFileLock()
+ : File(-1)
{
}
cmFileLockResult cmFileLock::Release()
{
- if (this->Filename.empty())
- {
+ if (this->Filename.empty()) {
return cmFileLockResult::MakeOk();
- }
+ }
const int lockResult = this->LockFile(F_SETLK, F_UNLCK);
this->Filename = "";
@@ -35,71 +35,56 @@ cmFileLockResult cmFileLock::Release()
::close(this->File);
this->File = -1;
- if (lockResult == 0)
- {
+ if (lockResult == 0) {
return cmFileLockResult::MakeOk();
- }
- else
- {
+ } else {
return cmFileLockResult::MakeSystem();
- }
+ }
}
cmFileLockResult cmFileLock::OpenFile()
{
this->File = ::open(this->Filename.c_str(), O_RDWR);
- if (this->File == -1)
- {
+ if (this->File == -1) {
return cmFileLockResult::MakeSystem();
- }
- else
- {
+ } else {
return cmFileLockResult::MakeOk();
- }
+ }
}
cmFileLockResult cmFileLock::LockWithoutTimeout()
{
- if (this->LockFile(F_SETLKW, F_WRLCK) == -1)
- {
+ if (this->LockFile(F_SETLKW, F_WRLCK) == -1) {
return cmFileLockResult::MakeSystem();
- }
- else
- {
+ } else {
return cmFileLockResult::MakeOk();
- }
+ }
}
cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
{
- while (true)
- {
- if (this->LockFile(F_SETLK, F_WRLCK) == -1)
- {
- if (errno != EACCES && errno != EAGAIN)
- {
+ while (true) {
+ if (this->LockFile(F_SETLK, F_WRLCK) == -1) {
+ if (errno != EACCES && errno != EAGAIN) {
return cmFileLockResult::MakeSystem();
- }
}
- else
- {
+ } else {
return cmFileLockResult::MakeOk();
- }
- if (seconds == 0)
- {
+ }
+ if (seconds == 0) {
return cmFileLockResult::MakeTimeout();
- }
+ }
--seconds;
cmSystemTools::Delay(1000);
- }
+ }
}
int cmFileLock::LockFile(int cmd, int type)
{
struct ::flock lock;
lock.l_start = 0;
- lock.l_len = 0; // lock all bytes
- lock.l_pid = 0; // unused (for F_GETLK only)
+ lock.l_len = 0; // lock all bytes
+ lock.l_pid = 0; // unused (for F_GETLK only)
lock.l_type = static_cast<short>(type); // exclusive lock
lock.l_whence = SEEK_SET;
return ::fcntl(this->File, cmd, &lock);