From dab39dc778217c28cee4e9f2a14aa8dfadb915a2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 19 Aug 2019 21:16:29 +0200 Subject: [PATCH] lib/curl: fix coding style --- src/lib/curl/Global.cxx | 37 +++++++++++++++++++------------------ src/lib/curl/Global.hxx | 4 ++-- src/lib/curl/Slist.hxx | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/lib/curl/Global.cxx b/src/lib/curl/Global.cxx index 0cd8b533d..bd4494b7a 100644 --- a/src/lib/curl/Global.cxx +++ b/src/lib/curl/Global.cxx @@ -48,7 +48,7 @@ public: CurlSocket(CurlGlobal &_global, EventLoop &_loop, SocketDescriptor _fd) :SocketMonitor(_fd, _loop), global(_global) {} - ~CurlSocket() { + ~CurlSocket() noexcept { /* TODO: sometimes, CURL uses CURL_POLL_REMOVE after closing the socket, and sometimes, it uses CURL_POLL_REMOVE just to move the (still open) @@ -109,7 +109,8 @@ CurlGlobal::CurlGlobal(EventLoop &_loop) int CurlSocket::SocketFunction(gcc_unused CURL *easy, curl_socket_t s, int action, - void *userp, void *socketp) noexcept { + void *userp, void *socketp) noexcept +{ auto &global = *(CurlGlobal *)userp; CurlSocket *cs = (CurlSocket *)socketp; @@ -217,6 +218,20 @@ CurlGlobal::ReadInfo() noexcept } } +void +CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask) noexcept +{ + int running_handles; + CURLMcode mcode = curl_multi_socket_action(multi.Get(), fd, ev_bitmask, + &running_handles); + if (mcode != CURLM_OK) + FormatError(curlm_domain, + "curl_multi_socket_action() failed: %s", + curl_multi_strerror(mcode)); + + defer_read_info.Schedule(); +} + inline void CurlGlobal::UpdateTimeout(long timeout_ms) noexcept { @@ -236,11 +251,11 @@ CurlGlobal::UpdateTimeout(long timeout_ms) noexcept } int -CurlGlobal::TimerFunction(gcc_unused CURLM *_global, long timeout_ms, +CurlGlobal::TimerFunction(gcc_unused CURLM *_multi, long timeout_ms, void *userp) noexcept { auto &global = *(CurlGlobal *)userp; - assert(_global == global.multi.Get()); + assert(_multi == global.multi.Get()); global.UpdateTimeout(timeout_ms); return 0; @@ -251,17 +266,3 @@ CurlGlobal::OnTimeout() noexcept { SocketAction(CURL_SOCKET_TIMEOUT, 0); } - -void -CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask) noexcept -{ - int running_handles; - CURLMcode mcode = curl_multi_socket_action(multi.Get(), fd, ev_bitmask, - &running_handles); - if (mcode != CURLM_OK) - FormatError(curlm_domain, - "curl_multi_socket_action() failed: %s", - curl_multi_strerror(mcode)); - - defer_read_info.Schedule(); -} diff --git a/src/lib/curl/Global.hxx b/src/lib/curl/Global.hxx index c0d63a035..38b909b1f 100644 --- a/src/lib/curl/Global.hxx +++ b/src/lib/curl/Global.hxx @@ -70,13 +70,13 @@ public: void SocketAction(curl_socket_t fd, int ev_bitmask) noexcept; - void InvalidateSockets() { + void InvalidateSockets() noexcept { SocketAction(CURL_SOCKET_TIMEOUT, 0); } private: void UpdateTimeout(long timeout_ms) noexcept; - static int TimerFunction(CURLM *global, long timeout_ms, + static int TimerFunction(CURLM *multi, long timeout_ms, void *userp) noexcept; /* callback for #timeout_event */ diff --git a/src/lib/curl/Slist.hxx b/src/lib/curl/Slist.hxx index 82c466b34..b53580a21 100644 --- a/src/lib/curl/Slist.hxx +++ b/src/lib/curl/Slist.hxx @@ -42,7 +42,7 @@ class CurlSlist { struct curl_slist *head = nullptr; public: - CurlSlist() = default; + CurlSlist() noexcept = default; CurlSlist(CurlSlist &&src) noexcept :head(std::exchange(src.head, nullptr)) {}