]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1704] Minimize code
authorMukund Sivaraman <muks@isc.org>
Thu, 24 May 2012 06:02:22 +0000 (11:32 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 24 May 2012 06:04:57 +0000 (11:34 +0530)
src/lib/util/interprocess_sync_file.cc
src/lib/util/tests/interprocess_sync_file_unittest.cc

index 197b63f6d3e203b6fa776f04e801115cf3e006d2..237045f3f111c744fe32d478c5209dd747cc2660 100644 (file)
@@ -78,7 +78,7 @@ do_lock(int fd, int cmd, short l_type)
 
     const int status = fcntl(fd, cmd, &lock);
 
-    return ((status == 0) ? true : false);
+    return (status == 0);
 }
 
 bool
index 3dd0ad080105a75df3cee8dc9259ce38006cb071..cc97aa78ec8e03208cd10a0e452ee119e9647f98 100644 (file)
@@ -40,8 +40,6 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
   // done from the same process for the granted range. The lock
   // attempt must fail to pass our check.
 
-  bool was_locked(false);
-
   pipe(fds);
 
   if (fork() == 0) {
@@ -64,18 +62,13 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
       // Parent reads from pipe
       close(fds[1]);
 
-      // Read status and set flag
+      // Read status
       read(fds[0], &locked, sizeof(locked));
-      if (locked == 1) {
-        was_locked = true;
-      } else {
-        was_locked = false;
-      }
-
       close(fds[0]);
+
+      EXPECT_EQ(1, locked);
   }
 
-  EXPECT_TRUE(was_locked);
   EXPECT_TRUE(locker.unlock());
 }
 
@@ -101,8 +94,6 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
 
   int fds[2];
 
-  bool was_not_locked(true);
-
   pipe(fds);
 
   if (fork() == 0) {
@@ -125,18 +116,13 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
       // Parent reads from pipe
       close(fds[1]);
 
-      // Read status and set flag
+      // Read status
       read(fds[0], &locked, sizeof(locked));
-      if (locked == 0) {
-        was_not_locked = true;
-      } else {
-        was_not_locked = false;
-      }
-
       close(fds[0]);
+
+      EXPECT_EQ(0, locked);
   }
 
-  EXPECT_TRUE(was_not_locked);
   EXPECT_TRUE(locker.unlock());
 }