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

@@ -123,7 +123,7 @@ protected:
/**
* Determine how many bytes can be added to the buffer.
*/
gcc_pure
[[gnu::pure]]
size_t GetBufferSpace() const noexcept {
return buffer.GetSpace();
}

View File

@@ -20,8 +20,6 @@
#ifndef INPUT_ERROR_HXX
#define INPUT_ERROR_HXX
#include "util/Compiler.h"
#include <exception>
/**
@@ -29,7 +27,7 @@
* exist? This function attempts to recognize exceptions thrown by
* various input plugins.
*/
gcc_pure
[[gnu::pure]]
bool
IsFileNotFound(std::exception_ptr e) noexcept;

View File

@@ -21,7 +21,6 @@
#define MPD_ICY_INPUT_STREAM_HXX
#include "ProxyInputStream.hxx"
#include "util/Compiler.h"
#include <memory>
@@ -63,7 +62,7 @@ public:
IcyInputStream(const IcyInputStream &) = delete;
IcyInputStream &operator=(const IcyInputStream &) = delete;
gcc_pure
[[gnu::pure]]
bool IsEnabled() const noexcept;
/* virtual methods from InputStream */

View File

@@ -22,7 +22,6 @@
#include "Ptr.hxx"
#include "thread/Mutex.hxx"
#include "util/Compiler.h"
#include <cassert>
#include <set>
@@ -83,7 +82,7 @@ struct InputPlugin {
std::unique_ptr<RemoteTagScanner> (*scan_tags)(const char *uri,
RemoteTagHandler &handler) = nullptr;
gcc_pure
[[gnu::pure]]
bool SupportsUri(const char *uri) const noexcept;
template<typename F>
@@ -103,7 +102,7 @@ struct InputPlugin {
}
};
gcc_pure
[[gnu::pure]]
bool
protocol_is_whitelisted(const char *proto) noexcept;

View File

@@ -23,7 +23,6 @@
#include "Offset.hxx"
#include "Ptr.hxx"
#include "thread/Mutex.hxx"
#include "util/Compiler.h"
#include <cassert>
#include <memory>
@@ -123,14 +122,12 @@ public:
* notifications
* @return an #InputStream object on success
*/
gcc_nonnull(1)
static InputStreamPtr Open(const char *uri, Mutex &mutex);
/**
* Just like Open(), but waits for the stream to become ready.
* It is a wrapper for Open(), WaitReady() and Check().
*/
gcc_nonnull(1)
static InputStreamPtr OpenReady(const char *uri, Mutex &mutex);
/**
@@ -184,14 +181,14 @@ public:
return ready;
}
gcc_pure
[[gnu::pure]]
bool HasMimeType() const noexcept {
assert(ready);
return !mime.empty();
}
gcc_pure
[[gnu::pure]]
const char *GetMimeType() const noexcept {
assert(ready);
@@ -202,7 +199,7 @@ public:
mime.clear();
}
gcc_nonnull_all
[[gnu::nonnull]]
void SetMimeType(const char *_mime) noexcept {
assert(!ready);
@@ -215,14 +212,14 @@ public:
mime = std::move(_mime);
}
gcc_pure
[[gnu::pure]]
bool KnownSize() const noexcept {
assert(ready);
return size != UNKNOWN_SIZE;
}
gcc_pure
[[gnu::pure]]
offset_type GetSize() const noexcept {
assert(ready);
assert(KnownSize());
@@ -236,14 +233,14 @@ public:
offset += delta;
}
gcc_pure
[[gnu::pure]]
offset_type GetOffset() const noexcept {
assert(ready);
return offset;
}
gcc_pure
[[gnu::pure]]
offset_type GetRest() const noexcept {
assert(ready);
assert(KnownSize());
@@ -251,7 +248,7 @@ public:
return size - offset;
}
gcc_pure
[[gnu::pure]]
bool IsSeekable() const noexcept {
assert(ready);
@@ -261,7 +258,7 @@ public:
/**
* Determines whether seeking is cheap. This is true for local files.
*/
gcc_pure
[[gnu::pure]]
bool CheapSeeking() const noexcept;
/**
@@ -313,14 +310,14 @@ public:
*
* The caller must lock the mutex.
*/
gcc_pure
[[gnu::pure]]
virtual bool IsEOF() const noexcept = 0;
/**
* Wrapper for IsEOF() which locks and unlocks the mutex; the
* caller must not be holding it already.
*/
gcc_pure
[[gnu::pure]]
bool LockIsEOF() const noexcept;
/**
@@ -346,7 +343,7 @@ public:
*
* The caller must lock the mutex.
*/
gcc_pure
[[gnu::pure]]
virtual bool IsAvailable() const noexcept;
/**
@@ -363,7 +360,7 @@ public:
* @param size the maximum number of bytes to read
* @return the number of bytes read
*/
gcc_nonnull_all
[[gnu::nonnull]]
virtual size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) = 0;
@@ -373,7 +370,7 @@ public:
*
* Throws std::runtime_error on error.
*/
gcc_nonnull_all
[[gnu::nonnull]]
size_t LockRead(void *ptr, size_t size);
/**
@@ -387,7 +384,7 @@ public:
* @param size the number of bytes to read
* @return true if the whole data was read, false otherwise.
*/
gcc_nonnull_all
[[gnu::nonnull]]
void ReadFull(std::unique_lock<Mutex> &lock, void *ptr, size_t size);
/**
@@ -396,7 +393,7 @@ public:
*
* Throws std::runtime_error on error.
*/
gcc_nonnull_all
[[gnu::nonnull]]
void LockReadFull(void *ptr, size_t size);
protected:

