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

@@ -21,7 +21,6 @@
#define MPD_DIRECTORY_HXX
#include "Ptr.hxx"
#include "util/Compiler.h"
#include "db/Visitor.hxx"
#include "db/PlaylistVector.hxx"
#include "db/Ptr.hxx"
@@ -113,7 +112,7 @@ public:
/**
* Create a new root #Directory object.
*/
gcc_malloc gcc_returns_nonnull
[[gnu::malloc]] [[gnu::returns_nonnull]]
static Directory *NewRoot() noexcept {
return new Directory(std::string(), nullptr);
}
@@ -141,7 +140,7 @@ public:
* (e.g. #DEVICE_PLAYLIST) and whether the underlying plugin
* is available.
*/
gcc_pure
[[gnu::pure]]
bool IsPluginAvailable() const noexcept;
/**
@@ -164,10 +163,10 @@ public:
/**
* Caller must lock the #db_mutex.
*/
gcc_pure
[[gnu::pure]]
const Directory *FindChild(std::string_view name) const noexcept;
gcc_pure
[[gnu::pure]]
Directory *FindChild(std::string_view name) noexcept {
const Directory *cthis = this;
return const_cast<Directory *>(cthis->FindChild(name));
@@ -211,20 +210,20 @@ public:
*
* @param uri the relative URI
*/
gcc_pure
[[gnu::pure]]
LookupResult LookupDirectory(std::string_view uri) noexcept;
[[gnu::pure]]
bool TargetExists(std::string_view target) const noexcept;
gcc_pure
[[gnu::pure]]
bool IsEmpty() const noexcept {
return children.empty() &&
songs.empty() &&
playlists.empty();
}
gcc_pure
[[gnu::pure]]
const char *GetPath() const noexcept {
return path.c_str();
}
@@ -232,13 +231,13 @@ public:
/**
* Returns the base name of the directory.
*/
gcc_pure
[[gnu::pure]]
const char *GetName() const noexcept;
/**
* Is this the root directory of the music database?
*/
gcc_pure
[[gnu::pure]]
bool IsRoot() const noexcept {
return parent == nullptr;
}
@@ -266,10 +265,10 @@ public:
*
* Caller must lock the #db_mutex.
*/
gcc_pure
[[gnu::pure]]
const Song *FindSong(std::string_view name_utf8) const noexcept;
gcc_pure
[[gnu::pure]]
Song *FindSong(std::string_view name_utf8) noexcept {
const Directory *cthis = this;
return const_cast<Song *>(cthis->FindSong(name_utf8));
@@ -307,7 +306,7 @@ public:
const VisitDirectory& visit_directory, const VisitSong& visit_song,
const VisitPlaylist& visit_playlist) const;
gcc_pure
[[gnu::pure]]
LightDirectory Export() const noexcept;
};

View File

@@ -25,7 +25,6 @@
#include "db/Ptr.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/Manual.hxx"
#include "util/Compiler.h"
#include "config.h"
#include <cassert>
@@ -78,7 +77,7 @@ public:
DatabaseListener &listener,
const ConfigBlock &block);
gcc_pure
[[gnu::pure]]
Directory &GetRoot() noexcept {
assert(root != NULL);
@@ -98,7 +97,7 @@ public:
* @param db the #Database to be mounted; must be "open"; on
* success, this object gains ownership of the given #Database
*/
gcc_nonnull_all
[[gnu::nonnull]]
void Mount(const char *uri, DatabasePtr db);
/**
@@ -106,10 +105,10 @@ public:
*
* @return false if the mounted database needs to be updated
*/
gcc_nonnull_all
[[gnu::nonnull]]
bool Mount(const char *local_uri, const char *storage_uri);
gcc_nonnull_all
[[gnu::nonnull]]
bool Unmount(const char *uri) noexcept;
/* virtual methods from class Database */

View File

@@ -24,7 +24,6 @@
#include "Chrono.hxx"
#include "tag/Tag.hxx"
#include "pcm/AudioFormat.hxx"
#include "util/Compiler.h"
#include "config.h"
#include <boost/intrusive/list.hpp>
@@ -108,14 +107,14 @@ struct Song {
Song(DetachedSong &&other, Directory &_parent) noexcept;
gcc_pure
[[gnu::pure]]
const char *GetFilenameSuffix() const noexcept;
/**
* Checks whether the decoder plugin for this song is
* available.
*/
gcc_pure
[[gnu::pure]]
bool IsPluginAvailable() const noexcept;
/**
@@ -149,10 +148,10 @@ struct Song {
* Returns the URI of the song in UTF-8 encoding, including its
* location within the music directory.
*/
gcc_pure
[[gnu::pure]]
std::string GetURI() const noexcept;
gcc_pure
[[gnu::pure]]
ExportedSong Export() const noexcept;
};