From 22382f799c30b1e9a4a891c9d3cd5b0eb5210862 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 4 Jan 2024 20:37:34 +0100 Subject: [PATCH] lib/upnp/Discovery: add `noexcept` --- src/lib/upnp/Discovery.cxx | 12 ++++++------ src/lib/upnp/Discovery.hxx | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index 1eafaa7c3..eddd14487 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -174,7 +174,7 @@ isMSDevice(std::string_view st) noexcept } static void -AnnounceFoundUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) +AnnounceFoundUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) noexcept { for (const auto &service : device.services) if (isCDService(service.serviceType)) @@ -183,7 +183,7 @@ AnnounceFoundUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) } static void -AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) +AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) noexcept { for (const auto &service : device.services) if (isCDService(service.serviceType)) @@ -192,7 +192,7 @@ AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) } inline void -UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d) +UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d) noexcept { const std::scoped_lock protect(mutex); @@ -210,7 +210,7 @@ UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d) } inline void -UPnPDeviceDirectory::LockRemove(const std::string &id) +UPnPDeviceDirectory::LockRemove(const std::string &id) noexcept { const std::scoped_lock protect(mutex); @@ -285,7 +285,7 @@ UPnPDeviceDirectory::Invoke(Upnp_EventType et, const void *evp) noexcept } void -UPnPDeviceDirectory::ExpireDevices() +UPnPDeviceDirectory::ExpireDevices() noexcept { const auto now = std::chrono::steady_clock::now(); bool didsomething = false; @@ -350,7 +350,7 @@ UPnPDeviceDirectory::Search() } std::vector -UPnPDeviceDirectory::GetDirectories() +UPnPDeviceDirectory::GetDirectories() noexcept { const std::scoped_lock protect(mutex); diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index be250d8a3..4393304d6 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -71,12 +71,14 @@ public: UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete; UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete; + [[gnu::const]] EventLoop &GetEventLoop() const noexcept; void Start(); /** Retrieve the directory services currently seen on the network */ - std::vector GetDirectories(); + [[gnu::pure]] + std::vector GetDirectories() noexcept; /** * Get server by friendly name. @@ -93,10 +95,10 @@ private: * * Caller must lock #mutex. */ - void ExpireDevices(); + void ExpireDevices() noexcept; - void LockAdd(ContentDirectoryDescriptor &&d); - void LockRemove(const std::string &id); + void LockAdd(ContentDirectoryDescriptor &&d) noexcept; + void LockRemove(const std::string &id) noexcept; int OnAlive(const UpnpDiscovery *disco) noexcept; int OnByeBye(const UpnpDiscovery *disco) noexcept;