From 4800f1d8f26c147e1ba0d97cd79a489f448ff0e4 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max.kellermann@gmail.com>
Date: Fri, 10 May 2024 19:08:15 +0200
Subject: [PATCH] storage/Interface: add [[nodiscard]]

---
 src/storage/StorageInterface.hxx | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/storage/StorageInterface.hxx b/src/storage/StorageInterface.hxx
index 3916e9fe5..be7a96eaf 100644
--- a/src/storage/StorageInterface.hxx
+++ b/src/storage/StorageInterface.hxx
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 // Copyright The Music Player Daemon Project
 
-#ifndef MPD_STORAGE_INTERFACE_HXX
-#define MPD_STORAGE_INTERFACE_HXX
+#pragma once
 
 #include <memory>
 #include <string>
@@ -17,11 +16,13 @@ public:
 	StorageDirectoryReader(const StorageDirectoryReader &) = delete;
 	virtual ~StorageDirectoryReader() noexcept = default;
 
+	[[nodiscard]]
 	virtual const char *Read() noexcept = 0;
 
 	/**
 	 * Throws #std::runtime_error on error.
 	 */
+	[[nodiscard]]
 	virtual StorageFileInfo GetInfo(bool follow) = 0;
 };
 
@@ -34,17 +35,19 @@ public:
 	/**
 	 * Throws #std::runtime_error on error.
 	 */
+	[[nodiscard]]
 	virtual StorageFileInfo GetInfo(std::string_view uri_utf8, bool follow) = 0;
 
 	/**
 	 * Throws #std::runtime_error on error.
 	 */
+	[[nodiscard]]
 	virtual std::unique_ptr<StorageDirectoryReader> OpenDirectory(std::string_view uri_utf8) = 0;
 
 	/**
 	 * Map the given relative URI to an absolute URI.
 	 */
-	[[gnu::pure]]
+	[[nodiscard]] [[gnu::pure]]
 	virtual std::string MapUTF8(std::string_view uri_utf8) const noexcept = 0;
 
 	/**
@@ -52,10 +55,10 @@ public:
 	 * nullptr on error or if this storage does not
 	 * support local files.
 	 */
-	[[gnu::pure]]
+	[[nodiscard]] [[gnu::pure]]
 	virtual AllocatedPath MapFS(std::string_view uri_utf8) const noexcept;
 
-	[[gnu::pure]]
+	[[nodiscard]] [[gnu::pure]]
 	AllocatedPath MapChildFS(std::string_view uri_utf8,
 				 std::string_view child_utf8) const noexcept;
 
@@ -64,8 +67,6 @@ public:
 	 * then it returns a relative URI (pointing inside the given
 	 * string); if not, returns nullptr.
 	 */
-	[[gnu::pure]]
+	[[nodiscard]] [[gnu::pure]]
 	virtual std::string_view MapToRelativeUTF8(std::string_view uri_utf8) const noexcept = 0;
 };
-
-#endif