diff options
author | David Robillard <d@drobilla.net> | 2018-09-16 21:37:34 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-16 21:50:04 +0200 |
commit | 07396e8d23bb8724c5960b57aca33e08a97f4e52 (patch) | |
tree | 8699e538e4c4b6cded707ebce46d8c6bc3e5a78e | |
parent | e911351fcc631cd511bfdac93687669028136f79 (diff) | |
download | raul-07396e8d23bb8724c5960b57aca33e08a97f4e52.tar.gz raul-07396e8d23bb8724c5960b57aca33e08a97f4e52.tar.bz2 raul-07396e8d23bb8724c5960b57aca33e08a97f4e52.zip |
Remove C casts
-rw-r--r-- | raul/Process.hpp | 2 | ||||
-rw-r--r-- | raul/RingBuffer.hpp | 8 | ||||
-rw-r--r-- | raul/Socket.hpp | 12 |
3 files changed, 13 insertions, 9 deletions
diff --git a/raul/Process.hpp b/raul/Process.hpp index 0b3a819..5804775 100644 --- a/raul/Process.hpp +++ b/raul/Process.hpp @@ -59,7 +59,7 @@ public: case 0: // (in grandchild) setsid(); - execvp(argv[0], (char*const*)argv); + execvp(argv[0], const_cast<char*const*>(argv)); _exit(-1); case -1: diff --git a/raul/RingBuffer.hpp b/raul/RingBuffer.hpp index 574b8b8..dfe5dd2 100644 --- a/raul/RingBuffer.hpp +++ b/raul/RingBuffer.hpp @@ -146,7 +146,9 @@ public: assert(this_size < size); assert(w + this_size <= _size); memcpy(&_buf[w], src, this_size); - memcpy(&_buf[0], (const char*)src + this_size, size - this_size); + memcpy(&_buf[0], + static_cast<const char*>(src) + this_size, + size - this_size); std::atomic_thread_fence(std::memory_order_release); _write_head = size - this_size; } @@ -196,7 +198,9 @@ private: } else { const uint32_t first_size = _size - r; memcpy(dst, &_buf[r], first_size); - memcpy((char*)dst + first_size, &_buf[0], size - first_size); + memcpy(static_cast<char*>(dst) + first_size, + &_buf[0], + size - first_size); } return size; diff --git a/raul/Socket.hpp b/raul/Socket.hpp index 7da4388..d41e0dc 100644 --- a/raul/Socket.hpp +++ b/raul/Socket.hpp @@ -151,12 +151,12 @@ Socket::set_addr(const std::string& uri) free(_addr); if (_type == Type::UNIX && uri.substr(0, strlen("unix://")) == "unix://") { const std::string path = uri.substr(strlen("unix://")); - struct sockaddr_un* uaddr = (struct sockaddr_un*)calloc( - 1, sizeof(struct sockaddr_un)); + struct sockaddr_un* uaddr = static_cast<struct sockaddr_un*>( + calloc(1, sizeof(struct sockaddr_un))); uaddr->sun_family = AF_UNIX; strncpy(uaddr->sun_path, path.c_str(), sizeof(uaddr->sun_path) - 1); _uri = uri; - _addr = (sockaddr*)uaddr; + _addr = reinterpret_cast<sockaddr*>(uaddr); _addr_len = sizeof(struct sockaddr_un); return true; } else if (_type == Type::TCP && uri.find("://") != std::string::npos) { @@ -179,7 +179,7 @@ Socket::set_addr(const std::string& uri) } _uri = uri; - _addr = (struct sockaddr*)malloc(ainfo->ai_addrlen); + _addr = static_cast<struct sockaddr*>(malloc(ainfo->ai_addrlen)); _addr_len = ainfo->ai_addrlen; memcpy(_addr, ainfo->ai_addr, ainfo->ai_addrlen); freeaddrinfo(ainfo); @@ -222,8 +222,8 @@ inline std::shared_ptr<Socket> Socket::accept() { socklen_t client_addr_len = _addr_len; - struct sockaddr* client_addr = (struct sockaddr*)calloc( - 1, client_addr_len); + struct sockaddr* client_addr = static_cast<struct sockaddr*>( + calloc(1, client_addr_len)); const int conn = ::accept(_sock, client_addr, &client_addr_len); if (conn == -1) { |