View File

@@ -20,8 +20,6 @@
#ifndef MPD_INPUT_REGISTRY_HXX
#define MPD_INPUT_REGISTRY_HXX
#include "util/Compiler.h"
/**
* NULL terminated list of all input plugins which were enabled at
* compile time.
@@ -40,7 +38,7 @@ extern bool input_plugins_enabled[];
input_plugins_for_each(plugin) \
if (input_plugins_enabled[input_plugin_iterator - input_plugins])
gcc_pure
[[gnu::pure]]
bool
HasRemoteTagScanner(const char *uri) noexcept;

View File

@@ -21,7 +21,6 @@
#define MPD_INPUT_CACHE_MANAGER_HXX
#include "thread/Mutex.hxx"
#include "util/Compiler.h"
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/list.hpp>
@@ -43,15 +42,15 @@ class InputCacheManager {
size_t total_size = 0;
struct ItemCompare {
gcc_pure
[[gnu::pure]]
bool operator()(const InputCacheItem &a,
const char *b) const noexcept;
gcc_pure
[[gnu::pure]]
bool operator()(const char *a,
const InputCacheItem &b) const noexcept;
gcc_pure
[[gnu::pure]]
bool operator()(const InputCacheItem &a,
const InputCacheItem &b) const noexcept;
};
@@ -74,7 +73,7 @@ public:
void Flush() noexcept;
gcc_pure
[[gnu::pure]]
bool Contains(const char *uri) noexcept;
/**

View File

@@ -55,7 +55,7 @@ public:
offset_type offset) override;
};
gcc_const
[[gnu::const]]
static inline bool
input_ffmpeg_supported() noexcept
{

View File

@@ -77,7 +77,7 @@ public:
return format_id;
}
gcc_pure
[[gnu::pure]]
CurlGlobal &GetCurl() noexcept;
void AddLoginHandler(QobuzSessionHandler &h) noexcept;

View File

@@ -166,7 +166,7 @@ FinishQobuzInput() noexcept
delete qobuz_client;
}
gcc_pure
[[gnu::pure]]
static const char *
ExtractQobuzTrackId(const char *uri)
{