BIND 10 trac1704_2, updated. 876dd74d15bcaa619602bcb60fc769d541923048 [1704] editorial nits: folded long lines, position of '*', sizeof(), constify.
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed May 23 21:35:50 UTC 2012
The branch, trac1704_2 has been updated
via 876dd74d15bcaa619602bcb60fc769d541923048 (commit)
from 17f327dc2a155c493dfe265cb6fac7b09a7d8836 (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 -----------------------------------------------------------------
commit 876dd74d15bcaa619602bcb60fc769d541923048
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed May 23 14:35:15 2012 -0700
[1704] editorial nits: folded long lines, position of '*', sizeof(), constify.
-----------------------------------------------------------------------
Summary of changes:
src/lib/util/interprocess_sync.h | 10 ++++--
src/lib/util/interprocess_sync_file.cc | 37 ++++++++++----------
src/lib/util/interprocess_sync_file.h | 7 ++--
.../util/tests/interprocess_sync_file_unittest.cc | 32 ++++++++---------
4 files changed, 45 insertions(+), 41 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/util/interprocess_sync.h b/src/lib/util/interprocess_sync.h
index f1183d2..cc08d6a 100644
--- a/src/lib/util/interprocess_sync.h
+++ b/src/lib/util/interprocess_sync.h
@@ -27,7 +27,9 @@ public:
/// \brief Constructor
///
/// Creates a interprocess synchronization object
- InterprocessSync(const std::string component_name) : component_name_(component_name) {}
+ InterprocessSync(const std::string component_name) :
+ component_name_(component_name)
+ {}
/// \brief Destructor
virtual ~InterprocessSync() {}
@@ -49,8 +51,10 @@ public:
virtual ~InterprocessSyncLocker() {}
protected:
- InterprocessSyncLocker(InterprocessSync* sync) : sync_(sync), is_locked_(false) {}
- InterprocessSync *sync_;
+ InterprocessSyncLocker(InterprocessSync* sync) :
+ sync_(sync), is_locked_(false)
+ {}
+ InterprocessSync* sync_;
bool is_locked_;
};
diff --git a/src/lib/util/interprocess_sync_file.cc b/src/lib/util/interprocess_sync_file.cc
index 00da2de..190b84b 100644
--- a/src/lib/util/interprocess_sync_file.cc
+++ b/src/lib/util/interprocess_sync_file.cc
@@ -27,8 +27,8 @@ namespace isc {
namespace util {
InterprocessSyncFile::InterprocessSyncFile(const std::string component_name) :
- InterprocessSync(component_name) {
-
+ InterprocessSync(component_name)
+{
std::string lockfile_path = LOCKFILE_DIR;
const char* const env = getenv("B10_FROM_SOURCE");
@@ -45,13 +45,14 @@ InterprocessSyncFile::InterprocessSyncFile(const std::string component_name) :
// Open the lockfile in the constructor so it doesn't do the access
// checks every time a message is logged.
- mode_t mode = umask(0111);
+ const mode_t mode = umask(0111);
fd_ = open(lockfile_path.c_str(), O_CREAT | O_RDWR, 0660);
umask(mode);
if (fd_ == -1) {
isc_throw(InterprocessSyncFileError,
- "Unable to use interprocess sync lockfile: " + lockfile_path);
+ "Unable to use interprocess sync lockfile: " +
+ lockfile_path);
}
}
@@ -65,14 +66,15 @@ InterprocessSyncFile::~InterprocessSyncFile() {
InterprocessSyncLocker*
InterprocessSyncFile::getLocker() {
- InterprocessSyncLocker *locker = new InterprocessSyncFileLocker(this);
- return locker;
+ InterprocessSyncLocker* locker = new InterprocessSyncFileLocker(this);
+ return (locker);
}
///////////////////////////////////////////////////////////////////////////////////
-InterprocessSyncFileLocker::InterprocessSyncFileLocker(InterprocessSync* sync) :
- InterprocessSyncLocker(sync) {
+InterprocessSyncFileLocker::InterprocessSyncFileLocker(InterprocessSync* sync)
+ : InterprocessSyncLocker(sync)
+{
}
InterprocessSyncFileLocker::~InterprocessSyncFileLocker() {
@@ -85,12 +87,11 @@ InterprocessSyncFileLocker::lock() {
return (true);
}
- InterprocessSyncFile *sync = dynamic_cast<InterprocessSyncFile*>(sync_);
- int fd = sync->getFd();
+ InterprocessSyncFile* sync = dynamic_cast<InterprocessSyncFile*>(sync_);
+ const int fd = sync->getFd();
if (fd != -1) {
struct flock lock;
- int status;
// Acquire the exclusive lock
memset(&lock, 0, sizeof lock);
@@ -99,7 +100,7 @@ InterprocessSyncFileLocker::lock() {
lock.l_start = 0;
lock.l_len = 1;
- status = fcntl(fd, F_SETLKW, &lock);
+ const int status = fcntl(fd, F_SETLKW, &lock);
if (status == 0) {
is_locked_ = true;
return (true);
@@ -115,12 +116,11 @@ InterprocessSyncFileLocker::tryLock() {
return (true);
}
- InterprocessSyncFile *sync = dynamic_cast<InterprocessSyncFile*>(sync_);
- int fd = sync->getFd();
+ InterprocessSyncFile* sync = dynamic_cast<InterprocessSyncFile*>(sync_);
+ const int fd = sync->getFd();
if (fd != -1) {
struct flock lock;
- int status;
// Acquire the exclusive lock
memset(&lock, 0, sizeof lock);
@@ -129,7 +129,7 @@ InterprocessSyncFileLocker::tryLock() {
lock.l_start = 0;
lock.l_len = 1;
- status = fcntl(fd, F_SETLK, &lock);
+ const int status = fcntl(fd, F_SETLK, &lock);
if (status == 0) {
is_locked_ = true;
return (true);
@@ -146,11 +146,10 @@ InterprocessSyncFileLocker::unlock() {
}
InterprocessSyncFile *sync = dynamic_cast<InterprocessSyncFile*>(sync_);
- int fd = sync->getFd();
+ const int fd = sync->getFd();
if (fd != -1) {
struct flock lock;
- int status;
// Release the exclusive lock
memset(&lock, 0, sizeof lock);
@@ -159,7 +158,7 @@ InterprocessSyncFileLocker::unlock() {
lock.l_start = 0;
lock.l_len = 1;
- status = fcntl(fd, F_SETLKW, &lock);
+ const int status = fcntl(fd, F_SETLKW, &lock);
if (status == 0) {
is_locked_ = false;
return (true);
diff --git a/src/lib/util/interprocess_sync_file.h b/src/lib/util/interprocess_sync_file.h
index 4339582..a71e4f9 100644
--- a/src/lib/util/interprocess_sync_file.h
+++ b/src/lib/util/interprocess_sync_file.h
@@ -27,7 +27,8 @@ namespace util {
///
class InterprocessSyncFileError : public Exception {
public:
- InterprocessSyncFileError(const char* file, size_t line, const char* what) :
+ InterprocessSyncFileError(const char* file, size_t line,
+ const char* what) :
isc::Exception(file, line, what) {}
};
@@ -41,8 +42,8 @@ public:
InterprocessSyncLocker* getLocker();
- int getFd() {
- return fd_;
+ int getFd() const {
+ return (fd_);
}
private:
diff --git a/src/lib/util/tests/interprocess_sync_file_unittest.cc b/src/lib/util/tests/interprocess_sync_file_unittest.cc
index 0e478d6..6d9fc32 100644
--- a/src/lib/util/tests/interprocess_sync_file_unittest.cc
+++ b/src/lib/util/tests/interprocess_sync_file_unittest.cc
@@ -26,8 +26,8 @@ protected:
};
TEST_F(InterprocessSyncFileTest, TestLock) {
- InterprocessSync *sync = new InterprocessSyncFile("test");
- InterprocessSyncLocker *locker = sync->getLocker();
+ InterprocessSync* sync = new InterprocessSyncFile("test");
+ InterprocessSyncLocker* locker = sync->getLocker();
EXPECT_TRUE(locker->lock());
@@ -49,8 +49,8 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
// Child writes to pipe
close(fds[0]);
- InterprocessSync *sync2 = new InterprocessSyncFile("test");
- InterprocessSyncLocker *locker2 = sync2->getLocker();
+ InterprocessSync* sync2 = new InterprocessSyncFile("test");
+ InterprocessSyncLocker* locker2 = sync2->getLocker();
if (!locker2->tryLock()) {
locked = 1;
@@ -59,7 +59,7 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
delete locker2;
delete sync2;
- write(fds[1], &locked, sizeof locked);
+ write(fds[1], &locked, sizeof(locked));
close(fds[1]);
exit(0);
} else {
@@ -68,7 +68,7 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
close(fds[1]);
// Read status and set flag
- read(fds[0], &locked, sizeof locked);
+ read(fds[0], &locked, sizeof(locked));
if (locked == 1) {
was_locked = true;
} else {
@@ -86,13 +86,13 @@ TEST_F(InterprocessSyncFileTest, TestLock) {
}
TEST_F(InterprocessSyncFileTest, TestMultipleFilesDirect) {
- InterprocessSync *sync = new InterprocessSyncFile("test1");
- InterprocessSyncLocker *locker = sync->getLocker();
+ InterprocessSync* sync = new InterprocessSyncFile("test1");
+ InterprocessSyncLocker* locker = sync->getLocker();
EXPECT_TRUE(locker->lock());
- InterprocessSync *sync2 = new InterprocessSyncFile("test2");
- InterprocessSyncLocker *locker2 = sync2->getLocker();
+ InterprocessSync* sync2 = new InterprocessSyncFile("test2");
+ InterprocessSyncLocker* locker2 = sync2->getLocker();
EXPECT_TRUE(locker2->lock());
EXPECT_TRUE(locker2->unlock());
delete sync2;
@@ -105,8 +105,8 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesDirect) {
}
TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
- InterprocessSync *sync = new InterprocessSyncFile("test");
- InterprocessSyncLocker *locker = sync->getLocker();
+ InterprocessSync* sync = new InterprocessSyncFile("test");
+ InterprocessSyncLocker* locker = sync->getLocker();
EXPECT_TRUE(locker->lock());
@@ -121,8 +121,8 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
// Child writes to pipe
close(fds[0]);
- InterprocessSync *sync2 = new InterprocessSyncFile("test2");
- InterprocessSyncLocker *locker2 = sync2->getLocker();
+ InterprocessSync* sync2 = new InterprocessSyncFile("test2");
+ InterprocessSyncLocker* locker2 = sync2->getLocker();
if (locker2->tryLock()) {
locked = 0;
@@ -131,7 +131,7 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
delete locker2;
delete sync2;
- write(fds[1], &locked, sizeof locked);
+ write(fds[1], &locked, sizeof(locked));
close(fds[1]);
exit(0);
} else {
@@ -140,7 +140,7 @@ TEST_F(InterprocessSyncFileTest, TestMultipleFilesForked) {
close(fds[1]);
// Read status and set flag
- read(fds[0], &locked, sizeof locked);
+ read(fds[0], &locked, sizeof(locked));
if (locked == 0) {
was_not_locked = true;
} else {
More information about the bind10-changes
mailing list