diff options
author | David Robillard <d@drobilla.net> | 2020-12-19 11:58:34 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-19 12:02:24 +0100 |
commit | 2a09c19703b242aaf693e5b52a70c1ad65332119 (patch) | |
tree | fcaf9fdffa4dcb80a74fc4e1b2c90e81e7e20fb6 | |
parent | 5680e5900f6fb89ec66af6480a7d125fc8960552 (diff) | |
download | raul-2a09c19703b242aaf693e5b52a70c1ad65332119.tar.gz raul-2a09c19703b242aaf693e5b52a70c1ad65332119.tar.bz2 raul-2a09c19703b242aaf693e5b52a70c1ad65332119.zip |
Avoid "else" after "return"
-rw-r--r-- | include/.clang-tidy | 1 | ||||
-rw-r--r-- | include/raul/DoubleBuffer.hpp | 4 | ||||
-rw-r--r-- | include/raul/Path.hpp | 21 | ||||
-rw-r--r-- | include/raul/RingBuffer.hpp | 16 | ||||
-rw-r--r-- | include/raul/Socket.hpp | 5 | ||||
-rw-r--r-- | include/raul/Symbol.hpp | 4 | ||||
-rw-r--r-- | test/.clang-tidy | 2 | ||||
-rw-r--r-- | test/socket_test.cpp | 4 |
8 files changed, 33 insertions, 24 deletions
diff --git a/include/.clang-tidy b/include/.clang-tidy index 3ed1d44..b209887 100644 --- a/include/.clang-tidy +++ b/include/.clang-tidy @@ -19,7 +19,6 @@ Checks: > -google-runtime-int, -hicpp-no-array-decay, -modernize-use-trailing-return-type, - -readability-else-after-return, -readability-implicit-bool-conversion, WarningsAsErrors: '*' HeaderFilterRegex: '.*' diff --git a/include/raul/DoubleBuffer.hpp b/include/raul/DoubleBuffer.hpp index 73b5565..f6ab826 100644 --- a/include/raul/DoubleBuffer.hpp +++ b/include/raul/DoubleBuffer.hpp @@ -62,7 +62,9 @@ public: _vals[1] = std::move(new_val); _state.store(State::WRITE_READ, std::memory_order_release); return true; - } else if (transition(State::WRITE_READ, State::LOCK_READ)) { + } + + if (transition(State::WRITE_READ, State::LOCK_READ)) { // Locked _vals[0] for writing _vals[0] = std::move(new_val); _state.store(State::READ_WRITE, std::memory_order_release); diff --git a/include/raul/Path.hpp b/include/raul/Path.hpp index f0168b7..4fb3da1 100644 --- a/include/raul/Path.hpp +++ b/include/raul/Path.hpp @@ -95,10 +95,14 @@ public: for (size_t i = 1; i < str.length(); ++i) { if (!is_valid_char(str[i])) { return false; // All characters must be /, _, a-z, A-Z, 0-9 - } else if (str[i - 1] == '/') { + } + + if (str[i - 1] == '/') { if (str[i] == '/') { return false; // Must not contain "//" - } else if (!Symbol::is_valid_start_char(str[i])) { + } + + if (!Symbol::is_valid_start_char(str[i])) { return false; // Invalid symbol start character (digit) } } @@ -145,12 +149,11 @@ public: inline Path parent() const { if (is_root()) { return *this; - } else { - const size_t first_sep = find('/'); - const size_t last_sep = find_last_of('/'); - return (first_sep == last_sep) - ? Path("/") : Path(substr(0, last_sep)); } + + const size_t first_sep = find('/'); + const size_t last_sep = find_last_of('/'); + return (first_sep == last_sep) ? Path("/") : Path(substr(0, last_sep)); } /** Return a child Path of this path. */ @@ -171,9 +174,9 @@ public: inline std::string base() const { if (is_root()) { return *this; - } else { - return *this + '/'; } + + return *this + '/'; } /** Return the lowest common ancestor of a and b. */ diff --git a/include/raul/RingBuffer.hpp b/include/raul/RingBuffer.hpp index 176fe92..b83f442 100644 --- a/include/raul/RingBuffer.hpp +++ b/include/raul/RingBuffer.hpp @@ -105,9 +105,9 @@ public: std::atomic_thread_fence(std::memory_order_acquire); _read_head = (r + size) & _size_mask; return size; - } else { - return 0; } + + return 0; } /** @@ -170,19 +170,21 @@ private: inline uint32_t write_space_internal(uint32_t r, uint32_t w) const { if (r == w) { return _size - 1; - } else if (r < w) { + } + + if (r < w) { return ((r - w + _size) & _size_mask) - 1; - } else { - return (r - w) - 1; } + + return (r - w) - 1; } inline uint32_t read_space_internal(uint32_t r, uint32_t w) const { if (r < w) { return w - r; - } else { - return (w - r + _size) & _size_mask; } + + return (w - r + _size) & _size_mask; } inline uint32_t peek_internal(uint32_t r, uint32_t w, diff --git a/include/raul/Socket.hpp b/include/raul/Socket.hpp index 66b5a45..74a1595 100644 --- a/include/raul/Socket.hpp +++ b/include/raul/Socket.hpp @@ -159,7 +159,9 @@ Socket::set_addr(const std::string& uri) _addr = reinterpret_cast<sockaddr*>(uaddr); _addr_len = sizeof(struct sockaddr_un); return true; - } else if (_type == Type::TCP && uri.find("://") != std::string::npos) { + } + + if (_type == Type::TCP && uri.find("://") != std::string::npos) { const std::string authority = uri.substr(uri.find("://") + 3); const size_t port_sep = authority.find(':'); if (port_sep == std::string::npos) { @@ -184,6 +186,7 @@ Socket::set_addr(const std::string& uri) freeaddrinfo(ainfo); return true; } + return false; } diff --git a/include/raul/Symbol.hpp b/include/raul/Symbol.hpp index 4814334..4f762f8 100644 --- a/include/raul/Symbol.hpp +++ b/include/raul/Symbol.hpp @@ -120,9 +120,9 @@ public: if (is_valid_start_char(out[0])) { return Symbol(out); - } else { - return Symbol(std::string("_") + out); } + + return Symbol(std::string("_") + out); } }; diff --git a/test/.clang-tidy b/test/.clang-tidy index 023fd87..4d343a6 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -22,11 +22,9 @@ Checks: > -hicpp-no-array-decay, -hicpp-no-malloc, -hicpp-signed-bitwise, - -llvm-else-after-return, -llvmlibc-*, -modernize-make-unique, -modernize-use-trailing-return-type, - -readability-else-after-return, -readability-implicit-bool-conversion, -readability-use-anyofallof, CheckOptions: diff --git a/test/socket_test.cpp b/test/socket_test.cpp index 0a7a75c..bf0fd33 100644 --- a/test/socket_test.cpp +++ b/test/socket_test.cpp @@ -63,7 +63,9 @@ main() if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) { break; - } else if (ret == 0) { + } + + if (ret == 0) { fprintf(stderr, "poll returned with no data\n"); continue; } |