Parcourir la source

[1704] style matters: long line, () for return, const, { position.

also change 'const string' to 'const string&' in some places
JINMEI Tatuya il y a 13 ans
Parent
commit
227d01775b

+ 2 - 2
src/lib/log/logger_impl.h

@@ -186,8 +186,8 @@ public:
     }
 
 private:
-    std::string                  name_;              ///< Full name of this logger
-    log4cplus::Logger            logger_;            ///< Underlying log4cplus logger
+    std::string                  name_;   ///< Full name of this logger
+    log4cplus::Logger            logger_; ///< Underlying log4cplus logger
     isc::util::InterprocessSync* sync_;
 };
 

+ 9 - 8
src/lib/log/tests/logger_unittest.cc

@@ -386,31 +386,32 @@ TEST_F(LoggerTest, LoggerNameLength) {
 class MockSync : public isc::util::InterprocessSync {
 public:
     /// \brief Constructor
-    MockSync(const std::string component_name) :
-        InterprocessSync(component_name), was_locked_(false), was_unlocked_(false)
+    MockSync(const std::string& component_name) :
+        InterprocessSync(component_name), was_locked_(false),
+        was_unlocked_(false)
     {}
 
     bool wasLocked() const {
-        return was_locked_;
+        return (was_locked_);
     }
 
     bool wasUnlocked() const {
-        return was_unlocked_;
+        return (was_unlocked_);
     }
 
 protected:
     bool lock() {
         was_locked_ = true;
-        return true;
+        return (true);
     }
 
     bool tryLock() {
-        return true;
+        return (true);
     }
 
     bool unlock() {
         was_unlocked_ = true;
-        return true;
+        return (true);
     }
 
 private:
@@ -427,7 +428,7 @@ TEST_F(LoggerTest, Lock) {
 
     // Setup our own mock sync object so that we can intercept the lock
     // call and check if a lock has been taken.
-    MockSync *sync = new MockSync("logger");
+    MockSync* sync = new MockSync("logger");
     logger.setInterprocessSync(sync);
 
     // Log a message and put things into play.

+ 5 - 5
src/lib/util/interprocess_sync.h

@@ -28,7 +28,7 @@ public:
     /// \brief Constructor
     ///
     /// Creates a interprocess synchronization object
-    InterprocessSync(const std::string component_name) :
+    InterprocessSync(const std::string& component_name) :
         component_name_(component_name), is_locked_(false)
     {}
 
@@ -40,7 +40,7 @@ protected:
     virtual bool tryLock() = 0;
     virtual bool unlock() = 0;
 
-    std::string component_name_;
+    const std::string component_name_;
     bool is_locked_;
 };
 
@@ -56,15 +56,15 @@ public:
     }
 
     bool lock() {
-        return sync_.lock();
+        return (sync_.lock());
     }
 
     bool tryLock() {
-        return sync_.tryLock();
+        return (sync_.tryLock());
     }
 
     bool unlock() {
-        return sync_.unlock();
+        return (sync_.unlock());
     }
 
 protected:

+ 1 - 2
src/lib/util/interprocess_sync_file.cc

@@ -36,8 +36,7 @@ InterprocessSyncFile::~InterprocessSyncFile() {
 }
 
 bool
-InterprocessSyncFile::do_lock(int cmd, short l_type)
-{
+InterprocessSyncFile::do_lock(int cmd, short l_type) {
     // Open lock file only when necessary (i.e., here). This is so that
     // if a default InterprocessSync object is replaced with another
     // implementation, it doesn't attempt any opens.

+ 1 - 1
src/lib/util/interprocess_sync_file.h

@@ -35,7 +35,7 @@ public:
 class InterprocessSyncFile : public InterprocessSync {
 public:
     /// \brief Constructor
-    InterprocessSyncFile(const std::string component_name) :
+    InterprocessSyncFile(const std::string& component_name) :
         InterprocessSync(component_name), fd_(-1)
     {}
 

+ 2 - 2
src/lib/util/tests/interprocess_sync_file_unittest.cc

@@ -65,7 +65,7 @@ TEST(InterprocessSyncFileTest, TestLock) {
       tv.tv_sec = 5;
       tv.tv_usec = 0;
 
-      int nfds = select(fds[0] + 1, &rfds, NULL, NULL, &tv);
+      const int nfds = select(fds[0] + 1, &rfds, NULL, NULL, &tv);
       EXPECT_EQ(1, nfds);
 
       if (nfds == 1) {
@@ -133,7 +133,7 @@ TEST(InterprocessSyncFileTest, TestMultipleFilesForked) {
       tv.tv_sec = 5;
       tv.tv_usec = 0;
 
-      int nfds = select(fds[0] + 1, &rfds, NULL, NULL, &tv);
+      const int nfds = select(fds[0] + 1, &rfds, NULL, NULL, &tv);
       EXPECT_EQ(1, nfds);
 
       if (nfds == 1) {