diff options
author | David Robillard <d@drobilla.net> | 2018-09-16 22:11:37 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-16 22:11:37 +0200 |
commit | 0c6bb92f3f59b6b86f3b7b56224677e79b2e6900 (patch) | |
tree | 40e3173eec8b493f22152372cc00782f2a076f92 /raul/Semaphore.hpp | |
parent | 07396e8d23bb8724c5960b57aca33e08a97f4e52 (diff) | |
download | raul-0c6bb92f3f59b6b86f3b7b56224677e79b2e6900.tar.gz raul-0c6bb92f3f59b6b86f3b7b56224677e79b2e6900.tar.bz2 raul-0c6bb92f3f59b6b86f3b7b56224677e79b2e6900.zip |
Lint with clang-tidy
Diffstat (limited to 'raul/Semaphore.hpp')
-rw-r--r-- | raul/Semaphore.hpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/raul/Semaphore.hpp b/raul/Semaphore.hpp index e0fbf18..1dd6e39 100644 --- a/raul/Semaphore.hpp +++ b/raul/Semaphore.hpp @@ -52,7 +52,9 @@ public: Chances are you want 1 wait() per 1 post(), an initial value of 0. */ - inline Semaphore(unsigned initial) { + explicit Semaphore(unsigned initial) + : _sem() + { if (!init(initial)) { throw std::runtime_error("Failed to create semaphore"); } @@ -203,10 +205,7 @@ Semaphore::timed_wait(const std::chrono::duration<Rep, Period>& wait) inline bool Semaphore::init(unsigned initial) { - if (sem_init(&_sem, 0, initial)) { - return false; - } - return true; + return !sem_init(&_sem, 0, initial); } inline void @@ -247,7 +246,7 @@ Semaphore::timed_wait(const std::chrono::duration<Rep, Period>& wait) namespace chr = std::chrono; // Use clock_gettime to ensure sem_timedwait uses the same clock - struct timespec time; + struct timespec time{}; clock_gettime(CLOCK_REALTIME, &time); const auto now(chr::seconds(time.tv_sec) + chr::nanoseconds(time.tv_nsec)); |