diff --git a/src/dpp/socketengines/epoll.cpp b/src/dpp/socketengines/epoll.cpp index e092a7ba70..c38439cdf0 100644 --- a/src/dpp/socketengines/epoll.cpp +++ b/src/dpp/socketengines/epoll.cpp @@ -60,7 +60,7 @@ struct socket_engine_epoll : public socket_engine_base { socket_engine_epoll& operator=(const socket_engine_epoll&) = delete; socket_engine_epoll& operator=(socket_engine_epoll&&) = delete; - socket_engine_epoll(cluster* creator) : socket_engine_base(creator), epoll_handle(epoll_create(socket_engine_epoll::epoll_hint)) { + explicit socket_engine_epoll(cluster* creator) : socket_engine_base(creator), epoll_handle(epoll_create(socket_engine_epoll::epoll_hint)) { events.resize(socket_engine_epoll::epoll_hint); if (epoll_handle == -1) { throw dpp::connection_exception("Failed to initialise epoll()"); diff --git a/src/dpp/socketengines/kqueue.cpp b/src/dpp/socketengines/kqueue.cpp index 4a6e9a8d9e..8d75ad4028 100644 --- a/src/dpp/socketengines/kqueue.cpp +++ b/src/dpp/socketengines/kqueue.cpp @@ -49,7 +49,7 @@ struct socket_engine_kqueue : public socket_engine_base { socket_engine_kqueue& operator=(const socket_engine_kqueue&) = default; socket_engine_kqueue& operator=(socket_engine_kqueue&&) = default; - socket_engine_kqueue(cluster* creator) : socket_engine_base(creator), kqueue_handle(kqueue()) { + explicit socket_engine_kqueue(cluster* creator) : socket_engine_base(creator), kqueue_handle(kqueue()) { change_list.resize(8); ke_list.resize(16); if (kqueue_handle == -1) { diff --git a/src/dpp/socketengines/poll.cpp b/src/dpp/socketengines/poll.cpp index f192c40a33..6b9b09eb4f 100644 --- a/src/dpp/socketengines/poll.cpp +++ b/src/dpp/socketengines/poll.cpp @@ -145,7 +145,7 @@ struct socket_engine_poll : public socket_engine_base { return r; } - socket_engine_poll(cluster* creator) : socket_engine_base(creator) { }; + explicit socket_engine_poll(cluster* creator) : socket_engine_base(creator) { }; protected: diff --git a/src/sockettest/socket.cpp b/src/sockettest/socket.cpp index e6e19e652d..08ce6b12da 100644 --- a/src/sockettest/socket.cpp +++ b/src/sockettest/socket.cpp @@ -22,10 +22,9 @@ #include #include -#include #include #include -#include +#include int main() { dpp::cluster cl("no-token"); @@ -51,7 +50,7 @@ int main() { int r = 0; do { char buf[128]{0}; - r = ::read(e.fd, buf, 127); + r = ::read(e.fd, buf, sizeof(buf)); if (r > 0) { buf[127] = 0; std::cout << buf; @@ -65,7 +64,9 @@ int main() { }, [](dpp::socket fd, const struct dpp::socket_events& e) { std::cout << "WANT_WRITE event on socket " << fd << "\n"; - ::write(e.fd, "GET / HTTP/1.0\r\nConnection: close\r\n\r\n", strlen("GET / HTTP/1.0\r\nConnection: close\r\n\r\n")); + constexpr std::string_view request{"GET / HTTP/1.0\r\nConnection: close\r\n\r\n"}; + auto written = ::write(e.fd, request.data(), request.length()); + std::cout << "Written: " << written << "\n"; }, [](dpp::socket fd, const struct dpp::socket_events&, int error_code) { std::cout << "WANT_ERROR event on socket " << fd << " with code " << error_code << "\n";