From 4b2bb88375ddf772836680ebd7495a9302892854 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Nov 2017 18:26:32 +0100 Subject: [PATCH] lib/upnp: add "noexcept" --- src/db/plugins/upnp/Object.cxx | 2 +- src/db/plugins/upnp/Object.hxx | 2 +- src/lib/curl/Slist.hxx | 2 +- src/lib/upnp/Action.hxx | 6 +++--- src/lib/upnp/Callback.hxx | 6 +++--- src/lib/upnp/ClientInit.cxx | 4 ++-- src/lib/upnp/ClientInit.hxx | 2 +- src/lib/upnp/ContentDirectoryService.cxx | 4 ++-- src/lib/upnp/ContentDirectoryService.hxx | 4 ++-- src/lib/upnp/Device.cxx | 2 +- src/lib/upnp/Device.hxx | 2 +- src/lib/upnp/Discovery.cxx | 14 +++++++------- src/lib/upnp/Discovery.hxx | 20 ++++++++++---------- src/lib/upnp/Init.cxx | 2 +- src/lib/upnp/Init.hxx | 2 +- src/lib/upnp/UniqueIxml.hxx | 4 ++-- src/lib/upnp/ixmlwrap.cxx | 2 +- src/lib/upnp/ixmlwrap.hxx | 2 +- 18 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/db/plugins/upnp/Object.cxx b/src/db/plugins/upnp/Object.cxx index 5cf218ca6..8dc953bc2 100644 --- a/src/db/plugins/upnp/Object.cxx +++ b/src/db/plugins/upnp/Object.cxx @@ -19,7 +19,7 @@ #include "Object.hxx" -UPnPDirObject::~UPnPDirObject() +UPnPDirObject::~UPnPDirObject() noexcept { /* this destructor exists here just so it won't get inlined */ } diff --git a/src/db/plugins/upnp/Object.hxx b/src/db/plugins/upnp/Object.hxx index 8a2a4e579..a234e842a 100644 --- a/src/db/plugins/upnp/Object.hxx +++ b/src/db/plugins/upnp/Object.hxx @@ -76,7 +76,7 @@ public: UPnPDirObject() = default; UPnPDirObject(UPnPDirObject &&) = default; - ~UPnPDirObject(); + ~UPnPDirObject() noexcept; UPnPDirObject &operator=(UPnPDirObject &&) = default; diff --git a/src/lib/curl/Slist.hxx b/src/lib/curl/Slist.hxx index 6634ecd5e..fd45f7d0b 100644 --- a/src/lib/curl/Slist.hxx +++ b/src/lib/curl/Slist.hxx @@ -41,7 +41,7 @@ class CurlSlist { struct curl_slist *head = nullptr; public: - CurlSlist() noexcept = default; + CurlSlist() = default; CurlSlist(CurlSlist &&src) noexcept :head(std::exchange(src.head, nullptr)) {} diff --git a/src/lib/upnp/Action.hxx b/src/lib/upnp/Action.hxx index a3aa069e2..367da528a 100644 --- a/src/lib/upnp/Action.hxx +++ b/src/lib/upnp/Action.hxx @@ -25,7 +25,7 @@ #include static inline constexpr unsigned -CountNameValuePairs() +CountNameValuePairs() noexcept { return 0; } @@ -33,7 +33,7 @@ CountNameValuePairs() template static inline constexpr unsigned CountNameValuePairs(gcc_unused const char *name, gcc_unused const char *value, - Args... args) + Args... args) noexcept { return 1 + CountNameValuePairs(args...); } @@ -45,7 +45,7 @@ CountNameValuePairs(gcc_unused const char *name, gcc_unused const char *value, template static inline IXML_Document * MakeActionHelper(const char *action_name, const char *service_type, - Args... args) + Args... args) noexcept { const unsigned n = CountNameValuePairs(args...); return UpnpMakeAction(action_name, service_type, n, diff --git a/src/lib/upnp/Callback.hxx b/src/lib/upnp/Callback.hxx index a57cfbdcd..f232a6cd2 100644 --- a/src/lib/upnp/Callback.hxx +++ b/src/lib/upnp/Callback.hxx @@ -32,15 +32,15 @@ public: * Pass this value as "cookie" pointer to libupnp asynchronous * functions. */ - void *GetUpnpCookie() { + void *GetUpnpCookie() noexcept { return this; } - static UpnpCallback &FromUpnpCookie(void *cookie) { + static UpnpCallback &FromUpnpCookie(void *cookie) noexcept { return *(UpnpCallback *)cookie; } - virtual int Invoke(Upnp_EventType et, void *evp) = 0; + virtual int Invoke(Upnp_EventType et, void *evp) noexcept = 0; }; #endif diff --git a/src/lib/upnp/ClientInit.cxx b/src/lib/upnp/ClientInit.cxx index cfe03e388..b320beb79 100644 --- a/src/lib/upnp/ClientInit.cxx +++ b/src/lib/upnp/ClientInit.cxx @@ -33,7 +33,7 @@ static unsigned upnp_client_ref; static UpnpClient_Handle upnp_client_handle; static int -UpnpClientCallback(Upnp_EventType et, void *evp, void *cookie) +UpnpClientCallback(Upnp_EventType et, void *evp, void *cookie) noexcept { if (cookie == nullptr) /* this is the cookie passed to UpnpRegisterClient(); @@ -74,7 +74,7 @@ UpnpClientGlobalInit(UpnpClient_Handle &handle) } void -UpnpClientGlobalFinish() +UpnpClientGlobalFinish() noexcept { { const std::lock_guard protect(upnp_client_init_mutex); diff --git a/src/lib/upnp/ClientInit.hxx b/src/lib/upnp/ClientInit.hxx index 75f3a8088..a36d24f9a 100644 --- a/src/lib/upnp/ClientInit.hxx +++ b/src/lib/upnp/ClientInit.hxx @@ -28,6 +28,6 @@ void UpnpClientGlobalInit(UpnpClient_Handle &handle); void -UpnpClientGlobalFinish(); +UpnpClientGlobalFinish() noexcept; #endif diff --git a/src/lib/upnp/ContentDirectoryService.cxx b/src/lib/upnp/ContentDirectoryService.cxx index cd7339d3c..2dc3eded4 100644 --- a/src/lib/upnp/ContentDirectoryService.cxx +++ b/src/lib/upnp/ContentDirectoryService.cxx @@ -28,7 +28,7 @@ #include "util/RuntimeError.hxx" ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device, - const UPnPService &service) + const UPnPService &service) noexcept :m_actionURL(uri_apply_base(service.controlURL, device.URLBase)), m_serviceType(service.serviceType), m_deviceId(device.UDN), @@ -44,7 +44,7 @@ ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device, } } -ContentDirectoryService::~ContentDirectoryService() +ContentDirectoryService::~ContentDirectoryService() noexcept { /* this destructor exists here just so it won't get inlined */ } diff --git a/src/lib/upnp/ContentDirectoryService.hxx b/src/lib/upnp/ContentDirectoryService.hxx index 78d7dffca..973468c34 100644 --- a/src/lib/upnp/ContentDirectoryService.hxx +++ b/src/lib/upnp/ContentDirectoryService.hxx @@ -65,12 +65,12 @@ public: * UPnPDeviceDirectory::GetDirectories() */ ContentDirectoryService(const UPnPDevice &device, - const UPnPService &service); + const UPnPService &service) noexcept; /** An empty one */ ContentDirectoryService() = default; - ~ContentDirectoryService(); + ~ContentDirectoryService() noexcept; /** Read a container's children list into dirbuf. * diff --git a/src/lib/upnp/Device.cxx b/src/lib/upnp/Device.cxx index 1e2efbd89..f629c36b6 100644 --- a/src/lib/upnp/Device.cxx +++ b/src/lib/upnp/Device.cxx @@ -24,7 +24,7 @@ #include -UPnPDevice::~UPnPDevice() +UPnPDevice::~UPnPDevice() noexcept { /* this destructor exists here just so it won't get inlined */ } diff --git a/src/lib/upnp/Device.hxx b/src/lib/upnp/Device.hxx index 9cb2d6fb1..8f7d42182 100644 --- a/src/lib/upnp/Device.hxx +++ b/src/lib/upnp/Device.hxx @@ -73,7 +73,7 @@ public: UPnPDevice(UPnPDevice &&) = default; UPnPDevice &operator=(UPnPDevice &&) = default; - ~UPnPDevice(); + ~UPnPDevice() noexcept; /** Build device from xml description downloaded from discovery * @param url where the description came from diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index b33e608b2..0ce1d6c13 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -45,7 +45,7 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent, } void -UPnPDeviceDirectory::Downloader::Destroy() +UPnPDeviceDirectory::Downloader::Destroy() noexcept { parent.downloaders.erase_and_dispose(parent.downloaders.iterator_to(*this), DeleteDisposer()); @@ -170,7 +170,7 @@ UPnPDeviceDirectory::LockRemove(const std::string &id) } inline int -UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco) +UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco) noexcept { if (isMSDevice(disco->DeviceType) || isCDService(disco->ServiceType)) { @@ -192,7 +192,7 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco) } inline int -UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco) +UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco) noexcept { if (isMSDevice(disco->DeviceType) || isCDService(disco->ServiceType)) { @@ -208,7 +208,7 @@ UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco) // Example: ContentDirectories appearing and disappearing from the network // We queue a task for our worker thread(s) int -UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp) +UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp) noexcept { switch (et) { case UPNP_DISCOVERY_SEARCH_RESULT: @@ -251,13 +251,13 @@ UPnPDeviceDirectory::ExpireDevices() UPnPDeviceDirectory::UPnPDeviceDirectory(EventLoop &event_loop, UpnpClient_Handle _handle, - UPnPDiscoveryListener *_listener) + UPnPDiscoveryListener *_listener) noexcept :curl(event_loop), handle(_handle), listener(_listener) { } -UPnPDeviceDirectory::~UPnPDeviceDirectory() +UPnPDeviceDirectory::~UPnPDeviceDirectory() noexcept { BlockingCall(GetEventLoop(), [this](){ downloaders.clear_and_dispose(DeleteDisposer()); @@ -265,7 +265,7 @@ UPnPDeviceDirectory::~UPnPDeviceDirectory() } inline EventLoop & -UPnPDeviceDirectory::GetEventLoop() +UPnPDeviceDirectory::GetEventLoop() noexcept { return curl->GetEventLoop(); } diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index bb7ada19e..cae223d0d 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -73,7 +73,7 @@ class UPnPDeviceDirectory final : UpnpCallback { ContentDirectoryDescriptor(std::string &&_id, std::chrono::steady_clock::time_point last, - std::chrono::steady_clock::duration exp) + std::chrono::steady_clock::duration exp) noexcept :id(std::move(_id)), expires(last + exp + std::chrono::seconds(20)) {} @@ -102,14 +102,14 @@ class UPnPDeviceDirectory final : UpnpCallback { Downloader(UPnPDeviceDirectory &_parent, const Upnp_Discovery &disco); - void Start() { + void Start() noexcept { defer_start_event.Schedule(); } - void Destroy(); + void Destroy() noexcept; private: - void OnDeferredStart() { + void OnDeferredStart() noexcept { request.Start(); } @@ -147,13 +147,13 @@ class UPnPDeviceDirectory final : UpnpCallback { public: UPnPDeviceDirectory(EventLoop &event_loop, UpnpClient_Handle _handle, - UPnPDiscoveryListener *_listener=nullptr); - ~UPnPDeviceDirectory(); + UPnPDiscoveryListener *_listener=nullptr) noexcept; + ~UPnPDeviceDirectory() noexcept; UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete; UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete; - EventLoop &GetEventLoop(); + EventLoop &GetEventLoop() noexcept; void Start(); @@ -180,11 +180,11 @@ private: void LockAdd(ContentDirectoryDescriptor &&d); void LockRemove(const std::string &id); - int OnAlive(Upnp_Discovery *disco); - int OnByeBye(Upnp_Discovery *disco); + int OnAlive(Upnp_Discovery *disco) noexcept; + int OnByeBye(Upnp_Discovery *disco) noexcept; /* virtual methods from class UpnpCallback */ - virtual int Invoke(Upnp_EventType et, void *evp) override; + int Invoke(Upnp_EventType et, void *evp) noexcept override; }; diff --git a/src/lib/upnp/Init.cxx b/src/lib/upnp/Init.cxx index 807a984ca..ca3140599 100644 --- a/src/lib/upnp/Init.cxx +++ b/src/lib/upnp/Init.cxx @@ -57,7 +57,7 @@ UpnpGlobalInit() } void -UpnpGlobalFinish() +UpnpGlobalFinish() noexcept { const std::lock_guard protect(upnp_init_mutex); diff --git a/src/lib/upnp/Init.hxx b/src/lib/upnp/Init.hxx index c3f65cc7e..8d91ee2ce 100644 --- a/src/lib/upnp/Init.hxx +++ b/src/lib/upnp/Init.hxx @@ -26,6 +26,6 @@ void UpnpGlobalInit(); void -UpnpGlobalFinish(); +UpnpGlobalFinish() noexcept; #endif diff --git a/src/lib/upnp/UniqueIxml.hxx b/src/lib/upnp/UniqueIxml.hxx index 9817ca340..ddfc4aa94 100644 --- a/src/lib/upnp/UniqueIxml.hxx +++ b/src/lib/upnp/UniqueIxml.hxx @@ -25,11 +25,11 @@ #include struct UpnpIxmlDeleter { - void operator()(IXML_Document *doc) { + void operator()(IXML_Document *doc) noexcept { ixmlDocument_free(doc); } - void operator()(IXML_NodeList *nl) { + void operator()(IXML_NodeList *nl) noexcept { ixmlNodeList_free(nl); } }; diff --git a/src/lib/upnp/ixmlwrap.cxx b/src/lib/upnp/ixmlwrap.cxx index fbcc30b28..4e44f35a6 100644 --- a/src/lib/upnp/ixmlwrap.cxx +++ b/src/lib/upnp/ixmlwrap.cxx @@ -21,7 +21,7 @@ namespace ixmlwrap { const char * -getFirstElementValue(IXML_Document *doc, const char *name) +getFirstElementValue(IXML_Document *doc, const char *name) noexcept { UniqueIxmlNodeList nodes(ixmlDocument_getElementsByTagName(doc, name)); if (!nodes) diff --git a/src/lib/upnp/ixmlwrap.hxx b/src/lib/upnp/ixmlwrap.hxx index 0d519a323..9d9813e13 100644 --- a/src/lib/upnp/ixmlwrap.hxx +++ b/src/lib/upnp/ixmlwrap.hxx @@ -28,7 +28,7 @@ namespace ixmlwrap { * contain a text node */ const char *getFirstElementValue(IXML_Document *doc, - const char *name); + const char *name) noexcept; };