more [[gnu::...]] attributes

This commit is contained in:
Max Kellermann
2021-10-13 11:28:04 +02:00
parent 1c4b484a56
commit f510564d9d
135 changed files with 361 additions and 514 deletions

View File

@@ -22,7 +22,6 @@
#include "StorageInterface.hxx"
#include "thread/Mutex.hxx"
#include "util/Compiler.h"
#include <memory>
#include <string>
@@ -51,12 +50,12 @@ class CompositeStorage final : public Storage {
std::map<std::string, Directory, std::less<>> children;
gcc_pure
[[gnu::pure]]
bool IsEmpty() const noexcept {
return storage == nullptr && children.empty();
}
gcc_pure
[[gnu::pure]]
const Directory *Find(std::string_view uri) const noexcept;
Directory &Make(std::string_view uri);
@@ -64,7 +63,7 @@ class CompositeStorage final : public Storage {
bool Unmount() noexcept;
bool Unmount(std::string_view uri) noexcept;
gcc_pure
[[gnu::pure]]
bool MapToRelativeUTF8(std::string &buffer,
std::string_view uri) const noexcept;
};
@@ -97,14 +96,14 @@ public:
* allowed to unmount the given mount point while the return
* value is being used.
*/
gcc_pure gcc_nonnull_all
[[gnu::pure]]
Storage *GetMount(std::string_view uri) noexcept;
/**
* Is the given URI a mount point, i.e. is something already
* mounted on this path?
*/
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
bool IsMountPoint(const char *uri) noexcept {
return GetMount(uri) != nullptr;
}
@@ -124,7 +123,7 @@ public:
/**
* Is a storage with the given URI already mounted?
*/
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
bool IsMounted(const char *storage_uri) const noexcept {
const std::lock_guard<Mutex> protect(mutex);
return IsMounted(root, storage_uri);
@@ -164,7 +163,7 @@ private:
}
}
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
static bool IsMounted(const Directory &directory,
const char *storage_uri) noexcept {
if (directory.storage) {
@@ -188,7 +187,7 @@ private:
* remaining unused part of the URI (may be empty if all of
* the URI was used).
*/
gcc_pure
[[gnu::pure]]
FindResult FindStorage(std::string_view uri) const noexcept;
const char *MapToRelativeUTF8(const Directory &directory,

View File

@@ -20,8 +20,6 @@
#ifndef MPD_STORAGE_CONFIG_HXX
#define MPD_STORAGE_CONFIG_HXX
#include "util/Compiler.h"
#include <memory>
struct ConfigData;
@@ -40,7 +38,7 @@ CreateConfiguredStorage(const ConfigData &config, EventLoop &event_loop);
/**
* Returns true if there is configuration for a #Storage instance.
*/
gcc_const
[[gnu::const]]
bool
IsStorageConfigured(const ConfigData &config) noexcept;

View File

@@ -20,8 +20,6 @@
#ifndef MPD_STORAGE_INTERFACE_HXX
#define MPD_STORAGE_INTERFACE_HXX
#include "util/Compiler.h"
#include <memory>
#include <string>
#include <string_view>
@@ -62,7 +60,7 @@ public:
/**
* Map the given relative URI to an absolute URI.
*/
gcc_pure
[[gnu::pure]]
virtual std::string MapUTF8(std::string_view uri_utf8) const noexcept = 0;
/**
@@ -70,10 +68,10 @@ public:
* nullptr on error or if this storage does not
* support local files.
*/
gcc_pure
[[gnu::pure]]
virtual AllocatedPath MapFS(std::string_view uri_utf8) const noexcept;
gcc_pure
[[gnu::pure]]
AllocatedPath MapChildFS(std::string_view uri_utf8,
std::string_view child_utf8) const noexcept;
@@ -82,7 +80,7 @@ public:
* then it returns a relative URI (pointing inside the given
* string); if not, returns nullptr.
*/
gcc_pure
[[gnu::pure]]
virtual std::string_view MapToRelativeUTF8(std::string_view uri_utf8) const noexcept = 0;
};