Commit 71f0ed8b authored by Max Kellermann's avatar Max Kellermann

*: add "noexcept" to many, many function prototypes

This eliminates some overhead, because the compiler doesn't need to consider these functions throwing.
parent ac2e4e59
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <stdio.h> #include <stdio.h>
void void
AudioFormat::ApplyMask(AudioFormat mask) AudioFormat::ApplyMask(AudioFormat mask) noexcept
{ {
assert(IsValid()); assert(IsValid());
assert(mask.IsMaskValid()); assert(mask.IsMaskValid());
...@@ -42,7 +42,7 @@ AudioFormat::ApplyMask(AudioFormat mask) ...@@ -42,7 +42,7 @@ AudioFormat::ApplyMask(AudioFormat mask)
} }
StringBuffer<24> StringBuffer<24>
ToString(const AudioFormat af) ToString(const AudioFormat af) noexcept
{ {
StringBuffer<24> buffer; StringBuffer<24> buffer;
......
...@@ -124,7 +124,7 @@ struct AudioFormat { ...@@ -124,7 +124,7 @@ struct AudioFormat {
return !(*this == other); return !(*this == other);
} }
void ApplyMask(AudioFormat mask); void ApplyMask(AudioFormat mask) noexcept;
gcc_pure gcc_pure
AudioFormat WithMask(AudioFormat mask) const { AudioFormat WithMask(AudioFormat mask) const {
...@@ -223,6 +223,6 @@ AudioFormat::GetTimeToSize() const ...@@ -223,6 +223,6 @@ AudioFormat::GetTimeToSize() const
*/ */
gcc_const gcc_const
StringBuffer<24> StringBuffer<24>
ToString(AudioFormat af); ToString(AudioFormat af) noexcept;
#endif #endif
...@@ -37,19 +37,19 @@ DetachedSong::~DetachedSong() ...@@ -37,19 +37,19 @@ DetachedSong::~DetachedSong()
} }
bool bool
DetachedSong::IsRemote() const DetachedSong::IsRemote() const noexcept
{ {
return uri_has_scheme(GetRealURI()); return uri_has_scheme(GetRealURI());
} }
bool bool
DetachedSong::IsAbsoluteFile() const DetachedSong::IsAbsoluteFile() const noexcept
{ {
return PathTraitsUTF8::IsAbsolute(GetRealURI()); return PathTraitsUTF8::IsAbsolute(GetRealURI());
} }
bool bool
DetachedSong::IsInDatabase() const DetachedSong::IsInDatabase() const noexcept
{ {
/* here, we use GetURI() and not GetRealURI() because /* here, we use GetURI() and not GetRealURI() because
GetRealURI() is never relative */ GetRealURI() is never relative */
...@@ -59,7 +59,7 @@ DetachedSong::IsInDatabase() const ...@@ -59,7 +59,7 @@ DetachedSong::IsInDatabase() const
} }
SignedSongTime SignedSongTime
DetachedSong::GetDuration() const DetachedSong::GetDuration() const noexcept
{ {
SongTime a = start_time, b = end_time; SongTime a = start_time, b = end_time;
if (!b.IsPositive()) { if (!b.IsPositive()) {
......
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
~DetachedSong(); ~DetachedSong();
gcc_pure gcc_pure
const char *GetURI() const { const char *GetURI() const noexcept {
return uri.c_str(); return uri.c_str();
} }
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
* displayed URI? * displayed URI?
*/ */
gcc_pure gcc_pure
bool HasRealURI() const { bool HasRealURI() const noexcept {
return !real_uri.empty(); return !real_uri.empty();
} }
...@@ -123,7 +123,7 @@ public: ...@@ -123,7 +123,7 @@ public:
* GetURI(). * GetURI().
*/ */
gcc_pure gcc_pure
const char *GetRealURI() const { const char *GetRealURI() const noexcept {
return (HasRealURI() ? real_uri : uri).c_str(); return (HasRealURI() ? real_uri : uri).c_str();
} }
...@@ -137,19 +137,19 @@ public: ...@@ -137,19 +137,19 @@ public:
* song. * song.
*/ */
gcc_pure gcc_pure
bool IsSame(const DetachedSong &other) const { bool IsSame(const DetachedSong &other) const noexcept {
return uri == other.uri && return uri == other.uri &&
start_time == other.start_time && start_time == other.start_time &&
end_time == other.end_time; end_time == other.end_time;
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
bool IsURI(const char *other_uri) const { bool IsURI(const char *other_uri) const noexcept {
return uri == other_uri; return uri == other_uri;
} }
gcc_pure gcc_pure
bool IsRemote() const; bool IsRemote() const noexcept;
gcc_pure gcc_pure
bool IsFile() const { bool IsFile() const {
...@@ -157,10 +157,10 @@ public: ...@@ -157,10 +157,10 @@ public:
} }
gcc_pure gcc_pure
bool IsAbsoluteFile() const; bool IsAbsoluteFile() const noexcept;
gcc_pure gcc_pure
bool IsInDatabase() const; bool IsInDatabase() const noexcept;
const Tag &GetTag() const { const Tag &GetTag() const {
return tag; return tag;
...@@ -215,7 +215,7 @@ public: ...@@ -215,7 +215,7 @@ public:
} }
gcc_pure gcc_pure
SignedSongTime GetDuration() const; SignedSongTime GetDuration() const noexcept;
/** /**
* Update the #tag and #mtime. * Update the #tag and #mtime.
......
...@@ -96,7 +96,7 @@ io_thread_deinit(void) ...@@ -96,7 +96,7 @@ io_thread_deinit(void)
} }
EventLoop & EventLoop &
io_thread_get() io_thread_get() noexcept
{ {
assert(io.loop != nullptr); assert(io.loop != nullptr);
...@@ -104,7 +104,7 @@ io_thread_get() ...@@ -104,7 +104,7 @@ io_thread_get()
} }
bool bool
io_thread_inside(void) io_thread_inside() noexcept
{ {
return io.thread.IsInside(); return io.thread.IsInside();
} }
...@@ -51,13 +51,13 @@ io_thread_deinit(); ...@@ -51,13 +51,13 @@ io_thread_deinit();
gcc_const gcc_const
EventLoop & EventLoop &
io_thread_get(); io_thread_get() noexcept;
/** /**
* Is the current thread the I/O thread? * Is the current thread the I/O thread?
*/ */
gcc_pure gcc_pure
bool bool
io_thread_inside(); io_thread_inside() noexcept;
#endif #endif
...@@ -46,13 +46,13 @@ static const char *const idle_names[] = { ...@@ -46,13 +46,13 @@ static const char *const idle_names[] = {
}; };
const char*const* const char*const*
idle_get_names(void) idle_get_names() noexcept
{ {
return idle_names; return idle_names;
} }
unsigned unsigned
idle_parse_name(const char *name) idle_parse_name(const char *name) noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
......
...@@ -70,8 +70,9 @@ static constexpr unsigned IDLE_MOUNT = 0x1000; ...@@ -70,8 +70,9 @@ static constexpr unsigned IDLE_MOUNT = 0x1000;
/** /**
* Get idle names * Get idle names
*/ */
gcc_const
const char*const* const char*const*
idle_get_names(); idle_get_names() noexcept;
/** /**
* Parse an idle name and return its mask. Returns 0 if the given * Parse an idle name and return its mask. Returns 0 if the given
...@@ -79,6 +80,6 @@ idle_get_names(); ...@@ -79,6 +80,6 @@ idle_get_names();
*/ */
gcc_nonnull_all gcc_pure gcc_nonnull_all gcc_pure
unsigned unsigned
idle_parse_name(const char *name); idle_parse_name(const char *name) noexcept;
#endif #endif
...@@ -59,14 +59,14 @@ mapper_init(AllocatedPath &&_playlist_dir) ...@@ -59,14 +59,14 @@ mapper_init(AllocatedPath &&_playlist_dir)
} }
void void
mapper_finish() mapper_finish() noexcept
{ {
} }
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
AllocatedPath AllocatedPath
map_uri_fs(const char *uri) map_uri_fs(const char *uri) noexcept
{ {
assert(uri != nullptr); assert(uri != nullptr);
assert(*uri != '/'); assert(*uri != '/');
...@@ -86,7 +86,7 @@ map_uri_fs(const char *uri) ...@@ -86,7 +86,7 @@ map_uri_fs(const char *uri)
} }
std::string std::string
map_fs_to_utf8(Path path_fs) map_fs_to_utf8(Path path_fs) noexcept
{ {
if (path_fs.IsAbsolute()) { if (path_fs.IsAbsolute()) {
if (instance->storage == nullptr) if (instance->storage == nullptr)
...@@ -109,13 +109,13 @@ map_fs_to_utf8(Path path_fs) ...@@ -109,13 +109,13 @@ map_fs_to_utf8(Path path_fs)
#endif #endif
const AllocatedPath & const AllocatedPath &
map_spl_path() map_spl_path() noexcept
{ {
return playlist_dir_fs; return playlist_dir_fs;
} }
AllocatedPath AllocatedPath
map_spl_utf8_to_fs(const char *name) map_spl_utf8_to_fs(const char *name) noexcept
{ {
if (playlist_dir_fs.IsNull()) if (playlist_dir_fs.IsNull())
return AllocatedPath::Null(); return AllocatedPath::Null();
......
...@@ -37,7 +37,7 @@ void ...@@ -37,7 +37,7 @@ void
mapper_init(AllocatedPath &&playlist_dir); mapper_init(AllocatedPath &&playlist_dir);
void void
mapper_finish(); mapper_finish() noexcept;
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
...@@ -48,7 +48,7 @@ mapper_finish(); ...@@ -48,7 +48,7 @@ mapper_finish();
*/ */
gcc_pure gcc_pure
AllocatedPath AllocatedPath
map_uri_fs(const char *uri); map_uri_fs(const char *uri) noexcept;
/** /**
* Maps a file system path (relative to the music directory or * Maps a file system path (relative to the music directory or
...@@ -60,7 +60,7 @@ map_uri_fs(const char *uri); ...@@ -60,7 +60,7 @@ map_uri_fs(const char *uri);
*/ */
gcc_pure gcc_pure
std::string std::string
map_fs_to_utf8(Path path_fs); map_fs_to_utf8(Path path_fs) noexcept;
#endif #endif
...@@ -69,7 +69,7 @@ map_fs_to_utf8(Path path_fs); ...@@ -69,7 +69,7 @@ map_fs_to_utf8(Path path_fs);
*/ */
gcc_const gcc_const
const AllocatedPath & const AllocatedPath &
map_spl_path(); map_spl_path() noexcept;
/** /**
* Maps a playlist name (without the ".m3u" suffix) to a file system * Maps a playlist name (without the ".m3u" suffix) to a file system
...@@ -79,6 +79,6 @@ map_spl_path(); ...@@ -79,6 +79,6 @@ map_spl_path();
*/ */
gcc_pure gcc_pure
AllocatedPath AllocatedPath
map_spl_utf8_to_fs(const char *name); map_spl_utf8_to_fs(const char *name) noexcept;
#endif #endif
...@@ -23,19 +23,19 @@ ...@@ -23,19 +23,19 @@
#include <assert.h> #include <assert.h>
MusicBuffer::MusicBuffer(unsigned num_chunks) MusicBuffer::MusicBuffer(unsigned num_chunks) noexcept
:buffer(num_chunks) { :buffer(num_chunks) {
} }
MusicChunk * MusicChunk *
MusicBuffer::Allocate() MusicBuffer::Allocate() noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
return buffer.Allocate(); return buffer.Allocate();
} }
void void
MusicBuffer::Return(MusicChunk *chunk) MusicBuffer::Return(MusicChunk *chunk) noexcept
{ {
assert(chunk != nullptr); assert(chunk != nullptr);
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
* @param num_chunks the number of #MusicChunk reserved in * @param num_chunks the number of #MusicChunk reserved in
* this buffer * this buffer
*/ */
MusicBuffer(unsigned num_chunks); MusicBuffer(unsigned num_chunks) noexcept;
#ifndef NDEBUG #ifndef NDEBUG
/** /**
...@@ -71,13 +71,13 @@ public: ...@@ -71,13 +71,13 @@ public:
* @return an empty chunk or nullptr if there are no chunks * @return an empty chunk or nullptr if there are no chunks
* available * available
*/ */
MusicChunk *Allocate(); MusicChunk *Allocate() noexcept;
/** /**
* Returns a chunk to the buffer. It can be reused by * Returns a chunk to the buffer. It can be reused by
* Allocate() then. * Allocate() then.
*/ */
void Return(MusicChunk *chunk); void Return(MusicChunk *chunk) noexcept;
}; };
#endif #endif
...@@ -31,7 +31,7 @@ MusicChunk::~MusicChunk() ...@@ -31,7 +31,7 @@ MusicChunk::~MusicChunk()
#ifndef NDEBUG #ifndef NDEBUG
bool bool
MusicChunk::CheckFormat(const AudioFormat other_format) const MusicChunk::CheckFormat(const AudioFormat other_format) const noexcept
{ {
assert(other_format.IsValid()); assert(other_format.IsValid());
...@@ -41,7 +41,7 @@ MusicChunk::CheckFormat(const AudioFormat other_format) const ...@@ -41,7 +41,7 @@ MusicChunk::CheckFormat(const AudioFormat other_format) const
WritableBuffer<void> WritableBuffer<void>
MusicChunk::Write(const AudioFormat af, MusicChunk::Write(const AudioFormat af,
SongTime data_time, uint16_t _bit_rate) SongTime data_time, uint16_t _bit_rate) noexcept
{ {
assert(CheckFormat(af)); assert(CheckFormat(af));
assert(length == 0 || audio_format.IsValid()); assert(length == 0 || audio_format.IsValid());
...@@ -64,7 +64,7 @@ MusicChunk::Write(const AudioFormat af, ...@@ -64,7 +64,7 @@ MusicChunk::Write(const AudioFormat af,
} }
bool bool
MusicChunk::Expand(const AudioFormat af, size_t _length) MusicChunk::Expand(const AudioFormat af, size_t _length) noexcept
{ {
const size_t frame_size = af.GetFrameSize(); const size_t frame_size = af.GetFrameSize();
......
...@@ -111,7 +111,7 @@ struct MusicChunk { ...@@ -111,7 +111,7 @@ struct MusicChunk {
* specified audio_format. * specified audio_format.
*/ */
gcc_pure gcc_pure
bool CheckFormat(AudioFormat audio_format) const; bool CheckFormat(AudioFormat audio_format) const noexcept;
#endif #endif
/** /**
...@@ -127,7 +127,7 @@ struct MusicChunk { ...@@ -127,7 +127,7 @@ struct MusicChunk {
*/ */
WritableBuffer<void> Write(AudioFormat af, WritableBuffer<void> Write(AudioFormat af,
SongTime data_time, SongTime data_time,
uint16_t bit_rate); uint16_t bit_rate) noexcept;
/** /**
* Increases the length of the chunk after the caller has written to * Increases the length of the chunk after the caller has written to
...@@ -138,7 +138,7 @@ struct MusicChunk { ...@@ -138,7 +138,7 @@ struct MusicChunk {
* @param length the number of bytes which were appended * @param length the number of bytes which were appended
* @return true if the chunk is full * @return true if the chunk is full
*/ */
bool Expand(AudioFormat af, size_t length); bool Expand(AudioFormat af, size_t length) noexcept;
}; };
#endif #endif
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef NDEBUG #ifndef NDEBUG
bool bool
MusicPipe::Contains(const MusicChunk *chunk) const MusicPipe::Contains(const MusicChunk *chunk) const noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
* Checks if the specified chunk is enqueued in the music pipe. * Checks if the specified chunk is enqueued in the music pipe.
*/ */
gcc_pure gcc_pure
bool Contains(const MusicChunk *chunk) const; bool Contains(const MusicChunk *chunk) const noexcept;
#endif #endif
/** /**
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <math.h> #include <math.h>
float float
ReplayGainTuple::CalculateScale(const ReplayGainConfig &config) const ReplayGainTuple::CalculateScale(const ReplayGainConfig &config) const noexcept
{ {
float scale; float scale;
......
...@@ -40,23 +40,23 @@ struct ReplayGainTuple { ...@@ -40,23 +40,23 @@ struct ReplayGainTuple {
} }
gcc_pure gcc_pure
float CalculateScale(const ReplayGainConfig &config) const; float CalculateScale(const ReplayGainConfig &config) const noexcept;
}; };
struct ReplayGainInfo { struct ReplayGainInfo {
ReplayGainTuple track, album; ReplayGainTuple track, album;
constexpr bool IsDefined() const { constexpr bool IsDefined() const noexcept {
return track.IsDefined() || album.IsDefined(); return track.IsDefined() || album.IsDefined();
} }
const ReplayGainTuple &Get(ReplayGainMode mode) const { const ReplayGainTuple &Get(ReplayGainMode mode) const noexcept {
return mode == ReplayGainMode::ALBUM return mode == ReplayGainMode::ALBUM
? (album.IsDefined() ? album : track) ? (album.IsDefined() ? album : track)
: (track.IsDefined() ? track : album); : (track.IsDefined() ? track : album);
} }
void Clear() { void Clear() noexcept {
track.Clear(); track.Clear();
album.Clear(); album.Clear();
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <string.h> #include <string.h>
const char * const char *
ToString(ReplayGainMode mode) ToString(ReplayGainMode mode) noexcept
{ {
switch (mode) { switch (mode) {
case ReplayGainMode::AUTO: case ReplayGainMode::AUTO:
......
...@@ -36,7 +36,7 @@ enum class ReplayGainMode : uint8_t { ...@@ -36,7 +36,7 @@ enum class ReplayGainMode : uint8_t {
*/ */
gcc_pure gcc_pure
const char * const char *
ToString(ReplayGainMode mode); ToString(ReplayGainMode mode) noexcept;
/** /**
* Parse a string to a #ReplayGainMode. Throws std::runtime_error on * Parse a string to a #ReplayGainMode. Throws std::runtime_error on
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#define LOCATE_TAG_ANY_KEY "any" #define LOCATE_TAG_ANY_KEY "any"
unsigned unsigned
locate_parse_type(const char *str) locate_parse_type(const char *str) noexcept
{ {
if (StringEqualsCaseASCII(str, LOCATE_TAG_FILE_KEY) || if (StringEqualsCaseASCII(str, LOCATE_TAG_FILE_KEY) ||
StringEqualsCaseASCII(str, LOCATE_TAG_FILE_KEY_OLD)) StringEqualsCaseASCII(str, LOCATE_TAG_FILE_KEY_OLD))
...@@ -78,7 +78,7 @@ SongFilter::Item::Item(unsigned _tag, time_t _time) ...@@ -78,7 +78,7 @@ SongFilter::Item::Item(unsigned _tag, time_t _time)
} }
bool bool
SongFilter::Item::StringMatch(const char *s) const SongFilter::Item::StringMatch(const char *s) const noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
...@@ -97,14 +97,14 @@ SongFilter::Item::StringMatch(const char *s) const ...@@ -97,14 +97,14 @@ SongFilter::Item::StringMatch(const char *s) const
} }
bool bool
SongFilter::Item::Match(const TagItem &item) const SongFilter::Item::Match(const TagItem &item) const noexcept
{ {
return (tag == LOCATE_TAG_ANY_TYPE || (unsigned)item.type == tag) && return (tag == LOCATE_TAG_ANY_TYPE || (unsigned)item.type == tag) &&
StringMatch(item.value); StringMatch(item.value);
} }
bool bool
SongFilter::Item::Match(const Tag &_tag) const SongFilter::Item::Match(const Tag &_tag) const noexcept
{ {
bool visited_types[TAG_NUM_OF_ITEM_TYPES]; bool visited_types[TAG_NUM_OF_ITEM_TYPES];
std::fill_n(visited_types, size_t(TAG_NUM_OF_ITEM_TYPES), false); std::fill_n(visited_types, size_t(TAG_NUM_OF_ITEM_TYPES), false);
...@@ -140,7 +140,7 @@ SongFilter::Item::Match(const Tag &_tag) const ...@@ -140,7 +140,7 @@ SongFilter::Item::Match(const Tag &_tag) const
} }
bool bool
SongFilter::Item::Match(const DetachedSong &song) const SongFilter::Item::Match(const DetachedSong &song) const noexcept
{ {
if (tag == LOCATE_TAG_BASE_TYPE) if (tag == LOCATE_TAG_BASE_TYPE)
return uri_is_child_or_same(value.c_str(), song.GetURI()); return uri_is_child_or_same(value.c_str(), song.GetURI());
...@@ -155,7 +155,7 @@ SongFilter::Item::Match(const DetachedSong &song) const ...@@ -155,7 +155,7 @@ SongFilter::Item::Match(const DetachedSong &song) const
} }
bool bool
SongFilter::Item::Match(const LightSong &song) const SongFilter::Item::Match(const LightSong &song) const noexcept
{ {
if (tag == LOCATE_TAG_BASE_TYPE) { if (tag == LOCATE_TAG_BASE_TYPE) {
const auto uri = song.GetURI(); const auto uri = song.GetURI();
...@@ -185,7 +185,7 @@ SongFilter::~SongFilter() ...@@ -185,7 +185,7 @@ SongFilter::~SongFilter()
gcc_pure gcc_pure
static time_t static time_t
ParseTimeStamp(const char *s) ParseTimeStamp(const char *s) noexcept
{ {
assert(s != nullptr); assert(s != nullptr);
...@@ -246,7 +246,7 @@ SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case) ...@@ -246,7 +246,7 @@ SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case)
} }
bool bool
SongFilter::Match(const DetachedSong &song) const SongFilter::Match(const DetachedSong &song) const noexcept
{ {
for (const auto &i : items) for (const auto &i : items)
if (!i.Match(song)) if (!i.Match(song))
...@@ -256,7 +256,7 @@ SongFilter::Match(const DetachedSong &song) const ...@@ -256,7 +256,7 @@ SongFilter::Match(const DetachedSong &song) const
} }
bool bool
SongFilter::Match(const LightSong &song) const SongFilter::Match(const LightSong &song) const noexcept
{ {
for (const auto &i : items) for (const auto &i : items)
if (!i.Match(song)) if (!i.Match(song))
...@@ -266,7 +266,7 @@ SongFilter::Match(const LightSong &song) const ...@@ -266,7 +266,7 @@ SongFilter::Match(const LightSong &song) const
} }
bool bool
SongFilter::HasOtherThanBase() const SongFilter::HasOtherThanBase() const noexcept
{ {
for (const auto &i : items) for (const auto &i : items)
if (i.GetTag() != LOCATE_TAG_BASE_TYPE) if (i.GetTag() != LOCATE_TAG_BASE_TYPE)
...@@ -276,7 +276,7 @@ SongFilter::HasOtherThanBase() const ...@@ -276,7 +276,7 @@ SongFilter::HasOtherThanBase() const
} }
const char * const char *
SongFilter::GetBase() const SongFilter::GetBase() const noexcept
{ {
for (const auto &i : items) for (const auto &i : items)
if (i.GetTag() == LOCATE_TAG_BASE_TYPE) if (i.GetTag() == LOCATE_TAG_BASE_TYPE)
......
...@@ -80,19 +80,19 @@ public: ...@@ -80,19 +80,19 @@ public:
} }
gcc_pure gcc_nonnull(2) gcc_pure gcc_nonnull(2)
bool StringMatch(const char *s) const; bool StringMatch(const char *s) const noexcept;
gcc_pure gcc_pure
bool Match(const TagItem &tag_item) const; bool Match(const TagItem &tag_item) const noexcept;
gcc_pure gcc_pure
bool Match(const Tag &tag) const; bool Match(const Tag &tag) const noexcept;
gcc_pure gcc_pure
bool Match(const DetachedSong &song) const; bool Match(const DetachedSong &song) const noexcept;
gcc_pure gcc_pure
bool Match(const LightSong &song) const; bool Match(const LightSong &song) const noexcept;
}; };
private: private:
...@@ -112,20 +112,20 @@ public: ...@@ -112,20 +112,20 @@ public:
bool Parse(ConstBuffer<const char *> args, bool fold_case=false); bool Parse(ConstBuffer<const char *> args, bool fold_case=false);
gcc_pure gcc_pure
bool Match(const Tag &tag) const; bool Match(const Tag &tag) const noexcept;
gcc_pure gcc_pure
bool Match(const DetachedSong &song) const; bool Match(const DetachedSong &song) const noexcept;
gcc_pure gcc_pure
bool Match(const LightSong &song) const; bool Match(const LightSong &song) const noexcept;
const std::list<Item> &GetItems() const { const std::list<Item> &GetItems() const noexcept {
return items; return items;
} }
gcc_pure gcc_pure
bool IsEmpty() const { bool IsEmpty() const noexcept {
return items.empty(); return items.empty();
} }
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
* Is there at least one item with "fold case" enabled? * Is there at least one item with "fold case" enabled?
*/ */
gcc_pure gcc_pure
bool HasFoldCase() const { bool HasFoldCase() const noexcept {
for (const auto &i : items) for (const auto &i : items)
if (i.GetFoldCase()) if (i.GetFoldCase())
return true; return true;
...@@ -145,14 +145,14 @@ public: ...@@ -145,14 +145,14 @@ public:
* Does this filter contain constraints other than "base"? * Does this filter contain constraints other than "base"?
*/ */
gcc_pure gcc_pure
bool HasOtherThanBase() const; bool HasOtherThanBase() const noexcept;
/** /**
* Returns the "base" specification (if there is one) or * Returns the "base" specification (if there is one) or
* nullptr. * nullptr.
*/ */
gcc_pure gcc_pure
const char *GetBase() const; const char *GetBase() const noexcept;
}; };
/** /**
...@@ -160,6 +160,6 @@ public: ...@@ -160,6 +160,6 @@ public:
*/ */
gcc_pure gcc_pure
unsigned unsigned
locate_parse_type(const char *str); locate_parse_type(const char *str) noexcept;
#endif #endif
...@@ -50,7 +50,7 @@ StateFile::StateFile(AllocatedPath &&_path, ...@@ -50,7 +50,7 @@ StateFile::StateFile(AllocatedPath &&_path,
} }
void void
StateFile::RememberVersions() StateFile::RememberVersions() noexcept
{ {
prev_volume_version = sw_volume_state_get_hash(); prev_volume_version = sw_volume_state_get_hash();
prev_output_version = audio_output_state_get_version(); prev_output_version = audio_output_state_get_version();
...@@ -59,7 +59,7 @@ StateFile::RememberVersions() ...@@ -59,7 +59,7 @@ StateFile::RememberVersions()
} }
bool bool
StateFile::IsModified() const StateFile::IsModified() const noexcept
{ {
return prev_volume_version != sw_volume_state_get_hash() || return prev_volume_version != sw_volume_state_get_hash() ||
prev_output_version != audio_output_state_get_version() || prev_output_version != audio_output_state_get_version() ||
......
...@@ -67,14 +67,14 @@ private: ...@@ -67,14 +67,14 @@ private:
/** /**
* Save the current state versions for use with IsModified(). * Save the current state versions for use with IsModified().
*/ */
void RememberVersions(); void RememberVersions() noexcept;
/** /**
* Check if MPD's state was modified since the last * Check if MPD's state was modified since the last
* RememberVersions() call. * RememberVersions() call.
*/ */
gcc_pure gcc_pure
bool IsModified() const; bool IsModified() const noexcept;
/* virtual methods from TimeoutMonitor */ /* virtual methods from TimeoutMonitor */
void OnTimeout() override; void OnTimeout() override;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
gcc_pure gcc_pure
static bool static bool
CheckDecoderPlugin(const DecoderPlugin &plugin, CheckDecoderPlugin(const DecoderPlugin &plugin,
const char *suffix, const char *mime) const char *suffix, const char *mime) noexcept
{ {
return (mime != nullptr && plugin.SupportsMimeType(mime)) || return (mime != nullptr && plugin.SupportsMimeType(mime)) ||
(suffix != nullptr && plugin.SupportsSuffix(suffix)); (suffix != nullptr && plugin.SupportsSuffix(suffix));
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
gcc_pure gcc_pure
static char * static char *
FindSlash(char *p, size_t i) FindSlash(char *p, size_t i) noexcept
{ {
for (; i > 0; --i) for (; i > 0; --i)
if (p[i] == '/') if (p[i] == '/')
...@@ -39,7 +39,7 @@ FindSlash(char *p, size_t i) ...@@ -39,7 +39,7 @@ FindSlash(char *p, size_t i)
gcc_pure gcc_pure
static const char * static const char *
FindSuffix(const char *p, const char *i) FindSuffix(const char *p, const char *i) noexcept
{ {
for (; i > p; --i) { for (; i > p; --i) {
if (*i == '.') if (*i == '.')
......
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
~Bzip2InputStream(); ~Bzip2InputStream();
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override; bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override; size_t Read(void *ptr, size_t size) override;
private: private:
...@@ -205,7 +205,7 @@ Bzip2InputStream::Read(void *ptr, size_t length) ...@@ -205,7 +205,7 @@ Bzip2InputStream::Read(void *ptr, size_t length)
} }
bool bool
Bzip2InputStream::IsEOF() Bzip2InputStream::IsEOF() noexcept
{ {
return eof; return eof;
} }
......
...@@ -162,7 +162,7 @@ public: ...@@ -162,7 +162,7 @@ public:
} }
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override; bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override; size_t Read(void *ptr, size_t size) override;
}; };
...@@ -213,7 +213,7 @@ Iso9660InputStream::Read(void *ptr, size_t read_size) ...@@ -213,7 +213,7 @@ Iso9660InputStream::Read(void *ptr, size_t read_size)
} }
bool bool
Iso9660InputStream::IsEOF() Iso9660InputStream::IsEOF() noexcept
{ {
return offset == size; return offset == size;
} }
......
...@@ -116,7 +116,7 @@ struct ZzipInputStream final : public InputStream { ...@@ -116,7 +116,7 @@ struct ZzipInputStream final : public InputStream {
} }
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override; bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override; size_t Read(void *ptr, size_t size) override;
void Seek(offset_type offset) override; void Seek(offset_type offset) override;
}; };
...@@ -147,7 +147,7 @@ ZzipInputStream::Read(void *ptr, size_t read_size) ...@@ -147,7 +147,7 @@ ZzipInputStream::Read(void *ptr, size_t read_size)
} }
bool bool
ZzipInputStream::IsEOF() ZzipInputStream::IsEOF() noexcept
{ {
return offset_type(zzip_tell(file)) == size; return offset_type(zzip_tell(file)) == size;
} }
......
...@@ -28,7 +28,7 @@ const Domain client_domain("client"); ...@@ -28,7 +28,7 @@ const Domain client_domain("client");
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
const Database * const Database *
Client::GetDatabase() const Client::GetDatabase() const noexcept
{ {
return partition.instance.GetDatabase(); return partition.instance.GetDatabase();
} }
...@@ -40,7 +40,7 @@ Client::GetDatabaseOrThrow() const ...@@ -40,7 +40,7 @@ Client::GetDatabaseOrThrow() const
} }
const Storage * const Storage *
Client::GetStorage() const Client::GetStorage() const noexcept
{ {
return partition.instance.storage; return partition.instance.storage;
} }
......
...@@ -160,7 +160,7 @@ public: ...@@ -160,7 +160,7 @@ public:
}; };
gcc_pure gcc_pure
bool IsSubscribed(const char *channel_name) const { bool IsSubscribed(const char *channel_name) const noexcept {
return subscriptions.find(channel_name) != subscriptions.end(); return subscriptions.find(channel_name) != subscriptions.end();
} }
...@@ -186,7 +186,7 @@ public: ...@@ -186,7 +186,7 @@ public:
* Wrapper for Instance::GetDatabase(). * Wrapper for Instance::GetDatabase().
*/ */
gcc_pure gcc_pure
const Database *GetDatabase() const; const Database *GetDatabase() const noexcept;
/** /**
* Wrapper for Instance::GetDatabaseOrThrow(). * Wrapper for Instance::GetDatabaseOrThrow().
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
const Database &GetDatabaseOrThrow() const; const Database &GetDatabaseOrThrow() const;
gcc_pure gcc_pure
const Storage *GetStorage() const; const Storage *GetStorage() const noexcept;
private: private:
/* virtual methods from class BufferedSocket */ /* virtual methods from class BufferedSocket */
......
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
gcc_const gcc_const
static bool static bool
valid_channel_char(const char ch) valid_channel_char(const char ch) noexcept
{ {
return IsAlphaNumericASCII(ch) || return IsAlphaNumericASCII(ch) ||
ch == '_' || ch == '-' || ch == '.' || ch == ':'; ch == '_' || ch == '-' || ch == '.' || ch == ':';
} }
bool bool
client_message_valid_channel_name(const char *name) client_message_valid_channel_name(const char *name) noexcept
{ {
do { do {
if (!valid_channel_char(*name)) if (!valid_channel_char(*name))
......
...@@ -53,6 +53,6 @@ public: ...@@ -53,6 +53,6 @@ public:
gcc_pure gcc_pure
bool bool
client_message_valid_channel_name(const char *name); client_message_valid_channel_name(const char *name) noexcept;
#endif #endif
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
gcc_const gcc_const
static enum ack static enum ack
ToAck(PlaylistResult result) ToAck(PlaylistResult result) noexcept
{ {
switch (result) { switch (result) {
case PlaylistResult::SUCCESS: case PlaylistResult::SUCCESS:
...@@ -90,7 +90,7 @@ ToAck(PlaylistResult result) ...@@ -90,7 +90,7 @@ ToAck(PlaylistResult result)
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
gcc_const gcc_const
static enum ack static enum ack
ToAck(DatabaseErrorCode code) ToAck(DatabaseErrorCode code) noexcept
{ {
switch (code) { switch (code) {
case DatabaseErrorCode::DISABLED: case DatabaseErrorCode::DISABLED:
...@@ -107,7 +107,7 @@ ToAck(DatabaseErrorCode code) ...@@ -107,7 +107,7 @@ ToAck(DatabaseErrorCode code)
gcc_pure gcc_pure
static enum ack static enum ack
ToAck(std::exception_ptr ep) ToAck(std::exception_ptr ep) noexcept
{ {
try { try {
std::rethrow_exception(ep); std::rethrow_exception(ep);
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
gcc_pure gcc_pure
static bool static bool
SkipNameFS(PathTraitsFS::const_pointer_type name_fs) SkipNameFS(PathTraitsFS::const_pointer_type name_fs) noexcept
{ {
return name_fs[0] == '.' && return name_fs[0] == '.' &&
(name_fs[1] == 0 || (name_fs[1] == 0 ||
...@@ -53,7 +53,7 @@ SkipNameFS(PathTraitsFS::const_pointer_type name_fs) ...@@ -53,7 +53,7 @@ SkipNameFS(PathTraitsFS::const_pointer_type name_fs)
gcc_pure gcc_pure
static bool static bool
skip_path(Path name_fs) skip_path(Path name_fs) noexcept
{ {
return name_fs.HasNewline(); return name_fs.HasNewline();
} }
...@@ -107,7 +107,7 @@ handle_listfiles_local(Response &r, Path path_fs) ...@@ -107,7 +107,7 @@ handle_listfiles_local(Response &r, Path path_fs)
gcc_pure gcc_pure
static bool static bool
IsValidName(const char *p) IsValidName(const char *p) noexcept
{ {
if (!IsAlphaASCII(*p)) if (!IsAlphaASCII(*p))
return false; return false;
...@@ -123,7 +123,7 @@ IsValidName(const char *p) ...@@ -123,7 +123,7 @@ IsValidName(const char *p)
gcc_pure gcc_pure
static bool static bool
IsValidValue(const char *p) IsValidValue(const char *p) noexcept
{ {
while (*p) { while (*p) {
const char ch = *p++; const char ch = *p++;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <string> #include <string>
bool bool
neighbor_commands_available(const Instance &instance) neighbor_commands_available(const Instance &instance) noexcept
{ {
return instance.neighbors != nullptr; return instance.neighbors != nullptr;
} }
......
...@@ -30,7 +30,7 @@ class Response; ...@@ -30,7 +30,7 @@ class Response;
gcc_pure gcc_pure
bool bool
neighbor_commands_available(const Instance &instance); neighbor_commands_available(const Instance &instance) noexcept;
CommandResult CommandResult
handle_listneighbors(Client &client, Request request, Response &response); handle_listneighbors(Client &client, Request request, Response &response);
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
bool bool
playlist_commands_available() playlist_commands_available() noexcept
{ {
return !map_spl_path().IsNull(); return !map_spl_path().IsNull();
} }
......
...@@ -29,7 +29,7 @@ class Response; ...@@ -29,7 +29,7 @@ class Response;
gcc_const gcc_const
bool bool
playlist_commands_available(); playlist_commands_available() noexcept;
CommandResult CommandResult
handle_save(Client &client, Request request, Response &response); handle_save(Client &client, Request request, Response &response);
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
gcc_pure gcc_pure
static bool static bool
skip_path(const char *name_utf8) skip_path(const char *name_utf8) noexcept
{ {
return strchr(name_utf8, '\n') != nullptr; return strchr(name_utf8, '\n') != nullptr;
} }
......
...@@ -68,7 +68,7 @@ ConfigBlock::~ConfigBlock() ...@@ -68,7 +68,7 @@ ConfigBlock::~ConfigBlock()
} }
const BlockParam * const BlockParam *
ConfigBlock::GetBlockParam(const char *name) const ConfigBlock::GetBlockParam(const char *name) const noexcept
{ {
for (const auto &i : block_params) { for (const auto &i : block_params) {
if (i.name == name) { if (i.name == name) {
...@@ -81,7 +81,8 @@ ConfigBlock::GetBlockParam(const char *name) const ...@@ -81,7 +81,8 @@ ConfigBlock::GetBlockParam(const char *name) const
} }
const char * const char *
ConfigBlock::GetBlockValue(const char *name, const char *default_value) const ConfigBlock::GetBlockValue(const char *name,
const char *default_value) const noexcept
{ {
const BlockParam *bp = GetBlockParam(name); const BlockParam *bp = GetBlockParam(name);
if (bp == nullptr) if (bp == nullptr)
......
...@@ -101,11 +101,11 @@ struct ConfigBlock { ...@@ -101,11 +101,11 @@ struct ConfigBlock {
} }
gcc_nonnull_all gcc_pure gcc_nonnull_all gcc_pure
const BlockParam *GetBlockParam(const char *_name) const; const BlockParam *GetBlockParam(const char *_name) const noexcept;
gcc_pure gcc_pure
const char *GetBlockValue(const char *name, const char *GetBlockValue(const char *name,
const char *default_value=nullptr) const; const char *default_value=nullptr) const noexcept;
/** /**
* Same as config_get_path(), but looks up the setting in the * Same as config_get_path(), but looks up the setting in the
......
...@@ -75,7 +75,7 @@ void config_global_check(void) ...@@ -75,7 +75,7 @@ void config_global_check(void)
} }
const ConfigParam * const ConfigParam *
config_get_param(ConfigOption option) config_get_param(ConfigOption option) noexcept
{ {
auto *param = config_data.params[unsigned(option)]; auto *param = config_data.params[unsigned(option)];
if (param != nullptr) if (param != nullptr)
...@@ -84,7 +84,7 @@ config_get_param(ConfigOption option) ...@@ -84,7 +84,7 @@ config_get_param(ConfigOption option)
} }
const ConfigBlock * const ConfigBlock *
config_get_block(ConfigBlockOption option) config_get_block(ConfigBlockOption option) noexcept
{ {
ConfigBlock *block = config_data.blocks[unsigned(option)]; ConfigBlock *block = config_data.blocks[unsigned(option)];
if (block != nullptr) if (block != nullptr)
...@@ -110,7 +110,7 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value) ...@@ -110,7 +110,7 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value)
} }
const char * const char *
config_get_string(ConfigOption option, const char *default_value) config_get_string(ConfigOption option, const char *default_value) noexcept
{ {
const auto *param = config_get_param(option); const auto *param = config_get_param(option);
......
...@@ -48,11 +48,11 @@ ReadConfigFile(Path path); ...@@ -48,11 +48,11 @@ ReadConfigFile(Path path);
gcc_pure gcc_pure
const ConfigParam * const ConfigParam *
config_get_param(enum ConfigOption option); config_get_param(enum ConfigOption option) noexcept;
gcc_pure gcc_pure
const ConfigBlock * const ConfigBlock *
config_get_block(enum ConfigBlockOption option); config_get_block(enum ConfigBlockOption option) noexcept;
/** /**
* Find a block with a matching attribute. * Find a block with a matching attribute.
...@@ -74,7 +74,8 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value); ...@@ -74,7 +74,8 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value);
gcc_pure gcc_pure
const char * const char *
config_get_string(enum ConfigOption option, const char *default_value=nullptr); config_get_string(enum ConfigOption option,
const char *default_value=nullptr) noexcept;
/** /**
* Returns an optional configuration variable which contains an * Returns an optional configuration variable which contains an
......
...@@ -102,13 +102,13 @@ enum class ConfigBlockOption { ...@@ -102,13 +102,13 @@ enum class ConfigBlockOption {
*/ */
gcc_pure gcc_pure
enum ConfigOption enum ConfigOption
ParseConfigOptionName(const char *name); ParseConfigOptionName(const char *name) noexcept;
/** /**
* @return #ConfigOption::MAX if not found * @return #ConfigOption::MAX if not found
*/ */
gcc_pure gcc_pure
enum ConfigBlockOption enum ConfigBlockOption
ParseConfigBlockOptionName(const char *name); ParseConfigBlockOptionName(const char *name) noexcept;
#endif #endif
...@@ -101,7 +101,7 @@ static_assert(n_config_block_templates == unsigned(ConfigBlockOption::MAX), ...@@ -101,7 +101,7 @@ static_assert(n_config_block_templates == unsigned(ConfigBlockOption::MAX),
gcc_pure gcc_pure
static inline unsigned static inline unsigned
ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count, ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
const char *name) const char *name) noexcept
{ {
unsigned i = 0; unsigned i = 0;
for (; i < count; ++i) for (; i < count; ++i)
...@@ -112,7 +112,7 @@ ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count, ...@@ -112,7 +112,7 @@ ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
} }
ConfigOption ConfigOption
ParseConfigOptionName(const char *name) ParseConfigOptionName(const char *name) noexcept
{ {
return ConfigOption(ParseConfigTemplateName(config_param_templates, return ConfigOption(ParseConfigTemplateName(config_param_templates,
n_config_param_templates, n_config_param_templates,
...@@ -120,7 +120,7 @@ ParseConfigOptionName(const char *name) ...@@ -120,7 +120,7 @@ ParseConfigOptionName(const char *name)
} }
ConfigBlockOption ConfigBlockOption
ParseConfigBlockOptionName(const char *name) ParseConfigBlockOptionName(const char *name) noexcept
{ {
return ConfigBlockOption(ParseConfigTemplateName(config_block_templates, return ConfigBlockOption(ParseConfigTemplateName(config_block_templates,
n_config_block_templates, n_config_block_templates,
......
...@@ -45,7 +45,7 @@ extern ThreadId db_mutex_holder; ...@@ -45,7 +45,7 @@ extern ThreadId db_mutex_holder;
*/ */
gcc_pure gcc_pure
static inline bool static inline bool
holding_db_lock(void) holding_db_lock() noexcept
{ {
return db_mutex_holder.IsInside(); return db_mutex_holder.IsInside();
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
SignedSongTime SignedSongTime
LightSong::GetDuration() const LightSong::GetDuration() const noexcept
{ {
SongTime a = start_time, b = end_time; SongTime a = start_time, b = end_time;
if (!b.IsPositive()) { if (!b.IsPositive()) {
......
...@@ -76,7 +76,7 @@ struct LightSong { ...@@ -76,7 +76,7 @@ struct LightSong {
SongTime end_time; SongTime end_time;
gcc_pure gcc_pure
std::string GetURI() const { std::string GetURI() const noexcept {
if (directory == nullptr) if (directory == nullptr)
return std::string(uri); return std::string(uri);
...@@ -87,7 +87,7 @@ struct LightSong { ...@@ -87,7 +87,7 @@ struct LightSong {
} }
gcc_pure gcc_pure
SignedSongTime GetDuration() const; SignedSongTime GetDuration() const noexcept;
}; };
#endif #endif
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <assert.h> #include <assert.h>
PlaylistVector::iterator PlaylistVector::iterator
PlaylistVector::find(const char *name) PlaylistVector::find(const char *name) noexcept
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(name != nullptr); assert(name != nullptr);
......
...@@ -31,7 +31,7 @@ protected: ...@@ -31,7 +31,7 @@ protected:
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
gcc_pure gcc_pure
iterator find(const char *name); iterator find(const char *name) noexcept;
public: public:
using std::list<PlaylistInfo>::empty; using std::list<PlaylistInfo>::empty;
......
...@@ -38,7 +38,7 @@ const DatabasePlugin *const database_plugins[] = { ...@@ -38,7 +38,7 @@ const DatabasePlugin *const database_plugins[] = {
}; };
const DatabasePlugin * const DatabasePlugin *
GetDatabasePluginByName(const char *name) GetDatabasePluginByName(const char *name) noexcept
{ {
for (auto i = database_plugins; *i != nullptr; ++i) for (auto i = database_plugins; *i != nullptr; ++i)
if (strcmp((*i)->name, name) == 0) if (strcmp((*i)->name, name) == 0)
......
...@@ -32,6 +32,6 @@ extern const DatabasePlugin *const database_plugins[]; ...@@ -32,6 +32,6 @@ extern const DatabasePlugin *const database_plugins[];
gcc_pure gcc_pure
const DatabasePlugin * const DatabasePlugin *
GetDatabasePluginByName(const char *name); GetDatabasePluginByName(const char *name) noexcept;
#endif #endif
...@@ -34,19 +34,19 @@ DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive, ...@@ -34,19 +34,19 @@ DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive,
} }
bool bool
DatabaseSelection::IsEmpty() const DatabaseSelection::IsEmpty() const noexcept
{ {
return uri.empty() && (filter == nullptr || filter->IsEmpty()); return uri.empty() && (filter == nullptr || filter->IsEmpty());
} }
bool bool
DatabaseSelection::HasOtherThanBase() const DatabaseSelection::HasOtherThanBase() const noexcept
{ {
return filter != nullptr && filter->HasOtherThanBase(); return filter != nullptr && filter->HasOtherThanBase();
} }
bool bool
DatabaseSelection::Match(const LightSong &song) const DatabaseSelection::Match(const LightSong &song) const noexcept
{ {
return filter == nullptr || filter->Match(song); return filter == nullptr || filter->Match(song);
} }
...@@ -45,16 +45,16 @@ struct DatabaseSelection { ...@@ -45,16 +45,16 @@ struct DatabaseSelection {
const SongFilter *_filter=nullptr); const SongFilter *_filter=nullptr);
gcc_pure gcc_pure
bool IsEmpty() const; bool IsEmpty() const noexcept;
/** /**
* Does this selection contain constraints other than "base"? * Does this selection contain constraints other than "base"?
*/ */
gcc_pure gcc_pure
bool HasOtherThanBase() const; bool HasOtherThanBase() const noexcept;
gcc_pure gcc_pure
bool Match(const LightSong &song) const; bool Match(const LightSong &song) const noexcept;
}; };
#endif #endif
...@@ -216,7 +216,7 @@ ProxySong::ProxySong(const mpd_song *song) ...@@ -216,7 +216,7 @@ ProxySong::ProxySong(const mpd_song *song)
gcc_const gcc_const
static enum mpd_tag_type static enum mpd_tag_type
Convert(TagType tag_type) Convert(TagType tag_type) noexcept
{ {
for (auto i = &tag_table[0]; i->d != TAG_NUM_OF_ITEM_TYPES; ++i) for (auto i = &tag_table[0]; i->d != TAG_NUM_OF_ITEM_TYPES; ++i)
if (i->d == tag_type) if (i->d == tag_type)
...@@ -574,7 +574,7 @@ Visit(struct mpd_connection *connection, ...@@ -574,7 +574,7 @@ Visit(struct mpd_connection *connection,
gcc_pure gcc_pure
static bool static bool
Match(const SongFilter *filter, const LightSong &song) Match(const SongFilter *filter, const LightSong &song) noexcept
{ {
return filter == nullptr || filter->Match(song); return filter == nullptr || filter->Match(song);
} }
...@@ -717,7 +717,7 @@ SearchSongs(struct mpd_connection *connection, ...@@ -717,7 +717,7 @@ SearchSongs(struct mpd_connection *connection,
*/ */
gcc_pure gcc_pure
static bool static bool
ServerSupportsSearchBase(const struct mpd_connection *connection) ServerSupportsSearchBase(const struct mpd_connection *connection) noexcept
{ {
#if LIBMPDCLIENT_CHECK_VERSION(2,9,0) #if LIBMPDCLIENT_CHECK_VERSION(2,9,0)
return mpd_connection_cmp_server_version(connection, 0, 18, 0) >= 0; return mpd_connection_cmp_server_version(connection, 0, 18, 0) >= 0;
......
...@@ -65,7 +65,7 @@ Directory::Delete() ...@@ -65,7 +65,7 @@ Directory::Delete()
} }
const char * const char *
Directory::GetName() const Directory::GetName() const noexcept
{ {
assert(!IsRoot()); assert(!IsRoot());
...@@ -89,7 +89,7 @@ Directory::CreateChild(const char *name_utf8) ...@@ -89,7 +89,7 @@ Directory::CreateChild(const char *name_utf8)
} }
const Directory * const Directory *
Directory::FindChild(const char *name) const Directory::FindChild(const char *name) const noexcept
{ {
assert(holding_db_lock()); assert(holding_db_lock());
...@@ -101,7 +101,7 @@ Directory::FindChild(const char *name) const ...@@ -101,7 +101,7 @@ Directory::FindChild(const char *name) const
} }
void void
Directory::PruneEmpty() Directory::PruneEmpty() noexcept
{ {
assert(holding_db_lock()); assert(holding_db_lock());
...@@ -118,7 +118,7 @@ Directory::PruneEmpty() ...@@ -118,7 +118,7 @@ Directory::PruneEmpty()
} }
Directory::LookupResult Directory::LookupResult
Directory::LookupDirectory(const char *uri) Directory::LookupDirectory(const char *uri) noexcept
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(uri != nullptr); assert(uri != nullptr);
...@@ -173,7 +173,7 @@ Directory::AddSong(Song *song) ...@@ -173,7 +173,7 @@ Directory::AddSong(Song *song)
} }
void void
Directory::RemoveSong(Song *song) Directory::RemoveSong(Song *song) noexcept
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(song != nullptr); assert(song != nullptr);
...@@ -183,7 +183,7 @@ Directory::RemoveSong(Song *song) ...@@ -183,7 +183,7 @@ Directory::RemoveSong(Song *song)
} }
const Song * const Song *
Directory::FindSong(const char *name_utf8) const Directory::FindSong(const char *name_utf8) const noexcept
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(name_utf8 != nullptr); assert(name_utf8 != nullptr);
...@@ -200,13 +200,13 @@ Directory::FindSong(const char *name_utf8) const ...@@ -200,13 +200,13 @@ Directory::FindSong(const char *name_utf8) const
gcc_pure gcc_pure
static bool static bool
directory_cmp(const Directory &a, const Directory &b) directory_cmp(const Directory &a, const Directory &b) noexcept
{ {
return IcuCollate(a.path.c_str(), b.path.c_str()) < 0; return IcuCollate(a.path.c_str(), b.path.c_str()) < 0;
} }
void void
Directory::Sort() Directory::Sort() noexcept
{ {
assert(holding_db_lock()); assert(holding_db_lock());
...@@ -261,7 +261,7 @@ Directory::Walk(bool recursive, const SongFilter *filter, ...@@ -261,7 +261,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
} }
LightDirectory LightDirectory
Directory::Export() const Directory::Export() const noexcept
{ {
return LightDirectory(GetPath(), mtime); return LightDirectory(GetPath(), mtime);
} }
...@@ -134,10 +134,10 @@ public: ...@@ -134,10 +134,10 @@ public:
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
gcc_pure gcc_pure
const Directory *FindChild(const char *name) const; const Directory *FindChild(const char *name) const noexcept;
gcc_pure gcc_pure
Directory *FindChild(const char *name) { Directory *FindChild(const char *name) noexcept {
const Directory *cthis = this; const Directory *cthis = this;
return const_cast<Directory *>(cthis->FindChild(name)); return const_cast<Directory *>(cthis->FindChild(name));
} }
...@@ -177,10 +177,10 @@ public: ...@@ -177,10 +177,10 @@ public:
* @return the Directory, or nullptr if none was found * @return the Directory, or nullptr if none was found
*/ */
gcc_pure gcc_pure
LookupResult LookupDirectory(const char *uri); LookupResult LookupDirectory(const char *uri) noexcept;
gcc_pure gcc_pure
bool IsEmpty() const { bool IsEmpty() const noexcept {
return children.empty() && return children.empty() &&
songs.empty() && songs.empty() &&
playlists.empty(); playlists.empty();
...@@ -195,13 +195,13 @@ public: ...@@ -195,13 +195,13 @@ public:
* Returns the base name of the directory. * Returns the base name of the directory.
*/ */
gcc_pure gcc_pure
const char *GetName() const; const char *GetName() const noexcept;
/** /**
* Is this the root directory of the music database? * Is this the root directory of the music database?
*/ */
gcc_pure gcc_pure
bool IsRoot() const { bool IsRoot() const noexcept {
return parent == nullptr; return parent == nullptr;
} }
...@@ -229,10 +229,10 @@ public: ...@@ -229,10 +229,10 @@ public:
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
gcc_pure gcc_pure
const Song *FindSong(const char *name_utf8) const; const Song *FindSong(const char *name_utf8) const noexcept;
gcc_pure gcc_pure
Song *FindSong(const char *name_utf8) { Song *FindSong(const char *name_utf8) noexcept {
const Directory *cthis = this; const Directory *cthis = this;
return const_cast<Song *>(cthis->FindSong(name_utf8)); return const_cast<Song *>(cthis->FindSong(name_utf8));
} }
...@@ -248,19 +248,19 @@ public: ...@@ -248,19 +248,19 @@ public:
* invalidates the song object, because the "parent" attribute becomes * invalidates the song object, because the "parent" attribute becomes
* stale), but does not free it. * stale), but does not free it.
*/ */
void RemoveSong(Song *song); void RemoveSong(Song *song) noexcept;
/** /**
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
void PruneEmpty(); void PruneEmpty() noexcept;
/** /**
* Sort all directory entries recursively. * Sort all directory entries recursively.
* *
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
void Sort(); void Sort() noexcept;
/** /**
* Caller must lock #db_mutex. * Caller must lock #db_mutex.
...@@ -270,7 +270,7 @@ public: ...@@ -270,7 +270,7 @@ public:
VisitPlaylist visit_playlist) const; VisitPlaylist visit_playlist) const;
gcc_pure gcc_pure
LightDirectory Export() const; LightDirectory Export() const noexcept;
}; };
#endif #endif
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
gcc_const gcc_const
static const char * static const char *
DeviceToTypeString(unsigned device) DeviceToTypeString(unsigned device) noexcept
{ {
switch (device) { switch (device) {
case DEVICE_INARCHIVE: case DEVICE_INARCHIVE:
...@@ -56,7 +56,7 @@ DeviceToTypeString(unsigned device) ...@@ -56,7 +56,7 @@ DeviceToTypeString(unsigned device)
gcc_pure gcc_pure
static unsigned static unsigned
ParseTypeString(const char *type) ParseTypeString(const char *type) noexcept
{ {
if (strcmp(type, "archive") == 0) if (strcmp(type, "archive") == 0)
return DEVICE_INARCHIVE; return DEVICE_INARCHIVE;
......
...@@ -77,7 +77,7 @@ Song::Free() ...@@ -77,7 +77,7 @@ Song::Free()
} }
std::string std::string
Song::GetURI() const Song::GetURI() const noexcept
{ {
assert(*uri); assert(*uri);
...@@ -96,7 +96,7 @@ Song::GetURI() const ...@@ -96,7 +96,7 @@ Song::GetURI() const
} }
LightSong LightSong
Song::Export() const Song::Export() const noexcept
{ {
LightSong dest; LightSong dest;
dest.directory = parent->IsRoot() dest.directory = parent->IsRoot()
......
...@@ -123,10 +123,10 @@ struct Song { ...@@ -123,10 +123,10 @@ struct Song {
* location within the music directory. * location within the music directory.
*/ */
gcc_pure gcc_pure
std::string GetURI() const; std::string GetURI() const noexcept;
gcc_pure gcc_pure
LightSong Export() const; LightSong Export() const noexcept;
}; };
typedef boost::intrusive::list<Song, typedef boost::intrusive::list<Song,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
static int static int
compare_utf8_string(const char *a, const char *b) compare_utf8_string(const char *a, const char *b) noexcept
{ {
if (a == nullptr) if (a == nullptr)
return b == nullptr ? 0 : -1; return b == nullptr ? 0 : -1;
...@@ -42,8 +42,7 @@ compare_utf8_string(const char *a, const char *b) ...@@ -42,8 +42,7 @@ compare_utf8_string(const char *a, const char *b)
* nullptr. * nullptr.
*/ */
static int static int
compare_string_tag_item(const Tag &a, const Tag &b, compare_string_tag_item(const Tag &a, const Tag &b, TagType type) noexcept
TagType type)
{ {
return compare_utf8_string(a.GetValue(type), return compare_utf8_string(a.GetValue(type),
b.GetValue(type)); b.GetValue(type));
...@@ -54,7 +53,7 @@ compare_string_tag_item(const Tag &a, const Tag &b, ...@@ -54,7 +53,7 @@ compare_string_tag_item(const Tag &a, const Tag &b,
* (e.g. disc or track number). Either one may be nullptr. * (e.g. disc or track number). Either one may be nullptr.
*/ */
static int static int
compare_number_string(const char *a, const char *b) compare_number_string(const char *a, const char *b) noexcept
{ {
long ai = a == nullptr ? 0 : strtol(a, nullptr, 10); long ai = a == nullptr ? 0 : strtol(a, nullptr, 10);
long bi = b == nullptr ? 0 : strtol(b, nullptr, 10); long bi = b == nullptr ? 0 : strtol(b, nullptr, 10);
...@@ -69,7 +68,7 @@ compare_number_string(const char *a, const char *b) ...@@ -69,7 +68,7 @@ compare_number_string(const char *a, const char *b)
} }
static int static int
compare_tag_item(const Tag &a, const Tag &b, TagType type) compare_tag_item(const Tag &a, const Tag &b, TagType type) noexcept
{ {
return compare_number_string(a.GetValue(type), return compare_number_string(a.GetValue(type),
b.GetValue(type)); b.GetValue(type));
...@@ -78,7 +77,7 @@ compare_tag_item(const Tag &a, const Tag &b, TagType type) ...@@ -78,7 +77,7 @@ compare_tag_item(const Tag &a, const Tag &b, TagType type)
/* Only used for sorting/searchin a songvec, not general purpose compares */ /* Only used for sorting/searchin a songvec, not general purpose compares */
gcc_pure gcc_pure
static bool static bool
song_cmp(const Song &a, const Song &b) song_cmp(const Song &a, const Song &b) noexcept
{ {
int ret; int ret;
...@@ -102,7 +101,7 @@ song_cmp(const Song &a, const Song &b) ...@@ -102,7 +101,7 @@ song_cmp(const Song &a, const Song &b)
} }
void void
song_list_sort(SongList &songs) song_list_sort(SongList &songs) noexcept
{ {
songs.sort(song_cmp); songs.sort(song_cmp);
} }
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
#include "Song.hxx" #include "Song.hxx"
void void
song_list_sort(SongList &songs); song_list_sort(SongList &songs) noexcept;
#endif #endif
...@@ -39,7 +39,7 @@ UPnPDirContent::~UPnPDirContent() ...@@ -39,7 +39,7 @@ UPnPDirContent::~UPnPDirContent()
gcc_pure gcc_pure
static UPnPDirObject::ItemClass static UPnPDirObject::ItemClass
ParseItemClass(StringView name) ParseItemClass(StringView name) noexcept
{ {
if (name.EqualsLiteral("object.item.audioItem.musicTrack")) if (name.EqualsLiteral("object.item.audioItem.musicTrack"))
return UPnPDirObject::ItemClass::MUSIC; return UPnPDirObject::ItemClass::MUSIC;
...@@ -51,7 +51,7 @@ ParseItemClass(StringView name) ...@@ -51,7 +51,7 @@ ParseItemClass(StringView name)
gcc_pure gcc_pure
static SignedSongTime static SignedSongTime
ParseDuration(const char *duration) ParseDuration(const char *duration) noexcept
{ {
char *endptr; char *endptr;
...@@ -81,7 +81,7 @@ ParseDuration(const char *duration) ...@@ -81,7 +81,7 @@ ParseDuration(const char *duration)
*/ */
gcc_pure gcc_pure
static std::string && static std::string &&
TitleToPathSegment(std::string &&s) TitleToPathSegment(std::string &&s) noexcept
{ {
std::replace(s.begin(), s.end(), '/', '_'); std::replace(s.begin(), s.end(), '/', '_');
return std::move(s); return std::move(s);
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
~UPnPDirContent(); ~UPnPDirContent();
gcc_pure gcc_pure
UPnPDirObject *FindObject(const char *name) { UPnPDirObject *FindObject(const char *name) noexcept {
for (auto &o : objects) for (auto &o : objects)
if (o.name == name) if (o.name == name)
return &o; return &o;
......
...@@ -56,7 +56,7 @@ InotifyQueue::OnTimeout() ...@@ -56,7 +56,7 @@ InotifyQueue::OnTimeout()
gcc_pure gcc_pure
static bool static bool
path_in(const char *path, const char *possible_parent) path_in(const char *path, const char *possible_parent) noexcept
{ {
if (StringIsEmpty(path)) if (StringIsEmpty(path))
return true; return true;
......
...@@ -62,10 +62,10 @@ struct WatchDirectory { ...@@ -62,10 +62,10 @@ struct WatchDirectory {
WatchDirectory &operator=(const WatchDirectory &) = delete; WatchDirectory &operator=(const WatchDirectory &) = delete;
gcc_pure gcc_pure
unsigned GetDepth() const; unsigned GetDepth() const noexcept;
gcc_pure gcc_pure
AllocatedPath GetUriFS() const; AllocatedPath GetUriFS() const noexcept;
}; };
static InotifySource *inotify_source; static InotifySource *inotify_source;
...@@ -132,7 +132,7 @@ remove_watch_directory(WatchDirectory *directory) ...@@ -132,7 +132,7 @@ remove_watch_directory(WatchDirectory *directory)
} }
AllocatedPath AllocatedPath
WatchDirectory::GetUriFS() const WatchDirectory::GetUriFS() const noexcept
{ {
if (parent == nullptr) if (parent == nullptr)
return AllocatedPath::Null(); return AllocatedPath::Null();
...@@ -225,7 +225,7 @@ recursive_watch_subdirectories(WatchDirectory *directory, ...@@ -225,7 +225,7 @@ recursive_watch_subdirectories(WatchDirectory *directory,
gcc_pure gcc_pure
unsigned unsigned
WatchDirectory::GetDepth() const WatchDirectory::GetDepth() const noexcept
{ {
const WatchDirectory *d = this; const WatchDirectory *d = this;
unsigned depth = 0; unsigned depth = 0;
...@@ -331,7 +331,7 @@ mpd_inotify_init(EventLoop &loop, Storage &storage, UpdateService &update, ...@@ -331,7 +331,7 @@ mpd_inotify_init(EventLoop &loop, Storage &storage, UpdateService &update,
} }
void void
mpd_inotify_finish(void) mpd_inotify_finish(void) noexcept
{ {
if (inotify_source == nullptr) if (inotify_source == nullptr)
return; return;
......
...@@ -32,6 +32,6 @@ mpd_inotify_init(EventLoop &loop, Storage &storage, UpdateService &update, ...@@ -32,6 +32,6 @@ mpd_inotify_init(EventLoop &loop, Storage &storage, UpdateService &update,
unsigned max_depth); unsigned max_depth);
void void
mpd_inotify_finish(); mpd_inotify_finish() noexcept;
#endif #endif
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <errno.h> #include <errno.h>
bool bool
GetInfo(Storage &storage, const char *uri_utf8, StorageFileInfo &info) GetInfo(Storage &storage, const char *uri_utf8, StorageFileInfo &info) noexcept
try { try {
info = storage.GetInfo(uri_utf8, true); info = storage.GetInfo(uri_utf8, true);
return true; return true;
...@@ -42,7 +42,7 @@ try { ...@@ -42,7 +42,7 @@ try {
} }
bool bool
GetInfo(StorageDirectoryReader &reader, StorageFileInfo &info) GetInfo(StorageDirectoryReader &reader, StorageFileInfo &info) noexcept
try { try {
info = reader.GetInfo(true); info = reader.GetInfo(true);
return true; return true;
...@@ -52,7 +52,7 @@ try { ...@@ -52,7 +52,7 @@ try {
} }
bool bool
DirectoryExists(Storage &storage, const Directory &directory) DirectoryExists(Storage &storage, const Directory &directory) noexcept
{ {
StorageFileInfo info; StorageFileInfo info;
...@@ -79,7 +79,7 @@ GetDirectoryChildInfo(Storage &storage, const Directory &directory, ...@@ -79,7 +79,7 @@ GetDirectoryChildInfo(Storage &storage, const Directory &directory,
bool bool
directory_child_is_regular(Storage &storage, const Directory &directory, directory_child_is_regular(Storage &storage, const Directory &directory,
const char *name_utf8) const char *name_utf8) noexcept
try { try {
return GetDirectoryChildInfo(storage, directory, name_utf8) return GetDirectoryChildInfo(storage, directory, name_utf8)
.IsRegular(); .IsRegular();
...@@ -89,7 +89,7 @@ try { ...@@ -89,7 +89,7 @@ try {
bool bool
directory_child_access(Storage &storage, const Directory &directory, directory_child_access(Storage &storage, const Directory &directory,
const char *name, int mode) const char *name, int mode) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
/* CheckAccess() is useless on WIN32 */ /* CheckAccess() is useless on WIN32 */
......
...@@ -33,23 +33,23 @@ class StorageDirectoryReader; ...@@ -33,23 +33,23 @@ class StorageDirectoryReader;
* returning them. * returning them.
*/ */
bool bool
GetInfo(Storage &storage, const char *uri_utf8, StorageFileInfo &info); GetInfo(Storage &storage, const char *uri_utf8, StorageFileInfo &info) noexcept;
/** /**
* Wrapper for LocalDirectoryReader::GetInfo() that logs errors * Wrapper for LocalDirectoryReader::GetInfo() that logs errors
* instead of returning them. * instead of returning them.
*/ */
bool bool
GetInfo(StorageDirectoryReader &reader, StorageFileInfo &info); GetInfo(StorageDirectoryReader &reader, StorageFileInfo &info) noexcept;
gcc_pure gcc_pure
bool bool
DirectoryExists(Storage &storage, const Directory &directory); DirectoryExists(Storage &storage, const Directory &directory) noexcept;
gcc_pure gcc_pure
bool bool
directory_child_is_regular(Storage &storage, const Directory &directory, directory_child_is_regular(Storage &storage, const Directory &directory,
const char *name_utf8); const char *name_utf8) noexcept;
/** /**
* Checks if the given permissions on the mapped file are given. * Checks if the given permissions on the mapped file are given.
...@@ -57,6 +57,6 @@ directory_child_is_regular(Storage &storage, const Directory &directory, ...@@ -57,6 +57,6 @@ directory_child_is_regular(Storage &storage, const Directory &directory,
gcc_pure gcc_pure
bool bool
directory_child_access(Storage &storage, const Directory &directory, directory_child_access(Storage &storage, const Directory &directory,
const char *name, int mode); const char *name, int mode) noexcept;
#endif #endif
...@@ -248,7 +248,7 @@ try { ...@@ -248,7 +248,7 @@ try {
/* we don't look at "." / ".." nor files with newlines in their name */ /* we don't look at "." / ".." nor files with newlines in their name */
gcc_pure gcc_pure
static bool static bool
skip_path(const char *name_utf8) skip_path(const char *name_utf8) noexcept
{ {
return strchr(name_utf8, '\n') != nullptr; return strchr(name_utf8, '\n') != nullptr;
} }
...@@ -256,7 +256,7 @@ skip_path(const char *name_utf8) ...@@ -256,7 +256,7 @@ skip_path(const char *name_utf8)
gcc_pure gcc_pure
bool bool
UpdateWalk::SkipSymlink(const Directory *directory, UpdateWalk::SkipSymlink(const Directory *directory,
const char *utf8_name) const const char *utf8_name) const noexcept
{ {
#ifndef WIN32 #ifndef WIN32
const auto path_fs = storage.MapChildFS(directory->GetPath(), const auto path_fs = storage.MapChildFS(directory->GetPath(),
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
private: private:
gcc_pure gcc_pure
bool SkipSymlink(const Directory *directory, bool SkipSymlink(const Directory *directory,
const char *utf8_name) const; const char *utf8_name) const noexcept;
void RemoveExcludedFromDirectory(Directory &directory, void RemoveExcludedFromDirectory(Directory &directory,
const ExcludeList &exclude_list); const ExcludeList &exclude_list);
......
...@@ -54,7 +54,7 @@ DecoderBridge::~DecoderBridge() ...@@ -54,7 +54,7 @@ DecoderBridge::~DecoderBridge()
} }
bool bool
DecoderBridge::CheckCancelRead() const DecoderBridge::CheckCancelRead() const noexcept
{ {
if (error) if (error)
/* this translates to DecoderCommand::STOP */ /* this translates to DecoderCommand::STOP */
...@@ -78,7 +78,7 @@ DecoderBridge::CheckCancelRead() const ...@@ -78,7 +78,7 @@ DecoderBridge::CheckCancelRead() const
* one. * one.
*/ */
static DecoderCommand static DecoderCommand
need_chunks(DecoderControl &dc) need_chunks(DecoderControl &dc) noexcept
{ {
if (dc.command == DecoderCommand::NONE) if (dc.command == DecoderCommand::NONE)
dc.Wait(); dc.Wait();
...@@ -87,14 +87,14 @@ need_chunks(DecoderControl &dc) ...@@ -87,14 +87,14 @@ need_chunks(DecoderControl &dc)
} }
static DecoderCommand static DecoderCommand
LockNeedChunks(DecoderControl &dc) LockNeedChunks(DecoderControl &dc) noexcept
{ {
const std::lock_guard<Mutex> protect(dc.mutex); const std::lock_guard<Mutex> protect(dc.mutex);
return need_chunks(dc); return need_chunks(dc);
} }
MusicChunk * MusicChunk *
DecoderBridge::GetChunk() DecoderBridge::GetChunk() noexcept
{ {
DecoderCommand cmd; DecoderCommand cmd;
...@@ -177,7 +177,7 @@ DecoderBridge::PrepareInitialSeek() ...@@ -177,7 +177,7 @@ DecoderBridge::PrepareInitialSeek()
} }
DecoderCommand DecoderCommand
DecoderBridge::GetVirtualCommand() DecoderBridge::GetVirtualCommand() noexcept
{ {
if (error) if (error)
/* an error has occurred: stop the decoder plugin */ /* an error has occurred: stop the decoder plugin */
...@@ -192,7 +192,7 @@ DecoderBridge::GetVirtualCommand() ...@@ -192,7 +192,7 @@ DecoderBridge::GetVirtualCommand()
} }
DecoderCommand DecoderCommand
DecoderBridge::LockGetVirtualCommand() DecoderBridge::LockGetVirtualCommand() noexcept
{ {
const std::lock_guard<Mutex> protect(dc.mutex); const std::lock_guard<Mutex> protect(dc.mutex);
return GetVirtualCommand(); return GetVirtualCommand();
......
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
* Caller must lock the #DecoderControl object. * Caller must lock the #DecoderControl object.
*/ */
gcc_pure gcc_pure
bool CheckCancelRead() const; bool CheckCancelRead() const noexcept;
/** /**
* Returns the current chunk the decoder writes to, or allocates a new * Returns the current chunk the decoder writes to, or allocates a new
...@@ -122,7 +122,7 @@ public: ...@@ -122,7 +122,7 @@ public:
* *
* @return the chunk, or NULL if we have received a decoder command * @return the chunk, or NULL if we have received a decoder command
*/ */
MusicChunk *GetChunk(); MusicChunk *GetChunk() noexcept;
/** /**
* Flushes the current chunk. * Flushes the current chunk.
...@@ -161,8 +161,8 @@ private: ...@@ -161,8 +161,8 @@ private:
* "virtual" synthesized command, e.g. to seek to the * "virtual" synthesized command, e.g. to seek to the
* beginning of the CUE track. * beginning of the CUE track.
*/ */
DecoderCommand GetVirtualCommand(); DecoderCommand GetVirtualCommand() noexcept;
DecoderCommand LockGetVirtualCommand(); DecoderCommand LockGetVirtualCommand() noexcept;
/** /**
* Sends a #Tag as-is to the #MusicPipe. Flushes the current * Sends a #Tag as-is to the #MusicPipe. Flushes the current
......
...@@ -74,7 +74,7 @@ DecoderControl::SetReady(const AudioFormat audio_format, ...@@ -74,7 +74,7 @@ DecoderControl::SetReady(const AudioFormat audio_format,
} }
bool bool
DecoderControl::IsCurrentSong(const DetachedSong &_song) const DecoderControl::IsCurrentSong(const DetachedSong &_song) const noexcept
{ {
switch (state) { switch (state) {
case DecoderState::STOP: case DecoderState::STOP:
......
...@@ -305,10 +305,10 @@ struct DecoderControl { ...@@ -305,10 +305,10 @@ struct DecoderControl {
* Caller must lock the object. * Caller must lock the object.
*/ */
gcc_pure gcc_pure
bool IsCurrentSong(const DetachedSong &_song) const; bool IsCurrentSong(const DetachedSong &_song) const noexcept;
gcc_pure gcc_pure
bool LockIsCurrentSong(const DetachedSong &_song) const { bool LockIsCurrentSong(const DetachedSong &_song) const noexcept {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
return IsCurrentSong(_song); return IsCurrentSong(_song);
} }
......
...@@ -118,7 +118,7 @@ static constexpr unsigned num_decoder_plugins = ...@@ -118,7 +118,7 @@ static constexpr unsigned num_decoder_plugins =
bool decoder_plugins_enabled[num_decoder_plugins]; bool decoder_plugins_enabled[num_decoder_plugins];
const struct DecoderPlugin * const struct DecoderPlugin *
decoder_plugin_from_name(const char *name) decoder_plugin_from_name(const char *name) noexcept
{ {
return decoder_plugins_find([=](const DecoderPlugin &plugin){ return decoder_plugins_find([=](const DecoderPlugin &plugin){
return strcmp(plugin.name, name) == 0; return strcmp(plugin.name, name) == 0;
...@@ -154,7 +154,7 @@ void decoder_plugin_deinit_all(void) ...@@ -154,7 +154,7 @@ void decoder_plugin_deinit_all(void)
} }
bool bool
decoder_plugins_supports_suffix(const char *suffix) decoder_plugins_supports_suffix(const char *suffix) noexcept
{ {
return decoder_plugins_try([suffix](const DecoderPlugin &plugin){ return decoder_plugins_try([suffix](const DecoderPlugin &plugin){
return plugin.SupportsSuffix(suffix); return plugin.SupportsSuffix(suffix);
......
...@@ -31,7 +31,7 @@ extern bool decoder_plugins_enabled[]; ...@@ -31,7 +31,7 @@ extern bool decoder_plugins_enabled[];
gcc_pure gcc_pure
const struct DecoderPlugin * const struct DecoderPlugin *
decoder_plugin_from_name(const char *name); decoder_plugin_from_name(const char *name) noexcept;
/* this is where we "load" all the "plugins" ;-) */ /* this is where we "load" all the "plugins" ;-) */
void void
...@@ -86,6 +86,6 @@ decoder_plugins_for_each_enabled(F f) ...@@ -86,6 +86,6 @@ decoder_plugins_for_each_enabled(F f)
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
bool bool
decoder_plugins_supports_suffix(const char *suffix); decoder_plugins_supports_suffix(const char *suffix) noexcept;
#endif #endif
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <assert.h> #include <assert.h>
bool bool
DecoderPlugin::SupportsSuffix(const char *suffix) const DecoderPlugin::SupportsSuffix(const char *suffix) const noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
...@@ -36,7 +36,7 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const ...@@ -36,7 +36,7 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const
} }
bool bool
DecoderPlugin::SupportsMimeType(const char *mime_type) const DecoderPlugin::SupportsMimeType(const char *mime_type) const noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
......
...@@ -168,13 +168,13 @@ struct DecoderPlugin { ...@@ -168,13 +168,13 @@ struct DecoderPlugin {
* Does the plugin announce the specified file name suffix? * Does the plugin announce the specified file name suffix?
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
bool SupportsSuffix(const char *suffix) const; bool SupportsSuffix(const char *suffix) const noexcept;
/** /**
* Does the plugin announce the specified MIME type? * Does the plugin announce the specified MIME type?
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
bool SupportsMimeType(const char *mime_type) const; bool SupportsMimeType(const char *mime_type) const noexcept;
}; };
#endif #endif
...@@ -170,7 +170,8 @@ decoder_file_decode(const DecoderPlugin &plugin, ...@@ -170,7 +170,8 @@ decoder_file_decode(const DecoderPlugin &plugin,
gcc_pure gcc_pure
static bool static bool
decoder_check_plugin_mime(const DecoderPlugin &plugin, const InputStream &is) decoder_check_plugin_mime(const DecoderPlugin &plugin,
const InputStream &is) noexcept
{ {
assert(plugin.stream_decode != nullptr); assert(plugin.stream_decode != nullptr);
...@@ -181,7 +182,8 @@ decoder_check_plugin_mime(const DecoderPlugin &plugin, const InputStream &is) ...@@ -181,7 +182,8 @@ decoder_check_plugin_mime(const DecoderPlugin &plugin, const InputStream &is)
gcc_pure gcc_pure
static bool static bool
decoder_check_plugin_suffix(const DecoderPlugin &plugin, const char *suffix) decoder_check_plugin_suffix(const DecoderPlugin &plugin,
const char *suffix) noexcept
{ {
assert(plugin.stream_decode != nullptr); assert(plugin.stream_decode != nullptr);
...@@ -191,7 +193,7 @@ decoder_check_plugin_suffix(const DecoderPlugin &plugin, const char *suffix) ...@@ -191,7 +193,7 @@ decoder_check_plugin_suffix(const DecoderPlugin &plugin, const char *suffix)
gcc_pure gcc_pure
static bool static bool
decoder_check_plugin(const DecoderPlugin &plugin, const InputStream &is, decoder_check_plugin(const DecoderPlugin &plugin, const InputStream &is,
const char *suffix) const char *suffix) noexcept
{ {
return plugin.stream_decode != nullptr && return plugin.stream_decode != nullptr &&
(decoder_check_plugin_mime(plugin, is) || (decoder_check_plugin_mime(plugin, is) ||
......
...@@ -66,7 +66,7 @@ struct AudioFileInputStream { ...@@ -66,7 +66,7 @@ struct AudioFileInputStream {
gcc_pure gcc_pure
static SongTime static SongTime
audiofile_get_duration(AFfilehandle fh) audiofile_get_duration(AFfilehandle fh) noexcept
{ {
return SongTime::FromScale<uint64_t>(afGetFrameCount(fh, AF_DEFAULT_TRACK), return SongTime::FromScale<uint64_t>(afGetFrameCount(fh, AF_DEFAULT_TRACK),
afGetRate(fh, AF_DEFAULT_TRACK)); afGetRate(fh, AF_DEFAULT_TRACK));
...@@ -239,7 +239,7 @@ audiofile_stream_decode(DecoderClient &client, InputStream &is) ...@@ -239,7 +239,7 @@ audiofile_stream_decode(DecoderClient &client, InputStream &is)
gcc_pure gcc_pure
static SignedSongTime static SignedSongTime
audiofile_get_duration(InputStream &is) audiofile_get_duration(InputStream &is) noexcept
{ {
if (!is.IsSeekable() || !is.KnownSize()) if (!is.IsSeekable() || !is.KnownSize())
return SignedSongTime::Negative(); return SignedSongTime::Negative();
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <stdlib.h> #include <stdlib.h>
bool bool
DsdId::Equals(const char *s) const DsdId::Equals(const char *s) const noexcept
{ {
assert(s != nullptr); assert(s != nullptr);
assert(strlen(s) == sizeof(value)); assert(strlen(s) == sizeof(value));
...@@ -95,7 +95,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is, ...@@ -95,7 +95,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is,
} }
bool bool
dsdlib_valid_freq(uint32_t samplefreq) dsdlib_valid_freq(uint32_t samplefreq) noexcept
{ {
switch (samplefreq) { switch (samplefreq) {
case 2822400: /* DSD64, 64xFs, Fs = 44.100kHz */ case 2822400: /* DSD64, 64xFs, Fs = 44.100kHz */
......
...@@ -34,7 +34,7 @@ struct DsdId { ...@@ -34,7 +34,7 @@ struct DsdId {
char value[4]; char value[4];
gcc_pure gcc_pure
bool Equals(const char *s) const; bool Equals(const char *s) const noexcept;
}; };
class DsdUint64 { class DsdUint64 {
...@@ -72,7 +72,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is, ...@@ -72,7 +72,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is,
**/ **/
gcc_const gcc_const
bool bool
dsdlib_valid_freq(uint32_t samplefreq); dsdlib_valid_freq(uint32_t samplefreq) noexcept;
/** /**
* Add tags from ID3 tag. All tags commonly found in the ID3 tags of * Add tags from ID3 tag. All tags commonly found in the ID3 tags of
......
...@@ -112,14 +112,14 @@ ffmpeg_finish() ...@@ -112,14 +112,14 @@ ffmpeg_finish()
gcc_pure gcc_pure
static const AVCodecParameters & static const AVCodecParameters &
GetCodecParameters(const AVStream &stream) GetCodecParameters(const AVStream &stream) noexcept
{ {
return *stream.codecpar; return *stream.codecpar;
} }
gcc_pure gcc_pure
static AVSampleFormat static AVSampleFormat
GetSampleFormat(const AVCodecParameters &codec_params) GetSampleFormat(const AVCodecParameters &codec_params) noexcept
{ {
return AVSampleFormat(codec_params.format); return AVSampleFormat(codec_params.format);
} }
...@@ -128,14 +128,14 @@ GetSampleFormat(const AVCodecParameters &codec_params) ...@@ -128,14 +128,14 @@ GetSampleFormat(const AVCodecParameters &codec_params)
gcc_pure gcc_pure
static const AVCodecContext & static const AVCodecContext &
GetCodecParameters(const AVStream &stream) GetCodecParameters(const AVStream &stream) noexcept
{ {
return *stream.codec; return *stream.codec;
} }
gcc_pure gcc_pure
static AVSampleFormat static AVSampleFormat
GetSampleFormat(const AVCodecContext &codec_context) GetSampleFormat(const AVCodecContext &codec_context) noexcept
{ {
return codec_context.sample_fmt; return codec_context.sample_fmt;
} }
...@@ -144,14 +144,14 @@ GetSampleFormat(const AVCodecContext &codec_context) ...@@ -144,14 +144,14 @@ GetSampleFormat(const AVCodecContext &codec_context)
gcc_pure gcc_pure
static bool static bool
IsAudio(const AVStream &stream) IsAudio(const AVStream &stream) noexcept
{ {
return GetCodecParameters(stream).codec_type == AVMEDIA_TYPE_AUDIO; return GetCodecParameters(stream).codec_type == AVMEDIA_TYPE_AUDIO;
} }
gcc_pure gcc_pure
static int static int
ffmpeg_find_audio_stream(const AVFormatContext &format_context) ffmpeg_find_audio_stream(const AVFormatContext &format_context) noexcept
{ {
for (unsigned i = 0; i < format_context.nb_streams; ++i) for (unsigned i = 0; i < format_context.nb_streams; ++i)
if (IsAudio(*format_context.streams[i])) if (IsAudio(*format_context.streams[i]))
...@@ -220,7 +220,7 @@ copy_interleave_frame(const AVCodecContext &codec_context, ...@@ -220,7 +220,7 @@ copy_interleave_frame(const AVCodecContext &codec_context,
*/ */
gcc_pure gcc_pure
static int64_t static int64_t
StreamRelativePts(const AVPacket &packet, const AVStream &stream) StreamRelativePts(const AVPacket &packet, const AVStream &stream) noexcept
{ {
auto pts = packet.pts; auto pts = packet.pts;
if (pts < 0 || pts == int64_t(AV_NOPTS_VALUE)) if (pts < 0 || pts == int64_t(AV_NOPTS_VALUE))
...@@ -237,7 +237,7 @@ StreamRelativePts(const AVPacket &packet, const AVStream &stream) ...@@ -237,7 +237,7 @@ StreamRelativePts(const AVPacket &packet, const AVStream &stream)
gcc_pure gcc_pure
static uint64_t static uint64_t
PtsToPcmFrame(uint64_t pts, const AVStream &stream, PtsToPcmFrame(uint64_t pts, const AVStream &stream,
const AVCodecContext &codec_context) const AVCodecContext &codec_context) noexcept
{ {
return av_rescale_q(pts, stream.time_base, codec_context.time_base); return av_rescale_q(pts, stream.time_base, codec_context.time_base);
} }
...@@ -437,7 +437,7 @@ ffmpeg_send_packet(DecoderClient &client, InputStream &is, ...@@ -437,7 +437,7 @@ ffmpeg_send_packet(DecoderClient &client, InputStream &is,
gcc_const gcc_const
static SampleFormat static SampleFormat
ffmpeg_sample_format(enum AVSampleFormat sample_fmt) ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept
{ {
switch (sample_fmt) { switch (sample_fmt) {
case AV_SAMPLE_FMT_S16: case AV_SAMPLE_FMT_S16:
......
...@@ -67,7 +67,7 @@ flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc) ...@@ -67,7 +67,7 @@ flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
*/ */
static const char * static const char *
flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry, flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
const char *name) const char *name) noexcept
{ {
return vorbis_comment_value((const char *)entry->entry, name); return vorbis_comment_value((const char *)entry->entry, name);
} }
...@@ -126,7 +126,7 @@ flac_scan_comments(const FLAC__StreamMetadata_VorbisComment *comment, ...@@ -126,7 +126,7 @@ flac_scan_comments(const FLAC__StreamMetadata_VorbisComment *comment,
gcc_pure gcc_pure
static inline SongTime static inline SongTime
flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info) flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info) noexcept
{ {
assert(stream_info->sample_rate > 0); assert(stream_info->sample_rate > 0);
......
...@@ -74,7 +74,7 @@ gme_plugin_init(gcc_unused const ConfigBlock &block) ...@@ -74,7 +74,7 @@ gme_plugin_init(gcc_unused const ConfigBlock &block)
gcc_pure gcc_pure
static unsigned static unsigned
ParseSubtuneName(const char *base) ParseSubtuneName(const char *base) noexcept
{ {
if (memcmp(base, SUBTUNE_PREFIX, sizeof(SUBTUNE_PREFIX) - 1) != 0) if (memcmp(base, SUBTUNE_PREFIX, sizeof(SUBTUNE_PREFIX) - 1) != 0)
return 0; return 0;
......
...@@ -71,7 +71,7 @@ static bool gapless_playback; ...@@ -71,7 +71,7 @@ static bool gapless_playback;
gcc_const gcc_const
static SongTime static SongTime
ToSongTime(mad_timer_t t) ToSongTime(mad_timer_t t) noexcept
{ {
return SongTime::FromMS(mad_timer_count(t, MAD_UNITS_MILLISECONDS)); return SongTime::FromMS(mad_timer_count(t, MAD_UNITS_MILLISECONDS));
} }
...@@ -155,10 +155,10 @@ struct MadDecoder { ...@@ -155,10 +155,10 @@ struct MadDecoder {
enum mp3_action DecodeNextFrame(); enum mp3_action DecodeNextFrame();
gcc_pure gcc_pure
offset_type ThisFrameOffset() const; offset_type ThisFrameOffset() const noexcept;
gcc_pure gcc_pure
offset_type RestIncludingThisFrame() const; offset_type RestIncludingThisFrame() const noexcept;
/** /**
* Attempt to calulcate the length of the song from filesize * Attempt to calulcate the length of the song from filesize
...@@ -177,7 +177,7 @@ struct MadDecoder { ...@@ -177,7 +177,7 @@ struct MadDecoder {
} }
gcc_pure gcc_pure
long TimeToFrame(SongTime t) const; long TimeToFrame(SongTime t) const noexcept;
void UpdateTimerNextFrame(); void UpdateTimerNextFrame();
...@@ -291,7 +291,7 @@ parse_id3_replay_gain_info(ReplayGainInfo &rgi, ...@@ -291,7 +291,7 @@ parse_id3_replay_gain_info(ReplayGainInfo &rgi,
#ifdef ENABLE_ID3TAG #ifdef ENABLE_ID3TAG
gcc_pure gcc_pure
static MixRampInfo static MixRampInfo
parse_id3_mixramp(struct id3_tag *tag) parse_id3_mixramp(struct id3_tag *tag) noexcept
{ {
MixRampInfo result; MixRampInfo result;
...@@ -710,7 +710,7 @@ mp3_frame_duration(const struct mad_frame *frame) ...@@ -710,7 +710,7 @@ mp3_frame_duration(const struct mad_frame *frame)
} }
inline offset_type inline offset_type
MadDecoder::ThisFrameOffset() const MadDecoder::ThisFrameOffset() const noexcept
{ {
auto offset = input_stream.GetOffset(); auto offset = input_stream.GetOffset();
...@@ -723,7 +723,7 @@ MadDecoder::ThisFrameOffset() const ...@@ -723,7 +723,7 @@ MadDecoder::ThisFrameOffset() const
} }
inline offset_type inline offset_type
MadDecoder::RestIncludingThisFrame() const MadDecoder::RestIncludingThisFrame() const noexcept
{ {
return input_stream.GetSize() - ThisFrameOffset(); return input_stream.GetSize() - ThisFrameOffset();
} }
...@@ -846,7 +846,7 @@ mad_decoder_total_file_time(InputStream &is) ...@@ -846,7 +846,7 @@ mad_decoder_total_file_time(InputStream &is)
} }
long long
MadDecoder::TimeToFrame(SongTime t) const MadDecoder::TimeToFrame(SongTime t) const noexcept
{ {
unsigned long i; unsigned long i;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
gcc_pure gcc_pure
static TagType static TagType
ParseOpusTagName(const char *name) ParseOpusTagName(const char *name) noexcept
{ {
TagType type = tag_name_parse_i(name); TagType type = tag_name_parse_i(name);
if (type != TAG_NUM_OF_ITEM_TYPES) if (type != TAG_NUM_OF_ITEM_TYPES)
......
...@@ -116,7 +116,7 @@ struct SidplayContainerPath { ...@@ -116,7 +116,7 @@ struct SidplayContainerPath {
gcc_pure gcc_pure
static unsigned static unsigned
ParseSubtuneName(const char *base) ParseSubtuneName(const char *base) noexcept
{ {
if (memcmp(base, SUBTUNE_PREFIX, sizeof(SUBTUNE_PREFIX) - 1) != 0) if (memcmp(base, SUBTUNE_PREFIX, sizeof(SUBTUNE_PREFIX) - 1) != 0)
return 0; return 0;
...@@ -390,7 +390,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs) ...@@ -390,7 +390,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
gcc_pure gcc_pure
static const char * static const char *
GetInfoString(const SidTuneInfo &info, unsigned i) GetInfoString(const SidTuneInfo &info, unsigned i) noexcept
{ {
#ifdef HAVE_SIDPLAYFP #ifdef HAVE_SIDPLAYFP
return info.numberOfInfoStrings() > i return info.numberOfInfoStrings() > i
......
...@@ -148,7 +148,7 @@ sndfile_duration(const SF_INFO &info) ...@@ -148,7 +148,7 @@ sndfile_duration(const SF_INFO &info)
gcc_pure gcc_pure
static SampleFormat static SampleFormat
sndfile_sample_format(const SF_INFO &info) sndfile_sample_format(const SF_INFO &info) noexcept
{ {
switch (info.format & SF_FORMAT_SUBMASK) { switch (info.format & SF_FORMAT_SUBMASK) {
case SF_FORMAT_PCM_S8: case SF_FORMAT_PCM_S8:
......
...@@ -101,7 +101,7 @@ WavpackOpenInput(WavpackStreamReader *reader, void *wv_id, void *wvc_id, ...@@ -101,7 +101,7 @@ WavpackOpenInput(WavpackStreamReader *reader, void *wv_id, void *wvc_id,
gcc_pure gcc_pure
static SignedSongTime static SignedSongTime
GetDuration(WavpackContext *wpc) GetDuration(WavpackContext *wpc) noexcept
{ {
#ifdef OPEN_DSD_AS_PCM #ifdef OPEN_DSD_AS_PCM
/* libWavPack 5 */ /* libWavPack 5 */
......
...@@ -103,16 +103,16 @@ public: ...@@ -103,16 +103,16 @@ public:
using SocketMonitor::Close; using SocketMonitor::Close;
gcc_pure gcc_pure
std::string ToString() const { std::string ToString() const noexcept {
return ::ToString(address); return ::ToString(address);
} }
void SetFD(int _fd) { void SetFD(int _fd) noexcept {
SocketMonitor::Open(_fd); SocketMonitor::Open(_fd);
SocketMonitor::ScheduleRead(); SocketMonitor::ScheduleRead();
} }
void Accept(); void Accept() noexcept;
private: private:
virtual bool OnSocketReady(unsigned flags) override; virtual bool OnSocketReady(unsigned flags) override;
...@@ -146,7 +146,7 @@ get_remote_uid(int fd) ...@@ -146,7 +146,7 @@ get_remote_uid(int fd)
} }
inline void inline void
OneServerSocket::Accept() OneServerSocket::Accept() noexcept
{ {
StaticSocketAddress peer_address; StaticSocketAddress peer_address;
size_t peer_address_length = sizeof(peer_address); size_t peer_address_length = sizeof(peer_address);
...@@ -343,7 +343,7 @@ ServerSocket::AddPortIPv6(unsigned port) ...@@ -343,7 +343,7 @@ ServerSocket::AddPortIPv6(unsigned port)
*/ */
gcc_pure gcc_pure
static bool static bool
SupportsIPv6() SupportsIPv6() noexcept
{ {
int fd = socket(AF_INET6, SOCK_STREAM, 0); int fd = socket(AF_INET6, SOCK_STREAM, 0);
if (fd < 0) if (fd < 0)
......
...@@ -32,7 +32,7 @@ static const FilterPlugin *const filter_plugins[] = { ...@@ -32,7 +32,7 @@ static const FilterPlugin *const filter_plugins[] = {
}; };
const FilterPlugin * const FilterPlugin *
filter_plugin_by_name(const char *name) filter_plugin_by_name(const char *name) noexcept
{ {
for (unsigned i = 0; filter_plugins[i] != nullptr; ++i) for (unsigned i = 0; filter_plugins[i] != nullptr; ++i)
if (strcmp(filter_plugins[i]->name, name) == 0) if (strcmp(filter_plugins[i]->name, name) == 0)
......
...@@ -39,6 +39,6 @@ extern const FilterPlugin volume_filter_plugin; ...@@ -39,6 +39,6 @@ extern const FilterPlugin volume_filter_plugin;
gcc_pure gcc_pure
const FilterPlugin * const FilterPlugin *
filter_plugin_by_name(const char *name); filter_plugin_by_name(const char *name) noexcept;
#endif #endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
AllocatedPath::~AllocatedPath() {} AllocatedPath::~AllocatedPath() {}
AllocatedPath AllocatedPath
AllocatedPath::FromUTF8(const char *path_utf8) AllocatedPath::FromUTF8(const char *path_utf8) noexcept
{ {
#if defined(HAVE_FS_CHARSET) || defined(WIN32) #if defined(HAVE_FS_CHARSET) || defined(WIN32)
try { try {
...@@ -53,13 +53,13 @@ AllocatedPath::FromUTF8Throw(const char *path_utf8) ...@@ -53,13 +53,13 @@ AllocatedPath::FromUTF8Throw(const char *path_utf8)
} }
AllocatedPath AllocatedPath
AllocatedPath::GetDirectoryName() const AllocatedPath::GetDirectoryName() const noexcept
{ {
return FromFS(PathTraitsFS::GetParent(c_str())); return FromFS(PathTraitsFS::GetParent(c_str()));
} }
std::string std::string
AllocatedPath::ToUTF8() const AllocatedPath::ToUTF8() const noexcept
{ {
try { try {
return ::PathToUTF8(c_str()); return ::PathToUTF8(c_str());
...@@ -69,7 +69,7 @@ AllocatedPath::ToUTF8() const ...@@ -69,7 +69,7 @@ AllocatedPath::ToUTF8() const
} }
void void
AllocatedPath::ChopSeparators() AllocatedPath::ChopSeparators() noexcept
{ {
size_t l = length(); size_t l = length();
const auto *p = data(); const auto *p = data();
......
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
* Returns return a "nulled" instance on error. * Returns return a "nulled" instance on error.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static AllocatedPath FromUTF8(const char *path_utf8); static AllocatedPath FromUTF8(const char *path_utf8) noexcept;
/** /**
* Convert a UTF-8 C string to an #AllocatedPath instance. * Convert a UTF-8 C string to an #AllocatedPath instance.
...@@ -244,14 +244,14 @@ public: ...@@ -244,14 +244,14 @@ public:
* (#IsNull returns true). * (#IsNull returns true).
*/ */
gcc_pure gcc_pure
std::string ToUTF8() const; std::string ToUTF8() const noexcept;
/** /**
* Gets directory name of this path. * Gets directory name of this path.
* Returns a "nulled" instance on error. * Returns a "nulled" instance on error.
*/ */
gcc_pure gcc_pure
AllocatedPath GetDirectoryName() const; AllocatedPath GetDirectoryName() const noexcept;
/** /**
* Determine the relative part of the given path to this * Determine the relative part of the given path to this
...@@ -260,17 +260,17 @@ public: ...@@ -260,17 +260,17 @@ public:
* nullptr on mismatch. * nullptr on mismatch.
*/ */
gcc_pure gcc_pure
const_pointer_type Relative(Path other_fs) const { const_pointer_type Relative(Path other_fs) const noexcept {
return PathTraitsFS::Relative(c_str(), other_fs.c_str()); return PathTraitsFS::Relative(c_str(), other_fs.c_str());
} }
/** /**
* Chop trailing directory separators. * Chop trailing directory separators.
*/ */
void ChopSeparators(); void ChopSeparators() noexcept;
gcc_pure gcc_pure
bool IsAbsolute() const { bool IsAbsolute() const noexcept {
return PathTraitsFS::IsAbsolute(c_str()); return PathTraitsFS::IsAbsolute(c_str());
} }
}; };
......
...@@ -57,7 +57,7 @@ SetFSCharset(const char *charset) ...@@ -57,7 +57,7 @@ SetFSCharset(const char *charset)
#endif #endif
void void
DeinitFSCharset() DeinitFSCharset() noexcept
{ {
#ifdef HAVE_ICU_CONVERTER #ifdef HAVE_ICU_CONVERTER
delete fs_converter; delete fs_converter;
...@@ -66,7 +66,7 @@ DeinitFSCharset() ...@@ -66,7 +66,7 @@ DeinitFSCharset()
} }
const char * const char *
GetFSCharset() GetFSCharset() noexcept
{ {
#ifdef HAVE_FS_CHARSET #ifdef HAVE_FS_CHARSET
return fs_charset.empty() ? "UTF-8" : fs_charset.c_str(); return fs_charset.empty() ? "UTF-8" : fs_charset.c_str();
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
*/ */
gcc_const gcc_const
const char * const char *
GetFSCharset(); GetFSCharset() noexcept;
/** /**
* Throws std::runtime_error on error. * Throws std::runtime_error on error.
...@@ -42,7 +42,7 @@ void ...@@ -42,7 +42,7 @@ void
SetFSCharset(const char *charset); SetFSCharset(const char *charset);
void void
DeinitFSCharset(); DeinitFSCharset() noexcept;
/** /**
* Convert the path to UTF-8. * Convert the path to UTF-8.
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <stdexcept> #include <stdexcept>
std::string std::string
Path::ToUTF8() const Path::ToUTF8() const noexcept
{ {
try { try {
return ::PathToUTF8(c_str()); return ::PathToUTF8(c_str());
...@@ -34,7 +34,7 @@ Path::ToUTF8() const ...@@ -34,7 +34,7 @@ Path::ToUTF8() const
} }
Path::const_pointer_type Path::const_pointer_type
Path::GetSuffix() const Path::GetSuffix() const noexcept
{ {
const auto base = GetBase().c_str(); const auto base = GetBase().c_str();
const auto *dot = StringFindLast(base, '.'); const auto *dot = StringFindLast(base, '.');
......
...@@ -123,7 +123,7 @@ public: ...@@ -123,7 +123,7 @@ public:
* transfer newline characters). * transfer newline characters).
*/ */
gcc_pure gcc_pure
bool HasNewline() const { bool HasNewline() const noexcept {
return PathTraitsFS::Find(c_str(), '\n') != nullptr; return PathTraitsFS::Find(c_str(), '\n') != nullptr;
} }
...@@ -133,14 +133,14 @@ public: ...@@ -133,14 +133,14 @@ public:
* (#IsNull returns true). * (#IsNull returns true).
*/ */
gcc_pure gcc_pure
std::string ToUTF8() const; std::string ToUTF8() const noexcept;
/** /**
* Determine the "base" file name. * Determine the "base" file name.
* The return value points inside this object. * The return value points inside this object.
*/ */
gcc_pure gcc_pure
Path GetBase() const { Path GetBase() const noexcept {
return FromFS(PathTraitsFS::GetBase(c_str())); return FromFS(PathTraitsFS::GetBase(c_str()));
} }
...@@ -149,7 +149,7 @@ public: ...@@ -149,7 +149,7 @@ public:
* Returns a "nulled" instance on error. * Returns a "nulled" instance on error.
*/ */
gcc_pure gcc_pure
AllocatedPath GetDirectoryName() const; AllocatedPath GetDirectoryName() const noexcept;
/** /**
* Determine the relative part of the given path to this * Determine the relative part of the given path to this
...@@ -158,17 +158,17 @@ public: ...@@ -158,17 +158,17 @@ public:
* nullptr on mismatch. * nullptr on mismatch.
*/ */
gcc_pure gcc_pure
const_pointer_type Relative(Path other_fs) const { const_pointer_type Relative(Path other_fs) const noexcept {
return PathTraitsFS::Relative(c_str(), other_fs.c_str()); return PathTraitsFS::Relative(c_str(), other_fs.c_str());
} }
gcc_pure gcc_pure
bool IsAbsolute() const { bool IsAbsolute() const noexcept {
return PathTraitsFS::IsAbsolute(c_str()); return PathTraitsFS::IsAbsolute(c_str());
} }
gcc_pure gcc_pure
const_pointer_type GetSuffix() const; const_pointer_type GetSuffix() const noexcept;
}; };
#endif #endif
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "AllocatedPath.hxx" #include "AllocatedPath.hxx"
AllocatedPath AllocatedPath
Path::GetDirectoryName() const Path::GetDirectoryName() const noexcept
{ {
return AllocatedPath::FromFS(PathTraitsFS::GetParent(c_str())); return AllocatedPath::FromFS(PathTraitsFS::GetParent(c_str()));
} }
...@@ -202,7 +202,8 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir) ...@@ -202,7 +202,8 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
return true; return true;
} }
static AllocatedPath GetUserDir(const char *name) static AllocatedPath
GetUserDir(const char *name) noexcept
try { try {
auto result = AllocatedPath::Null(); auto result = AllocatedPath::Null();
auto config_dir = GetUserConfigDir(); auto config_dir = GetUserConfigDir();
...@@ -222,7 +223,8 @@ try { ...@@ -222,7 +223,8 @@ try {
#endif #endif
AllocatedPath GetUserConfigDir() AllocatedPath
GetUserConfigDir() noexcept
{ {
#if defined(WIN32) #if defined(WIN32)
return GetStandardDir(CSIDL_LOCAL_APPDATA); return GetStandardDir(CSIDL_LOCAL_APPDATA);
...@@ -246,7 +248,8 @@ AllocatedPath GetUserConfigDir() ...@@ -246,7 +248,8 @@ AllocatedPath GetUserConfigDir()
#endif #endif
} }
AllocatedPath GetUserMusicDir() AllocatedPath
GetUserMusicDir() noexcept
{ {
#if defined(WIN32) #if defined(WIN32)
return GetStandardDir(CSIDL_MYMUSIC); return GetStandardDir(CSIDL_MYMUSIC);
...@@ -259,7 +262,8 @@ AllocatedPath GetUserMusicDir() ...@@ -259,7 +262,8 @@ AllocatedPath GetUserMusicDir()
#endif #endif
} }
AllocatedPath GetUserCacheDir() AllocatedPath
GetUserCacheDir() noexcept
{ {
#ifdef USE_XDG #ifdef USE_XDG
// Check for $XDG_CACHE_HOME // Check for $XDG_CACHE_HOME
...@@ -285,12 +289,14 @@ AllocatedPath GetUserCacheDir() ...@@ -285,12 +289,14 @@ AllocatedPath GetUserCacheDir()
#ifdef WIN32 #ifdef WIN32
AllocatedPath GetSystemConfigDir() AllocatedPath
GetSystemConfigDir() noexcept
{ {
return GetStandardDir(CSIDL_COMMON_APPDATA); return GetStandardDir(CSIDL_COMMON_APPDATA);
} }
AllocatedPath GetAppBaseDir() AllocatedPath
GetAppBaseDir() noexcept
{ {
std::array<PathTraitsFS::value_type, MAX_PATH> app; std::array<PathTraitsFS::value_type, MAX_PATH> app;
auto ret = GetModuleFileName(nullptr, app.data(), app.size()); auto ret = GetModuleFileName(nullptr, app.data(), app.size());
...@@ -309,7 +315,8 @@ AllocatedPath GetAppBaseDir() ...@@ -309,7 +315,8 @@ AllocatedPath GetAppBaseDir()
#else #else
AllocatedPath GetHomeDir() AllocatedPath
GetHomeDir() noexcept
{ {
#ifndef ANDROID #ifndef ANDROID
auto home = getenv("HOME"); auto home = getenv("HOME");
...@@ -322,7 +329,8 @@ AllocatedPath GetHomeDir() ...@@ -322,7 +329,8 @@ AllocatedPath GetHomeDir()
return AllocatedPath::Null(); return AllocatedPath::Null();
} }
AllocatedPath GetHomeDir(const char *user_name) AllocatedPath
GetHomeDir(const char *user_name) noexcept
{ {
#ifdef ANDROID #ifdef ANDROID
(void)user_name; (void)user_name;
......
...@@ -26,45 +26,51 @@ ...@@ -26,45 +26,51 @@
/** /**
* Obtains configuration directory for the current user. * Obtains configuration directory for the current user.
*/ */
AllocatedPath GetUserConfigDir(); AllocatedPath
GetUserConfigDir() noexcept;
/** /**
* Obtains music directory for the current user. * Obtains music directory for the current user.
*/ */
AllocatedPath GetUserMusicDir(); AllocatedPath
GetUserMusicDir() noexcept;
/** /**
* Obtains cache directory for the current user. * Obtains cache directory for the current user.
*/ */
gcc_pure gcc_pure
AllocatedPath AllocatedPath
GetUserCacheDir(); GetUserCacheDir() noexcept;
#ifdef WIN32 #ifdef WIN32
/** /**
* Obtains system configuration directory. * Obtains system configuration directory.
*/ */
AllocatedPath GetSystemConfigDir(); AllocatedPath
GetSystemConfigDir() noexcept;
/** /**
* Obtains application application base directory. * Obtains application application base directory.
* Application base directory is a directory that contains 'bin' folder * Application base directory is a directory that contains 'bin' folder
* for current executable. * for current executable.
*/ */
AllocatedPath GetAppBaseDir(); AllocatedPath
GetAppBaseDir() noexcept;
#else #else
/** /**
* Obtains home directory for the current user. * Obtains home directory for the current user.
*/ */
AllocatedPath GetHomeDir(); AllocatedPath
GetHomeDir() noexcept;
/** /**
* Obtains home directory for the specified user. * Obtains home directory for the specified user.
*/ */
AllocatedPath GetHomeDir(const char *user_name); AllocatedPath
GetHomeDir(const char *user_name) noexcept;
#endif #endif
......
...@@ -114,50 +114,51 @@ RelativePathImpl(typename Traits::const_pointer_type base, ...@@ -114,50 +114,51 @@ RelativePathImpl(typename Traits::const_pointer_type base,
PathTraitsFS::string PathTraitsFS::string
PathTraitsFS::Build(const_pointer_type a, size_t a_size, PathTraitsFS::Build(const_pointer_type a, size_t a_size,
const_pointer_type b, size_t b_size) const_pointer_type b, size_t b_size) noexcept
{ {
return BuildPathImpl<PathTraitsFS>(a, a_size, b, b_size); return BuildPathImpl<PathTraitsFS>(a, a_size, b, b_size);
} }
PathTraitsFS::const_pointer_type PathTraitsFS::const_pointer_type
PathTraitsFS::GetBase(PathTraitsFS::const_pointer_type p) PathTraitsFS::GetBase(PathTraitsFS::const_pointer_type p) noexcept
{ {
return GetBasePathImpl<PathTraitsFS>(p); return GetBasePathImpl<PathTraitsFS>(p);
} }
PathTraitsFS::string PathTraitsFS::string
PathTraitsFS::GetParent(PathTraitsFS::const_pointer_type p) PathTraitsFS::GetParent(PathTraitsFS::const_pointer_type p) noexcept
{ {
return GetParentPathImpl<PathTraitsFS>(p); return GetParentPathImpl<PathTraitsFS>(p);
} }
PathTraitsFS::const_pointer_type PathTraitsFS::const_pointer_type
PathTraitsFS::Relative(const_pointer_type base, const_pointer_type other) PathTraitsFS::Relative(const_pointer_type base, const_pointer_type other) noexcept
{ {
return RelativePathImpl<PathTraitsFS>(base, other); return RelativePathImpl<PathTraitsFS>(base, other);
} }
PathTraitsUTF8::string PathTraitsUTF8::string
PathTraitsUTF8::Build(const_pointer_type a, size_t a_size, PathTraitsUTF8::Build(const_pointer_type a, size_t a_size,
const_pointer_type b, size_t b_size) const_pointer_type b, size_t b_size) noexcept
{ {
return BuildPathImpl<PathTraitsUTF8>(a, a_size, b, b_size); return BuildPathImpl<PathTraitsUTF8>(a, a_size, b, b_size);
} }
PathTraitsUTF8::const_pointer_type PathTraitsUTF8::const_pointer_type
PathTraitsUTF8::GetBase(const_pointer_type p) PathTraitsUTF8::GetBase(const_pointer_type p) noexcept
{ {
return GetBasePathImpl<PathTraitsUTF8>(p); return GetBasePathImpl<PathTraitsUTF8>(p);
} }
PathTraitsUTF8::string PathTraitsUTF8::string
PathTraitsUTF8::GetParent(const_pointer_type p) PathTraitsUTF8::GetParent(const_pointer_type p) noexcept
{ {
return GetParentPathImpl<PathTraitsUTF8>(p); return GetParentPathImpl<PathTraitsUTF8>(p);
} }
PathTraitsUTF8::const_pointer_type PathTraitsUTF8::const_pointer_type
PathTraitsUTF8::Relative(const_pointer_type base, const_pointer_type other) PathTraitsUTF8::Relative(const_pointer_type base,
const_pointer_type other) noexcept
{ {
return RelativePathImpl<PathTraitsUTF8>(base, other); return RelativePathImpl<PathTraitsUTF8>(base, other);
} }
...@@ -124,7 +124,7 @@ struct PathTraitsFS { ...@@ -124,7 +124,7 @@ struct PathTraitsFS {
* The return value points inside the given string. * The return value points inside the given string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer_type GetBase(const_pointer_type p); static const_pointer_type GetBase(const_pointer_type p) noexcept;
/** /**
* Determine the "parent" file name of the given native path. * Determine the "parent" file name of the given native path.
...@@ -132,7 +132,7 @@ struct PathTraitsFS { ...@@ -132,7 +132,7 @@ struct PathTraitsFS {
* separator in the given input string. * separator in the given input string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string GetParent(const_pointer_type p); static string GetParent(const_pointer_type p) noexcept;
/** /**
* Determine the relative part of the given path to this * Determine the relative part of the given path to this
...@@ -142,7 +142,7 @@ struct PathTraitsFS { ...@@ -142,7 +142,7 @@ struct PathTraitsFS {
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer_type Relative(const_pointer_type base, static const_pointer_type Relative(const_pointer_type base,
const_pointer_type other); const_pointer_type other) noexcept;
/** /**
* Constructs the path from the given components. * Constructs the path from the given components.
...@@ -152,10 +152,10 @@ struct PathTraitsFS { ...@@ -152,10 +152,10 @@ struct PathTraitsFS {
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer_type a, size_t a_size, static string Build(const_pointer_type a, size_t a_size,
const_pointer_type b, size_t b_size); const_pointer_type b, size_t b_size) noexcept;
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer_type a, const_pointer_type b) { static string Build(const_pointer_type a, const_pointer_type b) noexcept {
return Build(a, GetLength(a), b, GetLength(b)); return Build(a, GetLength(a), b, GetLength(b));
} }
}; };
...@@ -224,7 +224,7 @@ struct PathTraitsUTF8 { ...@@ -224,7 +224,7 @@ struct PathTraitsUTF8 {
* The return value points inside the given string. * The return value points inside the given string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer_type GetBase(const_pointer_type p); static const_pointer_type GetBase(const_pointer_type p) noexcept;
/** /**
* Determine the "parent" file name of the given UTF-8 path. * Determine the "parent" file name of the given UTF-8 path.
...@@ -232,7 +232,7 @@ struct PathTraitsUTF8 { ...@@ -232,7 +232,7 @@ struct PathTraitsUTF8 {
* separator in the given input string. * separator in the given input string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string GetParent(const_pointer_type p); static string GetParent(const_pointer_type p) noexcept;
/** /**
* Determine the relative part of the given path to this * Determine the relative part of the given path to this
...@@ -242,7 +242,7 @@ struct PathTraitsUTF8 { ...@@ -242,7 +242,7 @@ struct PathTraitsUTF8 {
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer_type Relative(const_pointer_type base, static const_pointer_type Relative(const_pointer_type base,
const_pointer_type other); const_pointer_type other) noexcept;
/** /**
* Constructs the path from the given components. * Constructs the path from the given components.
...@@ -252,7 +252,7 @@ struct PathTraitsUTF8 { ...@@ -252,7 +252,7 @@ struct PathTraitsUTF8 {
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer_type a, size_t a_size, static string Build(const_pointer_type a, size_t a_size,
const_pointer_type b, size_t b_size); const_pointer_type b, size_t b_size) noexcept;
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer_type a, const_pointer_type b) { static string Build(const_pointer_type a, const_pointer_type b) {
......
...@@ -28,7 +28,7 @@ AutoGunzipReader::~AutoGunzipReader() ...@@ -28,7 +28,7 @@ AutoGunzipReader::~AutoGunzipReader()
gcc_pure gcc_pure
static bool static bool
IsGzip(const uint8_t data[4]) IsGzip(const uint8_t data[4]) noexcept
{ {
return data[0] == 0x1f && data[1] == 0x8b && data[2] == 0x08 && return data[0] == 0x1f && data[1] == 0x8b && data[2] == 0x08 &&
(data[3] & 0xe0) == 0; (data[3] & 0xe0) == 0;
......
...@@ -78,7 +78,7 @@ FileOutputStream::OpenAppend(bool create) ...@@ -78,7 +78,7 @@ FileOutputStream::OpenAppend(bool create)
} }
uint64_t uint64_t
FileOutputStream::Tell() const FileOutputStream::Tell() const noexcept
{ {
LONG high = 0; LONG high = 0;
DWORD low = SetFilePointer(handle, 0, &high, FILE_CURRENT); DWORD low = SetFilePointer(handle, 0, &high, FILE_CURRENT);
...@@ -184,7 +184,7 @@ FileOutputStream::OpenAppend(bool create) ...@@ -184,7 +184,7 @@ FileOutputStream::OpenAppend(bool create)
} }
uint64_t uint64_t
FileOutputStream::Tell() const FileOutputStream::Tell() const noexcept
{ {
return fd.Tell(); return fd.Tell();
} }
......
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
} }
gcc_pure gcc_pure
uint64_t Tell() const; uint64_t Tell() const noexcept;
/* virtual methods from class OutputStream */ /* virtual methods from class OutputStream */
void Write(const void *data, size_t size) override; void Write(const void *data, size_t size) override;
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
FileInfo GetFileInfo() const; FileInfo GetFileInfo() const;
gcc_pure gcc_pure
uint64_t GetSize() const { uint64_t GetSize() const noexcept {
#ifdef WIN32 #ifdef WIN32
LARGE_INTEGER size; LARGE_INTEGER size;
return GetFileSizeEx(handle, &size) return GetFileSizeEx(handle, &size)
...@@ -102,7 +102,7 @@ public: ...@@ -102,7 +102,7 @@ public:
} }
gcc_pure gcc_pure
uint64_t GetPosition() const { uint64_t GetPosition() const noexcept {
#ifdef WIN32 #ifdef WIN32
LARGE_INTEGER zero; LARGE_INTEGER zero;
zero.QuadPart = 0; zero.QuadPart = 0;
......
...@@ -89,7 +89,7 @@ AsyncInputStream::Check() ...@@ -89,7 +89,7 @@ AsyncInputStream::Check()
} }
bool bool
AsyncInputStream::IsEOF() AsyncInputStream::IsEOF() noexcept
{ {
return (KnownSize() && offset >= size) || return (KnownSize() && offset >= size) ||
(!open && buffer.IsEmpty()); (!open && buffer.IsEmpty());
...@@ -164,7 +164,7 @@ AsyncInputStream::ReadTag() ...@@ -164,7 +164,7 @@ AsyncInputStream::ReadTag()
} }
bool bool
AsyncInputStream::IsAvailable() AsyncInputStream::IsAvailable() noexcept
{ {
return postponed_exception || return postponed_exception ||
IsEOF() || IsEOF() ||
......
...@@ -82,10 +82,10 @@ public: ...@@ -82,10 +82,10 @@ public:
/* virtual methods from InputStream */ /* virtual methods from InputStream */
void Check() final; void Check() final;
bool IsEOF() final; bool IsEOF() noexcept final;
void Seek(offset_type new_offset) final; void Seek(offset_type new_offset) final;
Tag *ReadTag() final; Tag *ReadTag() final;
bool IsAvailable() final; bool IsAvailable() noexcept final;
size_t Read(void *ptr, size_t read_size) final; size_t Read(void *ptr, size_t read_size) final;
protected: protected:
......
...@@ -75,14 +75,14 @@ InputStream::LockWaitReady() ...@@ -75,14 +75,14 @@ InputStream::LockWaitReady()
*/ */
gcc_pure gcc_pure
static bool static bool
ExpensiveSeeking(const char *uri) ExpensiveSeeking(const char *uri) noexcept
{ {
return StringStartsWith(uri, "http://") || return StringStartsWith(uri, "http://") ||
StringStartsWith(uri, "https://"); StringStartsWith(uri, "https://");
} }
bool bool
InputStream::CheapSeeking() const InputStream::CheapSeeking() const noexcept
{ {
return IsSeekable() && !ExpensiveSeeking(uri.c_str()); return IsSeekable() && !ExpensiveSeeking(uri.c_str());
} }
...@@ -121,7 +121,7 @@ InputStream::LockReadTag() ...@@ -121,7 +121,7 @@ InputStream::LockReadTag()
} }
bool bool
InputStream::IsAvailable() InputStream::IsAvailable() noexcept
{ {
return true; return true;
} }
...@@ -169,7 +169,7 @@ InputStream::LockReadFull(void *ptr, size_t _size) ...@@ -169,7 +169,7 @@ InputStream::LockReadFull(void *ptr, size_t _size)
} }
bool bool
InputStream::LockIsEOF() InputStream::LockIsEOF() noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
return IsEOF(); return IsEOF();
......
...@@ -261,7 +261,7 @@ public: ...@@ -261,7 +261,7 @@ public:
* Determines whether seeking is cheap. This is true for local files. * Determines whether seeking is cheap. This is true for local files.
*/ */
gcc_pure gcc_pure
bool CheapSeeking() const; bool CheapSeeking() const noexcept;
/** /**
* Seeks to the specified position in the stream. This will most * Seeks to the specified position in the stream. This will most
...@@ -308,14 +308,14 @@ public: ...@@ -308,14 +308,14 @@ public:
* The caller must lock the mutex. * The caller must lock the mutex.
*/ */
gcc_pure gcc_pure
virtual bool IsEOF() = 0; virtual bool IsEOF() noexcept = 0;
/** /**
* Wrapper for IsEOF() which locks and unlocks the mutex; the * Wrapper for IsEOF() which locks and unlocks the mutex; the
* caller must not be holding it already. * caller must not be holding it already.
*/ */
gcc_pure gcc_pure
bool LockIsEOF(); bool LockIsEOF() noexcept;
/** /**
* Reads the tag from the stream. * Reads the tag from the stream.
...@@ -343,7 +343,7 @@ public: ...@@ -343,7 +343,7 @@ public:
* The caller must lock the mutex. * The caller must lock the mutex.
*/ */
gcc_pure gcc_pure
virtual bool IsAvailable(); virtual bool IsAvailable() noexcept;
/** /**
* Reads data from the stream into the caller-supplied buffer. * Reads data from the stream into the caller-supplied buffer.
......
...@@ -70,7 +70,7 @@ ProxyInputStream::Seek(offset_type new_offset) ...@@ -70,7 +70,7 @@ ProxyInputStream::Seek(offset_type new_offset)
} }
bool bool
ProxyInputStream::IsEOF() ProxyInputStream::IsEOF() noexcept
{ {
return input.IsEOF(); return input.IsEOF();
} }
...@@ -82,7 +82,7 @@ ProxyInputStream::ReadTag() ...@@ -82,7 +82,7 @@ ProxyInputStream::ReadTag()
} }
bool bool
ProxyInputStream::IsAvailable() ProxyInputStream::IsAvailable() noexcept
{ {
return input.IsAvailable(); return input.IsAvailable();
} }
......
...@@ -46,9 +46,9 @@ public: ...@@ -46,9 +46,9 @@ public:
void Check() override; void Check() override;
void Update() override; void Update() override;
void Seek(offset_type new_offset) override; void Seek(offset_type new_offset) override;
bool IsEOF() override; bool IsEOF() noexcept override;
Tag *ReadTag() override; Tag *ReadTag() override;
bool IsAvailable() override; bool IsAvailable() noexcept override;
size_t Read(void *ptr, size_t read_size) override; size_t Read(void *ptr, size_t read_size) override;
protected: protected:
......
...@@ -124,7 +124,7 @@ ThreadInputStream::Check() ...@@ -124,7 +124,7 @@ ThreadInputStream::Check()
} }
bool bool
ThreadInputStream::IsAvailable() ThreadInputStream::IsAvailable() noexcept
{ {
assert(!thread.IsInside()); assert(!thread.IsInside());
...@@ -158,7 +158,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size) ...@@ -158,7 +158,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size)
} }
bool bool
ThreadInputStream::IsEOF() ThreadInputStream::IsEOF() noexcept
{ {
assert(!thread.IsInside()); assert(!thread.IsInside());
......
...@@ -84,8 +84,8 @@ public: ...@@ -84,8 +84,8 @@ public:
/* virtual methods from InputStream */ /* virtual methods from InputStream */
void Check() override final; void Check() override final;
bool IsEOF() override final; bool IsEOF() noexcept final;
bool IsAvailable() override final; bool IsAvailable() noexcept final;
size_t Read(void *ptr, size_t size) override final; size_t Read(void *ptr, size_t size) override final;
protected: protected:
......
...@@ -96,7 +96,7 @@ class CdioParanoiaInputStream final : public InputStream { ...@@ -96,7 +96,7 @@ class CdioParanoiaInputStream final : public InputStream {
} }
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override; bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override; size_t Read(void *ptr, size_t size) override;
void Seek(offset_type offset) override; void Seek(offset_type offset) override;
}; };
...@@ -340,7 +340,7 @@ CdioParanoiaInputStream::Read(void *ptr, size_t length) ...@@ -340,7 +340,7 @@ CdioParanoiaInputStream::Read(void *ptr, size_t length)
} }
bool bool
CdioParanoiaInputStream::IsEOF() CdioParanoiaInputStream::IsEOF() noexcept
{ {
return lsn_from + lsn_relofs > lsn_to; return lsn_from + lsn_relofs > lsn_to;
} }
......
...@@ -59,7 +59,7 @@ struct FfmpegInputStream final : public InputStream { ...@@ -59,7 +59,7 @@ struct FfmpegInputStream final : public InputStream {
} }
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override; bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override; size_t Read(void *ptr, size_t size) override;
void Seek(offset_type offset) override; void Seek(offset_type offset) override;
}; };
...@@ -118,7 +118,7 @@ FfmpegInputStream::Read(void *ptr, size_t read_size) ...@@ -118,7 +118,7 @@ FfmpegInputStream::Read(void *ptr, size_t read_size)
} }
bool bool
FfmpegInputStream::IsEOF() FfmpegInputStream::IsEOF() noexcept
{ {
return eof; return eof;
} }
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override { bool IsEOF() noexcept override {
return GetOffset() >= GetSize(); return GetOffset() >= GetSize();
} }
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
ProxyInputStream::Update(); ProxyInputStream::Update();
} }
bool IsEOF() override { bool IsEOF() noexcept override {
return !ReadingFromBuffer() && ProxyInputStream::IsEOF(); return !ReadingFromBuffer() && ProxyInputStream::IsEOF();
} }
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override { bool IsEOF() noexcept override {
return offset >= size; return offset >= size;
} }
......
...@@ -170,7 +170,7 @@ CurlRequest::Done(CURLcode result) ...@@ -170,7 +170,7 @@ CurlRequest::Done(CURLcode result)
gcc_pure gcc_pure
static bool static bool
IsResponseBoundaryHeader(StringView s) IsResponseBoundaryHeader(StringView s) noexcept
{ {
return s.size > 5 && (memcmp(s.data, "HTTP/", 5) == 0 || return s.size > 5 && (memcmp(s.data, "HTTP/", 5) == 0 ||
/* the proprietary "ICY 200 OK" is /* the proprietary "ICY 200 OK" is
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <curl/curl.h> #include <curl/curl.h>
bool bool
IsCurlOlderThan(unsigned version_num) IsCurlOlderThan(unsigned version_num) noexcept
{ {
const auto *const info = curl_version_info(CURLVERSION_FIRST); const auto *const info = curl_version_info(CURLVERSION_FIRST);
return info == nullptr || info->version_num < version_num; return info == nullptr || info->version_num < version_num;
......
...@@ -34,6 +34,6 @@ ...@@ -34,6 +34,6 @@
gcc_const gcc_const
bool bool
IsCurlOlderThan(unsigned version_num); IsCurlOlderThan(unsigned version_num) noexcept;
#endif #endif
...@@ -32,7 +32,7 @@ ExpatParser::Parse(const char *data, size_t length, bool is_final) ...@@ -32,7 +32,7 @@ ExpatParser::Parse(const char *data, size_t length, bool is_final)
const char * const char *
ExpatParser::GetAttribute(const XML_Char **atts, ExpatParser::GetAttribute(const XML_Char **atts,
const char *name) const char *name) noexcept
{ {
for (unsigned i = 0; atts[i] != nullptr; i += 2) for (unsigned i = 0; atts[i] != nullptr; i += 2)
if (strcmp(atts[i], name) == 0) if (strcmp(atts[i], name) == 0)
...@@ -43,7 +43,7 @@ ExpatParser::GetAttribute(const XML_Char **atts, ...@@ -43,7 +43,7 @@ ExpatParser::GetAttribute(const XML_Char **atts,
const char * const char *
ExpatParser::GetAttributeCase(const XML_Char **atts, ExpatParser::GetAttributeCase(const XML_Char **atts,
const char *name) const char *name) noexcept
{ {
for (unsigned i = 0; atts[i] != nullptr; i += 2) for (unsigned i = 0; atts[i] != nullptr; i += 2)
if (StringEqualsCaseASCII(atts[i], name)) if (StringEqualsCaseASCII(atts[i], name))
......
...@@ -64,11 +64,11 @@ public: ...@@ -64,11 +64,11 @@ public:
ExpatParser &operator=(const ExpatParser &) = delete; ExpatParser &operator=(const ExpatParser &) = delete;
void SetElementHandler(XML_StartElementHandler start, void SetElementHandler(XML_StartElementHandler start,
XML_EndElementHandler end) { XML_EndElementHandler end) noexcept {
XML_SetElementHandler(parser, start, end); XML_SetElementHandler(parser, start, end);
} }
void SetCharacterDataHandler(XML_CharacterDataHandler charhndl) { void SetCharacterDataHandler(XML_CharacterDataHandler charhndl) noexcept {
XML_SetCharacterDataHandler(parser, charhndl); XML_SetCharacterDataHandler(parser, charhndl);
} }
...@@ -78,11 +78,11 @@ public: ...@@ -78,11 +78,11 @@ public:
gcc_pure gcc_pure
static const char *GetAttribute(const XML_Char **atts, static const char *GetAttribute(const XML_Char **atts,
const char *name); const char *name) noexcept;
gcc_pure gcc_pure
static const char *GetAttributeCase(const XML_Char **atts, static const char *GetAttributeCase(const XML_Char **atts,
const char *name); const char *name) noexcept;
}; };
/** /**
...@@ -114,13 +114,13 @@ public: ...@@ -114,13 +114,13 @@ public:
gcc_pure gcc_pure
static const char *GetAttribute(const XML_Char **atts, static const char *GetAttribute(const XML_Char **atts,
const char *name) { const char *name) noexcept {
return ExpatParser::GetAttribute(atts, name); return ExpatParser::GetAttribute(atts, name);
} }
gcc_pure gcc_pure
static const char *GetAttributeCase(const XML_Char **atts, static const char *GetAttributeCase(const XML_Char **atts,
const char *name) { const char *name) noexcept {
return ExpatParser::GetAttributeCase(atts, name); return ExpatParser::GetAttributeCase(atts, name);
} }
......
...@@ -34,7 +34,7 @@ extern "C" { ...@@ -34,7 +34,7 @@ extern "C" {
gcc_const gcc_const
static LogLevel static LogLevel
FfmpegImportLogLevel(int level) FfmpegImportLogLevel(int level) noexcept
{ {
if (level <= AV_LOG_FATAL) if (level <= AV_LOG_FATAL)
return LogLevel::ERROR; return LogLevel::ERROR;
......
...@@ -41,7 +41,7 @@ extern "C" { ...@@ -41,7 +41,7 @@ extern "C" {
*/ */
gcc_const gcc_const
static inline double static inline double
FfmpegTimeToDouble(int64_t t, const AVRational time_base) FfmpegTimeToDouble(int64_t t, const AVRational time_base) noexcept
{ {
assert(t != (int64_t)AV_NOPTS_VALUE); assert(t != (int64_t)AV_NOPTS_VALUE);
...@@ -64,7 +64,7 @@ RatioToAVRational() ...@@ -64,7 +64,7 @@ RatioToAVRational()
*/ */
gcc_const gcc_const
static inline SongTime static inline SongTime
FromFfmpegTime(int64_t t, const AVRational time_base) FromFfmpegTime(int64_t t, const AVRational time_base) noexcept
{ {
assert(t != (int64_t)AV_NOPTS_VALUE); assert(t != (int64_t)AV_NOPTS_VALUE);
...@@ -77,7 +77,7 @@ FromFfmpegTime(int64_t t, const AVRational time_base) ...@@ -77,7 +77,7 @@ FromFfmpegTime(int64_t t, const AVRational time_base)
*/ */
gcc_const gcc_const
static inline SignedSongTime static inline SignedSongTime
FromFfmpegTimeChecked(int64_t t, const AVRational time_base) FromFfmpegTimeChecked(int64_t t, const AVRational time_base) noexcept
{ {
return t != (int64_t)AV_NOPTS_VALUE return t != (int64_t)AV_NOPTS_VALUE
? SignedSongTime(FromFfmpegTime(t, time_base)) ? SignedSongTime(FromFfmpegTime(t, time_base))
...@@ -89,7 +89,7 @@ FromFfmpegTimeChecked(int64_t t, const AVRational time_base) ...@@ -89,7 +89,7 @@ FromFfmpegTimeChecked(int64_t t, const AVRational time_base)
*/ */
gcc_const gcc_const
static inline int64_t static inline int64_t
ToFfmpegTime(SongTime t, const AVRational time_base) ToFfmpegTime(SongTime t, const AVRational time_base) noexcept
{ {
return av_rescale_q(t.count(), return av_rescale_q(t.count(),
RatioToAVRational<SongTime::period>(), RatioToAVRational<SongTime::period>(),
......
...@@ -65,7 +65,7 @@ IcuCollateInit() ...@@ -65,7 +65,7 @@ IcuCollateInit()
} }
void void
IcuCollateFinish() IcuCollateFinish() noexcept
{ {
assert(collator != nullptr); assert(collator != nullptr);
...@@ -76,7 +76,7 @@ IcuCollateFinish() ...@@ -76,7 +76,7 @@ IcuCollateFinish()
gcc_pure gcc_pure
int int
IcuCollate(const char *a, const char *b) IcuCollate(const char *a, const char *b) noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
......
...@@ -32,11 +32,11 @@ void ...@@ -32,11 +32,11 @@ void
IcuCollateInit(); IcuCollateInit();
void void
IcuCollateFinish(); IcuCollateFinish() noexcept;
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
int int
IcuCollate(const char *a, const char *b); IcuCollate(const char *a, const char *b) noexcept;
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
AllocatedString<char> AllocatedString<char>
......
...@@ -46,7 +46,7 @@ nfs_set_base(const char *server, const char *export_name) ...@@ -46,7 +46,7 @@ nfs_set_base(const char *server, const char *export_name)
} }
const char * const char *
nfs_check_base(const char *server, const char *path) nfs_check_base(const char *server, const char *path) noexcept
{ {
assert(server != nullptr); assert(server != nullptr);
assert(path != nullptr); assert(path != nullptr);
......
...@@ -41,6 +41,6 @@ nfs_set_base(const char *server, const char *export_name); ...@@ -41,6 +41,6 @@ nfs_set_base(const char *server, const char *export_name);
*/ */
gcc_pure gcc_pure
const char * const char *
nfs_check_base(const char *server, const char *path); nfs_check_base(const char *server, const char *path) noexcept;
#endif #endif
...@@ -91,29 +91,29 @@ private: ...@@ -91,29 +91,29 @@ private:
}; };
gcc_pure gcc_pure
iterator Find(reference_type p) { iterator Find(reference_type p) noexcept {
return std::find_if(list.begin(), list.end(), MatchPointer(p)); return std::find_if(list.begin(), list.end(), MatchPointer(p));
} }
gcc_pure gcc_pure
const_iterator Find(const_reference_type p) const { const_iterator Find(const_reference_type p) const noexcept {
return std::find_if(list.begin(), list.end(), MatchPointer(p)); return std::find_if(list.begin(), list.end(), MatchPointer(p));
} }
gcc_pure gcc_pure
iterator Find(CT &c) { iterator Find(CT &c) noexcept {
return list.iterator_to(c); return list.iterator_to(c);
} }
gcc_pure gcc_pure
const_iterator Find(const CT &c) const { const_iterator Find(const CT &c) const noexcept {
return list.iterator_to(c); return list.iterator_to(c);
} }
public: public:
#ifndef NDEBUG #ifndef NDEBUG
gcc_pure gcc_pure
bool IsEmpty() const { bool IsEmpty() const noexcept {
for (const auto &c : list) for (const auto &c : list)
if (!c.IsCancelled()) if (!c.IsCancelled())
return false; return false;
...@@ -123,7 +123,7 @@ public: ...@@ -123,7 +123,7 @@ public:
#endif #endif
gcc_pure gcc_pure
bool Contains(const_reference_type p) const { bool Contains(const_reference_type p) const noexcept {
return Find(p) != list.end(); return Find(p) != list.end();
} }
...@@ -151,7 +151,7 @@ public: ...@@ -151,7 +151,7 @@ public:
i->Cancel(); i->Cancel();
} }
CT &Get(reference_type p) { CT &Get(reference_type p) noexcept {
auto i = Find(p); auto i = Find(p);
assert(i != list.end()); assert(i != list.end());
......
...@@ -135,7 +135,7 @@ class NfsConnection : SocketMonitor, TimeoutMonitor, DeferredMonitor { ...@@ -135,7 +135,7 @@ class NfsConnection : SocketMonitor, TimeoutMonitor, DeferredMonitor {
public: public:
gcc_nonnull_all gcc_nonnull_all
NfsConnection(EventLoop &_loop, NfsConnection(EventLoop &_loop,
const char *_server, const char *_export_name) const char *_server, const char *_export_name) noexcept
:SocketMonitor(_loop), TimeoutMonitor(_loop), :SocketMonitor(_loop), TimeoutMonitor(_loop),
DeferredMonitor(_loop), DeferredMonitor(_loop),
server(_server), export_name(_export_name), server(_server), export_name(_export_name),
......
...@@ -50,7 +50,7 @@ nfs_finish() ...@@ -50,7 +50,7 @@ nfs_finish()
} }
NfsConnection & NfsConnection &
nfs_get_connection(const char *server, const char *export_name) nfs_get_connection(const char *server, const char *export_name) noexcept
{ {
assert(in_use > 0); assert(in_use > 0);
assert(io_thread_inside()); assert(io_thread_inside());
......
...@@ -33,6 +33,6 @@ nfs_finish(); ...@@ -33,6 +33,6 @@ nfs_finish();
gcc_pure gcc_pure
NfsConnection & NfsConnection &
nfs_get_connection(const char *server, const char *export_name); nfs_get_connection(const char *server, const char *export_name) noexcept;
#endif #endif
...@@ -38,7 +38,7 @@ NfsManager::ManagedConnection::OnNfsConnectionError(std::exception_ptr &&e) ...@@ -38,7 +38,7 @@ NfsManager::ManagedConnection::OnNfsConnectionError(std::exception_ptr &&e)
inline bool inline bool
NfsManager::Compare::operator()(const LookupKey a, NfsManager::Compare::operator()(const LookupKey a,
const ManagedConnection &b) const const ManagedConnection &b) const noexcept
{ {
int result = strcmp(a.server, b.GetServer()); int result = strcmp(a.server, b.GetServer());
if (result != 0) if (result != 0)
...@@ -50,7 +50,7 @@ NfsManager::Compare::operator()(const LookupKey a, ...@@ -50,7 +50,7 @@ NfsManager::Compare::operator()(const LookupKey a,
inline bool inline bool
NfsManager::Compare::operator()(const ManagedConnection &a, NfsManager::Compare::operator()(const ManagedConnection &a,
const LookupKey b) const const LookupKey b) const noexcept
{ {
int result = strcmp(a.GetServer(), b.server); int result = strcmp(a.GetServer(), b.server);
if (result != 0) if (result != 0)
...@@ -62,7 +62,7 @@ NfsManager::Compare::operator()(const ManagedConnection &a, ...@@ -62,7 +62,7 @@ NfsManager::Compare::operator()(const ManagedConnection &a,
inline bool inline bool
NfsManager::Compare::operator()(const ManagedConnection &a, NfsManager::Compare::operator()(const ManagedConnection &a,
const ManagedConnection &b) const const ManagedConnection &b) const noexcept
{ {
int result = strcmp(a.GetServer(), b.GetServer()); int result = strcmp(a.GetServer(), b.GetServer());
if (result != 0) if (result != 0)
...@@ -82,7 +82,7 @@ NfsManager::~NfsManager() ...@@ -82,7 +82,7 @@ NfsManager::~NfsManager()
} }
NfsConnection & NfsConnection &
NfsManager::GetConnection(const char *server, const char *export_name) NfsManager::GetConnection(const char *server, const char *export_name) noexcept
{ {
assert(server != nullptr); assert(server != nullptr);
assert(export_name != nullptr); assert(export_name != nullptr);
......
...@@ -59,15 +59,15 @@ class NfsManager final : IdleMonitor { ...@@ -59,15 +59,15 @@ class NfsManager final : IdleMonitor {
struct Compare { struct Compare {
gcc_pure gcc_pure
bool operator()(const LookupKey a, bool operator()(const LookupKey a,
const ManagedConnection &b) const; const ManagedConnection &b) const noexcept;
gcc_pure gcc_pure
bool operator()(const ManagedConnection &a, bool operator()(const ManagedConnection &a,
const LookupKey b) const; const LookupKey b) const noexcept;
gcc_pure gcc_pure
bool operator()(const ManagedConnection &a, bool operator()(const ManagedConnection &a,
const ManagedConnection &b) const; const ManagedConnection &b) const noexcept;
}; };
/** /**
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
gcc_pure gcc_pure
NfsConnection &GetConnection(const char *server, NfsConnection &GetConnection(const char *server,
const char *export_name); const char *export_name) noexcept;
private: private:
void ScheduleDelete(ManagedConnection &c) { void ScheduleDelete(ManagedConnection &c) {
......
...@@ -36,7 +36,7 @@ static constexpr char ContentDirectorySType[] = "urn:schemas-upnp-org:service:Co ...@@ -36,7 +36,7 @@ static constexpr char ContentDirectorySType[] = "urn:schemas-upnp-org:service:Co
// version 1 // version 1
gcc_pure gcc_pure
static bool static bool
isCDService(const char *st) isCDService(const char *st) noexcept
{ {
constexpr size_t sz = sizeof(ContentDirectorySType) - 3; constexpr size_t sz = sizeof(ContentDirectorySType) - 3;
return memcmp(ContentDirectorySType, st, sz) == 0; return memcmp(ContentDirectorySType, st, sz) == 0;
...@@ -47,7 +47,7 @@ static constexpr char MediaServerDType[] = "urn:schemas-upnp-org:device:MediaSer ...@@ -47,7 +47,7 @@ static constexpr char MediaServerDType[] = "urn:schemas-upnp-org:device:MediaSer
gcc_pure gcc_pure
static bool static bool
isMSDevice(const char *st) isMSDevice(const char *st) noexcept
{ {
constexpr size_t sz = sizeof(MediaServerDType) - 3; constexpr size_t sz = sizeof(MediaServerDType) - 3;
return memcmp(MediaServerDType, st, sz) == 0; return memcmp(MediaServerDType, st, sz) == 0;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** Get rid of white space at both ends */ /** Get rid of white space at both ends */
void void
trimstring(std::string &s, const char *ws) trimstring(std::string &s, const char *ws) noexcept
{ {
auto pos = s.find_first_not_of(ws); auto pos = s.find_first_not_of(ws);
if (pos == std::string::npos) { if (pos == std::string::npos) {
...@@ -38,14 +38,14 @@ trimstring(std::string &s, const char *ws) ...@@ -38,14 +38,14 @@ trimstring(std::string &s, const char *ws)
} }
static void static void
path_catslash(std::string &s) path_catslash(std::string &s) noexcept
{ {
if (s.empty() || s.back() != '/') if (s.empty() || s.back() != '/')
s += '/'; s += '/';
} }
std::string std::string
path_getfather(const std::string &s) path_getfather(const std::string &s) noexcept
{ {
std::string father = s; std::string father = s;
...@@ -71,7 +71,7 @@ path_getfather(const std::string &s) ...@@ -71,7 +71,7 @@ path_getfather(const std::string &s)
std::list<std::string> std::list<std::string>
stringToTokens(const std::string &str, stringToTokens(const std::string &str,
const char delim) const char delim) noexcept
{ {
std::list<std::string> tokens; std::list<std::string> tokens;
...@@ -105,7 +105,7 @@ stringToTokens(const std::string &str, ...@@ -105,7 +105,7 @@ stringToTokens(const std::string &str,
template <class T> template <class T>
bool bool
csvToStrings(const char *s, T &tokens) csvToStrings(const char *s, T &tokens) noexcept
{ {
assert(tokens.empty()); assert(tokens.empty());
...@@ -132,4 +132,4 @@ csvToStrings(const char *s, T &tokens) ...@@ -132,4 +132,4 @@ csvToStrings(const char *s, T &tokens)
} }
} }
template bool csvToStrings<std::list<std::string>>(const char *, std::list<std::string> &); template bool csvToStrings<std::list<std::string>>(const char *, std::list<std::string> &) noexcept;
...@@ -26,17 +26,17 @@ ...@@ -26,17 +26,17 @@
#include <list> #include <list>
void void
trimstring(std::string &s, const char *ws = " \t\n"); trimstring(std::string &s, const char *ws = " \t\n") noexcept;
std::string std::string
path_getfather(const std::string &s); path_getfather(const std::string &s) noexcept;
gcc_pure gcc_pure
std::list<std::string> std::list<std::string>
stringToTokens(const std::string &str, char delim); stringToTokens(const std::string &str, char delim) noexcept;
template <class T> template <class T>
bool bool
csvToStrings(const char *s, T &tokens); csvToStrings(const char *s, T &tokens) noexcept;
#endif /* _UPNPP_H_X_INCLUDED_ */ #endif /* _UPNPP_H_X_INCLUDED_ */
...@@ -89,7 +89,8 @@ print_supported_uri_schemes(Response &r) ...@@ -89,7 +89,8 @@ print_supported_uri_schemes(Response &r)
} }
} }
bool uri_supported_scheme(const char *uri) bool
uri_supported_scheme(const char *uri) noexcept
{ {
const char *const*urlPrefixes = remoteUrlPrefixes; const char *const*urlPrefixes = remoteUrlPrefixes;
......
...@@ -32,7 +32,8 @@ class Response; ...@@ -32,7 +32,8 @@ class Response;
* uri_has_scheme() first. * uri_has_scheme() first.
*/ */
gcc_pure gcc_pure
bool uri_supported_scheme(const char *url); bool
uri_supported_scheme(const char *url) noexcept;
/** /**
* Send a list of supported URI schemes to the client. This is the * Send a list of supported URI schemes to the client. This is the
......
...@@ -30,8 +30,9 @@ ...@@ -30,8 +30,9 @@
#include <assert.h> #include <assert.h>
gcc_pure
static int static int
output_mixer_get_volume(const AudioOutput &ao) output_mixer_get_volume(const AudioOutput &ao) noexcept
{ {
if (!ao.enabled) if (!ao.enabled)
return -1; return -1;
...@@ -51,7 +52,7 @@ output_mixer_get_volume(const AudioOutput &ao) ...@@ -51,7 +52,7 @@ output_mixer_get_volume(const AudioOutput &ao)
} }
int int
MultipleOutputs::GetVolume() const MultipleOutputs::GetVolume() const noexcept
{ {
unsigned ok = 0; unsigned ok = 0;
int total = 0; int total = 0;
...@@ -71,7 +72,7 @@ MultipleOutputs::GetVolume() const ...@@ -71,7 +72,7 @@ MultipleOutputs::GetVolume() const
} }
static bool static bool
output_mixer_set_volume(AudioOutput &ao, unsigned volume) output_mixer_set_volume(AudioOutput &ao, unsigned volume) noexcept
{ {
assert(volume <= 100); assert(volume <= 100);
...@@ -94,7 +95,7 @@ output_mixer_set_volume(AudioOutput &ao, unsigned volume) ...@@ -94,7 +95,7 @@ output_mixer_set_volume(AudioOutput &ao, unsigned volume)
} }
bool bool
MultipleOutputs::SetVolume(unsigned volume) MultipleOutputs::SetVolume(unsigned volume) noexcept
{ {
assert(volume <= 100); assert(volume <= 100);
...@@ -107,7 +108,7 @@ MultipleOutputs::SetVolume(unsigned volume) ...@@ -107,7 +108,7 @@ MultipleOutputs::SetVolume(unsigned volume)
} }
static int static int
output_mixer_get_software_volume(const AudioOutput &ao) output_mixer_get_software_volume(const AudioOutput &ao) noexcept
{ {
if (!ao.enabled) if (!ao.enabled)
return -1; return -1;
...@@ -120,7 +121,7 @@ output_mixer_get_software_volume(const AudioOutput &ao) ...@@ -120,7 +121,7 @@ output_mixer_get_software_volume(const AudioOutput &ao)
} }
int int
MultipleOutputs::GetSoftwareVolume() const MultipleOutputs::GetSoftwareVolume() const noexcept
{ {
unsigned ok = 0; unsigned ok = 0;
int total = 0; int total = 0;
...@@ -140,7 +141,7 @@ MultipleOutputs::GetSoftwareVolume() const ...@@ -140,7 +141,7 @@ MultipleOutputs::GetSoftwareVolume() const
} }
void void
MultipleOutputs::SetSoftwareVolume(unsigned volume) MultipleOutputs::SetSoftwareVolume(unsigned volume) noexcept
{ {
assert(volume <= PCM_VOLUME_1); assert(volume <= PCM_VOLUME_1);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <string.h> #include <string.h>
MixerType MixerType
mixer_type_parse(const char *input) mixer_type_parse(const char *input) noexcept
{ {
assert(input != NULL); assert(input != NULL);
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#ifndef MPD_MIXER_TYPE_HXX #ifndef MPD_MIXER_TYPE_HXX
#define MPD_MIXER_TYPE_HXX #define MPD_MIXER_TYPE_HXX
#include "Compiler.h"
enum class MixerType { enum class MixerType {
/** parser error */ /** parser error */
UNKNOWN, UNKNOWN,
...@@ -44,7 +46,8 @@ enum class MixerType { ...@@ -44,7 +46,8 @@ enum class MixerType {
* a #MixerType value; #MixerType::UNKNOWN means #input could not be * a #MixerType value; #MixerType::UNKNOWN means #input could not be
* parsed * parsed
*/ */
gcc_pure
MixerType MixerType
mixer_type_parse(const char *input); mixer_type_parse(const char *input) noexcept;
#endif #endif
...@@ -42,14 +42,14 @@ static int last_hardware_volume = -1; ...@@ -42,14 +42,14 @@ static int last_hardware_volume = -1;
static PeriodClock hardware_volume_clock; static PeriodClock hardware_volume_clock;
void void
InvalidateHardwareVolume() InvalidateHardwareVolume() noexcept
{ {
/* flush the hardware volume cache */ /* flush the hardware volume cache */
last_hardware_volume = -1; last_hardware_volume = -1;
} }
int int
volume_level_get(const MultipleOutputs &outputs) volume_level_get(const MultipleOutputs &outputs) noexcept
{ {
if (last_hardware_volume >= 0 && if (last_hardware_volume >= 0 &&
!hardware_volume_clock.CheckUpdate(std::chrono::seconds(1))) !hardware_volume_clock.CheckUpdate(std::chrono::seconds(1)))
...@@ -118,7 +118,7 @@ save_sw_volume_state(BufferedOutputStream &os) ...@@ -118,7 +118,7 @@ save_sw_volume_state(BufferedOutputStream &os)
} }
unsigned unsigned
sw_volume_state_get_hash(void) sw_volume_state_get_hash() noexcept
{ {
return volume_software_set; return volume_software_set;
} }
...@@ -26,11 +26,11 @@ class MultipleOutputs; ...@@ -26,11 +26,11 @@ class MultipleOutputs;
class BufferedOutputStream; class BufferedOutputStream;
void void
InvalidateHardwareVolume(); InvalidateHardwareVolume() noexcept;
gcc_pure gcc_pure
int int
volume_level_get(const MultipleOutputs &outputs); volume_level_get(const MultipleOutputs &outputs) noexcept;
bool bool
volume_level_change(MultipleOutputs &outputs, unsigned volume); volume_level_change(MultipleOutputs &outputs, unsigned volume);
...@@ -49,6 +49,6 @@ save_sw_volume_state(BufferedOutputStream &os); ...@@ -49,6 +49,6 @@ save_sw_volume_state(BufferedOutputStream &os);
*/ */
gcc_pure gcc_pure
unsigned unsigned
sw_volume_state_get_hash(); sw_volume_state_get_hash() noexcept;
#endif #endif
...@@ -201,7 +201,8 @@ AlsaMixer::~AlsaMixer() ...@@ -201,7 +201,8 @@ AlsaMixer::~AlsaMixer()
gcc_pure gcc_pure
static snd_mixer_elem_t * static snd_mixer_elem_t *
alsa_mixer_lookup_elem(snd_mixer_t *handle, const char *name, unsigned idx) alsa_mixer_lookup_elem(snd_mixer_t *handle,
const char *name, unsigned idx) noexcept
{ {
for (snd_mixer_elem_t *elem = snd_mixer_first_elem(handle); for (snd_mixer_elem_t *elem = snd_mixer_first_elem(handle);
elem != nullptr; elem = snd_mixer_elem_next(elem)) { elem != nullptr; elem = snd_mixer_elem_next(elem)) {
......
...@@ -71,7 +71,7 @@ software_mixer_init(gcc_unused EventLoop &event_loop, ...@@ -71,7 +71,7 @@ software_mixer_init(gcc_unused EventLoop &event_loop,
gcc_const gcc_const
static unsigned static unsigned
PercentVolumeToSoftwareVolume(unsigned volume) PercentVolumeToSoftwareVolume(unsigned volume) noexcept
{ {
assert(volume <= 100); assert(volume <= 100);
......
...@@ -93,7 +93,7 @@ NeighborGlue::Close() ...@@ -93,7 +93,7 @@ NeighborGlue::Close()
} }
NeighborGlue::List NeighborGlue::List
NeighborGlue::GetList() const NeighborGlue::GetList() const noexcept
{ {
List result; List result;
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
* plugins. * plugins.
*/ */
gcc_pure gcc_pure
List GetList() const; List GetList() const noexcept;
}; };
#endif #endif
...@@ -36,7 +36,7 @@ const NeighborPlugin *const neighbor_plugins[] = { ...@@ -36,7 +36,7 @@ const NeighborPlugin *const neighbor_plugins[] = {
}; };
const NeighborPlugin * const NeighborPlugin *
GetNeighborPluginByName(const char *name) GetNeighborPluginByName(const char *name) noexcept
{ {
for (auto i = neighbor_plugins; *i != nullptr; ++i) for (auto i = neighbor_plugins; *i != nullptr; ++i)
if (strcmp((*i)->name, name) == 0) if (strcmp((*i)->name, name) == 0)
......
...@@ -32,6 +32,6 @@ extern const NeighborPlugin *const neighbor_plugins[]; ...@@ -32,6 +32,6 @@ extern const NeighborPlugin *const neighbor_plugins[];
gcc_pure gcc_pure
const NeighborPlugin * const NeighborPlugin *
GetNeighborPluginByName(const char *name); GetNeighborPluginByName(const char *name) noexcept;
#endif #endif
...@@ -169,7 +169,7 @@ ReadServers(NeighborExplorer::List &list, const char *uri) ...@@ -169,7 +169,7 @@ ReadServers(NeighborExplorer::List &list, const char *uri)
gcc_pure gcc_pure
static NeighborExplorer::List static NeighborExplorer::List
DetectServers() DetectServers() noexcept
{ {
NeighborExplorer::List list; NeighborExplorer::List list;
const std::lock_guard<Mutex> protect(smbclient_mutex); const std::lock_guard<Mutex> protect(smbclient_mutex);
...@@ -181,7 +181,7 @@ gcc_pure ...@@ -181,7 +181,7 @@ gcc_pure
static NeighborExplorer::List::const_iterator static NeighborExplorer::List::const_iterator
FindBeforeServerByURI(NeighborExplorer::List::const_iterator prev, FindBeforeServerByURI(NeighborExplorer::List::const_iterator prev,
NeighborExplorer::List::const_iterator end, NeighborExplorer::List::const_iterator end,
const std::string &uri) const std::string &uri) noexcept
{ {
for (auto i = std::next(prev); i != end; prev = i, i = std::next(prev)) for (auto i = std::next(prev); i != end; prev = i, i = std::next(prev))
if (i->uri == uri) if (i->uri == uri)
......
...@@ -50,7 +50,7 @@ AllocatedSocketAddress::operator=(SocketAddress src) ...@@ -50,7 +50,7 @@ AllocatedSocketAddress::operator=(SocketAddress src)
} }
void void
AllocatedSocketAddress::SetSize(size_type new_size) AllocatedSocketAddress::SetSize(size_type new_size) noexcept
{ {
if (size == new_size) if (size == new_size)
return; return;
...@@ -63,7 +63,7 @@ AllocatedSocketAddress::SetSize(size_type new_size) ...@@ -63,7 +63,7 @@ AllocatedSocketAddress::SetSize(size_type new_size)
#ifdef HAVE_UN #ifdef HAVE_UN
void void
AllocatedSocketAddress::SetLocal(const char *path) AllocatedSocketAddress::SetLocal(const char *path) noexcept
{ {
const bool is_abstract = *path == '@'; const bool is_abstract = *path == '@';
......
...@@ -140,11 +140,11 @@ public: ...@@ -140,11 +140,11 @@ public:
* begins with a '@', then the rest specifies an "abstract" local * begins with a '@', then the rest specifies an "abstract" local
* address. * address.
*/ */
void SetLocal(const char *path); void SetLocal(const char *path) noexcept;
#endif #endif
private: private:
void SetSize(size_type new_size); void SetSize(size_type new_size) noexcept;
}; };
#endif #endif
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <string.h> #include <string.h>
bool bool
SocketAddress::operator==(SocketAddress other) const SocketAddress::operator==(SocketAddress other) const noexcept
{ {
return size == other.size && memcmp(address, other.address, size) == 0; return size == other.size && memcmp(address, other.address, size) == 0;
} }
...@@ -93,9 +93,9 @@ public: ...@@ -93,9 +93,9 @@ public:
} }
gcc_pure gcc_pure
bool operator==(const SocketAddress other) const; bool operator==(const SocketAddress other) const noexcept;
bool operator!=(const SocketAddress other) const { bool operator!=(const SocketAddress other) const noexcept {
return !(*this == other); return !(*this == other);
} }
}; };
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifdef WIN32 #ifdef WIN32
SocketErrorMessage::SocketErrorMessage(socket_error_t code) SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept
{ {
#ifdef _UNICODE #ifdef _UNICODE
wchar_t buffer[ARRAY_SIZE(msg)]; wchar_t buffer[ARRAY_SIZE(msg)];
...@@ -56,7 +56,7 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code) ...@@ -56,7 +56,7 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code)
#else #else
SocketErrorMessage::SocketErrorMessage(socket_error_t code) SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept
:msg(strerror(code)) {} :msg(strerror(code)) {}
#endif #endif
...@@ -33,7 +33,7 @@ typedef int socket_error_t; ...@@ -33,7 +33,7 @@ typedef int socket_error_t;
gcc_pure gcc_pure
static inline socket_error_t static inline socket_error_t
GetSocketError() GetSocketError() noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return WSAGetLastError(); return WSAGetLastError();
...@@ -44,7 +44,7 @@ GetSocketError() ...@@ -44,7 +44,7 @@ GetSocketError()
gcc_const gcc_const
static inline bool static inline bool
IsSocketErrorAgain(socket_error_t code) IsSocketErrorAgain(socket_error_t code) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return code == WSAEINPROGRESS; return code == WSAEINPROGRESS;
...@@ -55,7 +55,7 @@ IsSocketErrorAgain(socket_error_t code) ...@@ -55,7 +55,7 @@ IsSocketErrorAgain(socket_error_t code)
gcc_const gcc_const
static inline bool static inline bool
IsSocketErrorInterruped(socket_error_t code) IsSocketErrorInterruped(socket_error_t code) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return code == WSAEINTR; return code == WSAEINTR;
...@@ -66,7 +66,7 @@ IsSocketErrorInterruped(socket_error_t code) ...@@ -66,7 +66,7 @@ IsSocketErrorInterruped(socket_error_t code)
gcc_const gcc_const
static inline bool static inline bool
IsSocketErrorClosed(socket_error_t code) IsSocketErrorClosed(socket_error_t code) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return code == WSAECONNRESET; return code == WSAECONNRESET;
...@@ -88,11 +88,7 @@ class SocketErrorMessage { ...@@ -88,11 +88,7 @@ class SocketErrorMessage {
#endif #endif
public: public:
#ifdef WIN32 explicit SocketErrorMessage(socket_error_t code=GetSocketError()) noexcept;
explicit SocketErrorMessage(socket_error_t code=GetSocketError());
#else
explicit SocketErrorMessage(socket_error_t code=GetSocketError());
#endif
operator const char *() const { operator const char *() const {
return msg; return msg;
...@@ -101,7 +97,7 @@ public: ...@@ -101,7 +97,7 @@ public:
gcc_const gcc_const
static inline std::system_error static inline std::system_error
MakeSocketError(socket_error_t code, const char *msg) MakeSocketError(socket_error_t code, const char *msg) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return MakeLastError(code, msg); return MakeLastError(code, msg);
...@@ -112,7 +108,7 @@ MakeSocketError(socket_error_t code, const char *msg) ...@@ -112,7 +108,7 @@ MakeSocketError(socket_error_t code, const char *msg)
gcc_pure gcc_pure
static inline std::system_error static inline std::system_error
MakeSocketError(const char *msg) MakeSocketError(const char *msg) noexcept
{ {
return MakeSocketError(GetSocketError(), msg); return MakeSocketError(GetSocketError(), msg);
} }
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <string.h> #include <string.h>
StaticSocketAddress & StaticSocketAddress &
StaticSocketAddress::operator=(SocketAddress other) StaticSocketAddress::operator=(SocketAddress other) noexcept
{ {
size = std::min(other.GetSize(), GetCapacity()); size = std::min(other.GetSize(), GetCapacity());
memcpy(&address, other.GetAddress(), size); memcpy(&address, other.GetAddress(), size);
......
...@@ -49,7 +49,7 @@ private: ...@@ -49,7 +49,7 @@ private:
public: public:
StaticSocketAddress() = default; StaticSocketAddress() = default;
StaticSocketAddress &operator=(SocketAddress other); StaticSocketAddress &operator=(SocketAddress other) noexcept;
operator SocketAddress() const { operator SocketAddress() const {
return SocketAddress(reinterpret_cast<const struct sockaddr *>(&address), return SocketAddress(reinterpret_cast<const struct sockaddr *>(&address),
......
/* /*
* Copyright (C) 2011-2015 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2011-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#ifdef HAVE_UN #ifdef HAVE_UN
static std::string static std::string
LocalAddressToString(const struct sockaddr_un &s_un, size_t size) LocalAddressToString(const struct sockaddr_un &s_un, size_t size) noexcept
{ {
const size_t prefix_size = (size_t) const size_t prefix_size = (size_t)
((struct sockaddr_un *)nullptr)->sun_path; ((struct sockaddr_un *)nullptr)->sun_path;
...@@ -83,7 +83,7 @@ LocalAddressToString(const struct sockaddr_un &s_un, size_t size) ...@@ -83,7 +83,7 @@ LocalAddressToString(const struct sockaddr_un &s_un, size_t size)
gcc_pure gcc_pure
static bool static bool
IsV4Mapped(SocketAddress address) IsV4Mapped(SocketAddress address) noexcept
{ {
if (address.GetFamily() != AF_INET6) if (address.GetFamily() != AF_INET6)
return false; return false;
...@@ -96,7 +96,7 @@ IsV4Mapped(SocketAddress address) ...@@ -96,7 +96,7 @@ IsV4Mapped(SocketAddress address)
* Convert "::ffff:127.0.0.1" to "127.0.0.1". * Convert "::ffff:127.0.0.1" to "127.0.0.1".
*/ */
static SocketAddress static SocketAddress
UnmapV4(SocketAddress src, struct sockaddr_in &buffer) UnmapV4(SocketAddress src, struct sockaddr_in &buffer) noexcept
{ {
assert(IsV4Mapped(src)); assert(IsV4Mapped(src));
...@@ -113,7 +113,7 @@ UnmapV4(SocketAddress src, struct sockaddr_in &buffer) ...@@ -113,7 +113,7 @@ UnmapV4(SocketAddress src, struct sockaddr_in &buffer)
#endif #endif
std::string std::string
ToString(SocketAddress address) ToString(SocketAddress address) noexcept
{ {
#ifdef HAVE_UN #ifdef HAVE_UN
if (address.GetFamily() == AF_UNIX) if (address.GetFamily() == AF_UNIX)
......
/* /*
* Copyright (C) 2011-2015 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2011-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -43,6 +43,6 @@ class SocketAddress; ...@@ -43,6 +43,6 @@ class SocketAddress;
*/ */
gcc_pure gcc_pure
std::string std::string
ToString(SocketAddress address); ToString(SocketAddress address) noexcept;
#endif #endif
...@@ -89,7 +89,7 @@ audio_output_detect() ...@@ -89,7 +89,7 @@ audio_output_detect()
*/ */
gcc_pure gcc_pure
static MixerType static MixerType
audio_output_mixer_type(const ConfigBlock &block) audio_output_mixer_type(const ConfigBlock &block) noexcept
{ {
/* read the local "mixer_type" setting */ /* read the local "mixer_type" setting */
const char *p = block.GetBlockValue("mixer_type"); const char *p = block.GetBlockValue("mixer_type");
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "Internal.hxx" #include "Internal.hxx"
bool bool
AudioOutput::IsChunkConsumed(const MusicChunk &chunk) const AudioOutput::IsChunkConsumed(const MusicChunk &chunk) const noexcept
{ {
if (!open) if (!open)
return true; return true;
......
...@@ -436,10 +436,10 @@ public: ...@@ -436,10 +436,10 @@ public:
* Caller must lock the mutex. * Caller must lock the mutex.
*/ */
gcc_pure gcc_pure
bool IsChunkConsumed(const MusicChunk &chunk) const; bool IsChunkConsumed(const MusicChunk &chunk) const noexcept;
gcc_pure gcc_pure
bool LockIsChunkConsumed(const MusicChunk &chunk) { bool LockIsChunkConsumed(const MusicChunk &chunk) noexcept {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
return IsChunkConsumed(chunk); return IsChunkConsumed(chunk);
} }
......
...@@ -94,7 +94,7 @@ MultipleOutputs::Configure(EventLoop &event_loop, ...@@ -94,7 +94,7 @@ MultipleOutputs::Configure(EventLoop &event_loop,
} }
AudioOutput * AudioOutput *
MultipleOutputs::FindByName(const char *name) const MultipleOutputs::FindByName(const char *name) const noexcept
{ {
for (auto i : outputs) for (auto i : outputs)
if (strcmp(i->GetName(), name) == 0) if (strcmp(i->GetName(), name) == 0)
...@@ -120,7 +120,7 @@ MultipleOutputs::EnableDisable() ...@@ -120,7 +120,7 @@ MultipleOutputs::EnableDisable()
} }
bool bool
MultipleOutputs::AllFinished() const MultipleOutputs::AllFinished() const noexcept
{ {
for (auto ao : outputs) { for (auto ao : outputs) {
const std::lock_guard<Mutex> protect(ao->mutex); const std::lock_guard<Mutex> protect(ao->mutex);
...@@ -132,7 +132,7 @@ MultipleOutputs::AllFinished() const ...@@ -132,7 +132,7 @@ MultipleOutputs::AllFinished() const
} }
void void
MultipleOutputs::WaitAll() MultipleOutputs::WaitAll() noexcept
{ {
while (!AllFinished()) while (!AllFinished())
audio_output_client_notify.Wait(); audio_output_client_notify.Wait();
...@@ -243,7 +243,7 @@ MultipleOutputs::Open(const AudioFormat audio_format, ...@@ -243,7 +243,7 @@ MultipleOutputs::Open(const AudioFormat audio_format,
} }
bool bool
MultipleOutputs::IsChunkConsumed(const MusicChunk *chunk) const MultipleOutputs::IsChunkConsumed(const MusicChunk *chunk) const noexcept
{ {
for (auto ao : outputs) for (auto ao : outputs)
if (!ao->LockIsChunkConsumed(*chunk)) if (!ao->LockIsChunkConsumed(*chunk))
......
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
* Returns nullptr if the name does not exist. * Returns nullptr if the name does not exist.
*/ */
gcc_pure gcc_pure
AudioOutput *FindByName(const char *name) const; AudioOutput *FindByName(const char *name) const noexcept;
/** /**
* Checks the "enabled" flag of all audio outputs, and if one has * Checks the "enabled" flag of all audio outputs, and if one has
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
* 0..100). Returns -1 if no mixer can be queried. * 0..100). Returns -1 if no mixer can be queried.
*/ */
gcc_pure gcc_pure
int GetVolume() const; int GetVolume() const noexcept;
/** /**
* Sets the volume on all available mixers. * Sets the volume on all available mixers.
...@@ -203,7 +203,7 @@ public: ...@@ -203,7 +203,7 @@ public:
* @param volume the volume (range 0..100) * @param volume the volume (range 0..100)
* @return true on success, false on failure * @return true on success, false on failure
*/ */
bool SetVolume(unsigned volume); bool SetVolume(unsigned volume) noexcept;
/** /**
* Similar to GetVolume(), but gets the volume only for * Similar to GetVolume(), but gets the volume only for
...@@ -211,7 +211,7 @@ public: ...@@ -211,7 +211,7 @@ public:
* function fails if no software mixer is configured. * function fails if no software mixer is configured.
*/ */
gcc_pure gcc_pure
int GetSoftwareVolume() const; int GetSoftwareVolume() const noexcept;
/** /**
* Similar to SetVolume(), but sets the volume only for * Similar to SetVolume(), but sets the volume only for
...@@ -219,7 +219,7 @@ public: ...@@ -219,7 +219,7 @@ public:
* function cannot fail, because the underlying software * function cannot fail, because the underlying software
* mixers cannot fail either. * mixers cannot fail either.
*/ */
void SetSoftwareVolume(unsigned volume); void SetSoftwareVolume(unsigned volume) noexcept;
private: private:
/** /**
...@@ -227,9 +227,9 @@ private: ...@@ -227,9 +227,9 @@ private:
* command. * command.
*/ */
gcc_pure gcc_pure
bool AllFinished() const; bool AllFinished() const noexcept;
void WaitAll(); void WaitAll() noexcept;
/** /**
* Signals all audio outputs which are open. * Signals all audio outputs which are open.
...@@ -247,7 +247,7 @@ private: ...@@ -247,7 +247,7 @@ private:
/** /**
* Has this chunk been consumed by all audio outputs? * Has this chunk been consumed by all audio outputs?
*/ */
bool IsChunkConsumed(const MusicChunk *chunk) const; bool IsChunkConsumed(const MusicChunk *chunk) const noexcept;
/** /**
* There's only one chunk left in the pipe (#pipe), and all * There's only one chunk left in the pipe (#pipe), and all
......
...@@ -64,7 +64,7 @@ ao_plugin_close(AudioOutput *ao) ...@@ -64,7 +64,7 @@ ao_plugin_close(AudioOutput *ao)
} }
std::chrono::steady_clock::duration std::chrono::steady_clock::duration
ao_plugin_delay(AudioOutput *ao) ao_plugin_delay(AudioOutput *ao) noexcept
{ {
return ao->plugin.delay != nullptr return ao->plugin.delay != nullptr
? ao->plugin.delay(ao) ? ao->plugin.delay(ao)
......
...@@ -101,7 +101,7 @@ struct AudioOutputPlugin { ...@@ -101,7 +101,7 @@ struct AudioOutputPlugin {
* *
* @return the duration to wait * @return the duration to wait
*/ */
std::chrono::steady_clock::duration (*delay)(AudioOutput *data); std::chrono::steady_clock::duration (*delay)(AudioOutput *data) noexcept;
/** /**
* Display metadata for the next chunk. Optional method, * Display metadata for the next chunk. Optional method,
...@@ -182,7 +182,7 @@ ao_plugin_close(AudioOutput *ao); ...@@ -182,7 +182,7 @@ ao_plugin_close(AudioOutput *ao);
gcc_pure gcc_pure
std::chrono::steady_clock::duration std::chrono::steady_clock::duration
ao_plugin_delay(AudioOutput *ao); ao_plugin_delay(AudioOutput *ao) noexcept;
void void
ao_plugin_send_tag(AudioOutput *ao, const Tag &tag); ao_plugin_send_tag(AudioOutput *ao, const Tag &tag);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "MusicPipe.hxx" #include "MusicPipe.hxx"
const MusicChunk * const MusicChunk *
SharedPipeConsumer::Get() SharedPipeConsumer::Get() noexcept
{ {
if (chunk != nullptr) { if (chunk != nullptr) {
if (!consumed) if (!consumed)
...@@ -42,7 +42,7 @@ SharedPipeConsumer::Get() ...@@ -42,7 +42,7 @@ SharedPipeConsumer::Get()
} }
bool bool
SharedPipeConsumer::IsConsumed(const MusicChunk &_chunk) const SharedPipeConsumer::IsConsumed(const MusicChunk &_chunk) const noexcept
{ {
if (chunk == nullptr) if (chunk == nullptr)
return false; return false;
......
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
chunk = nullptr; chunk = nullptr;
} }
const MusicChunk *Get(); const MusicChunk *Get() noexcept;
void Consume(gcc_unused const MusicChunk &_chunk) { void Consume(gcc_unused const MusicChunk &_chunk) {
assert(chunk != nullptr); assert(chunk != nullptr);
...@@ -85,9 +85,9 @@ public: ...@@ -85,9 +85,9 @@ public:
} }
gcc_pure gcc_pure
bool IsConsumed(const MusicChunk &_chunk) const; bool IsConsumed(const MusicChunk &_chunk) const noexcept;
void ClearTail(gcc_unused const MusicChunk &_chunk) { void ClearTail(gcc_unused const MusicChunk &_chunk) noexcept {
assert(chunk == &_chunk); assert(chunk == &_chunk);
assert(consumed); assert(consumed);
chunk = nullptr; chunk = nullptr;
......
...@@ -60,7 +60,7 @@ AudioOutputSource::Open(AudioFormat audio_format, const MusicPipe &_pipe, ...@@ -60,7 +60,7 @@ AudioOutputSource::Open(AudioFormat audio_format, const MusicPipe &_pipe,
} }
void void
AudioOutputSource::Close() AudioOutputSource::Close() noexcept
{ {
assert(in_audio_format.IsValid()); assert(in_audio_format.IsValid());
in_audio_format.Clear(); in_audio_format.Clear();
...@@ -71,7 +71,7 @@ AudioOutputSource::Close() ...@@ -71,7 +71,7 @@ AudioOutputSource::Close()
} }
void void
AudioOutputSource::Cancel() AudioOutputSource::Cancel() noexcept
{ {
current_chunk = nullptr; current_chunk = nullptr;
pipe.Cancel(); pipe.Cancel();
...@@ -114,7 +114,7 @@ try { ...@@ -114,7 +114,7 @@ try {
} }
void void
AudioOutputSource::CloseFilter() AudioOutputSource::CloseFilter() noexcept
{ {
delete replay_gain_filter_instance; delete replay_gain_filter_instance;
replay_gain_filter_instance = nullptr; replay_gain_filter_instance = nullptr;
......
...@@ -138,8 +138,8 @@ public: ...@@ -138,8 +138,8 @@ public:
PreparedFilter *prepared_other_replay_gain_filter, PreparedFilter *prepared_other_replay_gain_filter,
PreparedFilter *prepared_filter); PreparedFilter *prepared_filter);
void Close(); void Close() noexcept;
void Cancel(); void Cancel() noexcept;
/** /**
* Ensure that ReadTag() or PeekData() return any input. * Ensure that ReadTag() or PeekData() return any input.
...@@ -181,13 +181,13 @@ public: ...@@ -181,13 +181,13 @@ public:
*/ */
void ConsumeData(size_t nbytes) noexcept; void ConsumeData(size_t nbytes) noexcept;
bool IsChunkConsumed(const MusicChunk &chunk) const { bool IsChunkConsumed(const MusicChunk &chunk) const noexcept {
assert(IsOpen()); assert(IsOpen());
return pipe.IsConsumed(chunk); return pipe.IsConsumed(chunk);
} }
void ClearTailChunk(const MusicChunk &chunk) { void ClearTailChunk(const MusicChunk &chunk) noexcept {
pipe.ClearTail(chunk); pipe.ClearTail(chunk);
} }
...@@ -197,7 +197,7 @@ private: ...@@ -197,7 +197,7 @@ private:
PreparedFilter *prepared_other_replay_gain_filter, PreparedFilter *prepared_other_replay_gain_filter,
PreparedFilter *prepared_filter); PreparedFilter *prepared_filter);
void CloseFilter(); void CloseFilter() noexcept;
ConstBuffer<void> GetChunkData(const MusicChunk &chunk, ConstBuffer<void> GetChunkData(const MusicChunk &chunk,
Filter *replay_gain_filter, Filter *replay_gain_filter,
......
...@@ -63,7 +63,7 @@ struct AudioOutputWrapper { ...@@ -63,7 +63,7 @@ struct AudioOutputWrapper {
} }
gcc_pure gcc_pure
static std::chrono::steady_clock::duration Delay(AudioOutput *ao) { static std::chrono::steady_clock::duration Delay(AudioOutput *ao) noexcept {
T &t = Cast(*ao); T &t = Cast(*ao);
return t.Delay(); return t.Delay();
} }
......
...@@ -249,7 +249,7 @@ alsa_test_default_device() ...@@ -249,7 +249,7 @@ alsa_test_default_device()
*/ */
gcc_const gcc_const
static snd_pcm_format_t static snd_pcm_format_t
ToAlsaPcmFormat(SampleFormat sample_format) ToAlsaPcmFormat(SampleFormat sample_format) noexcept
{ {
switch (sample_format) { switch (sample_format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
...@@ -287,7 +287,7 @@ ToAlsaPcmFormat(SampleFormat sample_format) ...@@ -287,7 +287,7 @@ ToAlsaPcmFormat(SampleFormat sample_format)
* SND_PCM_FORMAT_UNKNOWN if the format cannot be byte-swapped. * SND_PCM_FORMAT_UNKNOWN if the format cannot be byte-swapped.
*/ */
static snd_pcm_format_t static snd_pcm_format_t
ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt) ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt) noexcept
{ {
switch (fmt) { switch (fmt) {
case SND_PCM_FORMAT_S16_LE: return SND_PCM_FORMAT_S16_BE; case SND_PCM_FORMAT_S16_LE: return SND_PCM_FORMAT_S16_BE;
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
void Open(AudioFormat &audio_format); void Open(AudioFormat &audio_format);
void Close(); void Close();
std::chrono::steady_clock::duration Delay() const; std::chrono::steady_clock::duration Delay() const noexcept;
size_t Play(const void *chunk, size_t size); size_t Play(const void *chunk, size_t size);
void Cancel(); void Cancel();
}; };
...@@ -205,7 +205,7 @@ FifoOutput::Cancel() ...@@ -205,7 +205,7 @@ FifoOutput::Cancel()
} }
inline std::chrono::steady_clock::duration inline std::chrono::steady_clock::duration
FifoOutput::Delay() const FifoOutput::Delay() const noexcept
{ {
return timer->IsStarted() return timer->IsStarted()
? timer->GetDelay() ? timer->GetDelay()
......
...@@ -119,7 +119,7 @@ struct JackOutput { ...@@ -119,7 +119,7 @@ struct JackOutput {
* on all channels. * on all channels.
*/ */
gcc_pure gcc_pure
jack_nframes_t GetAvailable() const; jack_nframes_t GetAvailable() const noexcept;
void Process(jack_nframes_t nframes); void Process(jack_nframes_t nframes);
...@@ -128,7 +128,7 @@ struct JackOutput { ...@@ -128,7 +128,7 @@ struct JackOutput {
*/ */
size_t WriteSamples(const float *src, size_t n_frames); size_t WriteSamples(const float *src, size_t n_frames);
std::chrono::steady_clock::duration Delay() const { std::chrono::steady_clock::duration Delay() const noexcept {
return base.pause && pause && !shutdown return base.pause && pause && !shutdown
? std::chrono::seconds(1) ? std::chrono::seconds(1)
: std::chrono::steady_clock::duration::zero(); : std::chrono::steady_clock::duration::zero();
...@@ -215,7 +215,7 @@ JackOutput::JackOutput(const ConfigBlock &block) ...@@ -215,7 +215,7 @@ JackOutput::JackOutput(const ConfigBlock &block)
} }
inline jack_nframes_t inline jack_nframes_t
JackOutput::GetAvailable() const JackOutput::GetAvailable() const noexcept
{ {
size_t min = jack_ringbuffer_read_space(ringbuffer[0]); size_t min = jack_ringbuffer_read_space(ringbuffer[0]);
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
delete timer; delete timer;
} }
std::chrono::steady_clock::duration Delay() const { std::chrono::steady_clock::duration Delay() const noexcept {
return sync && timer->IsStarted() return sync && timer->IsStarted()
? timer->GetDelay() ? timer->GetDelay()
: std::chrono::steady_clock::duration::zero(); : std::chrono::steady_clock::duration::zero();
......
...@@ -58,7 +58,7 @@ class OpenALOutput { ...@@ -58,7 +58,7 @@ class OpenALOutput {
void Close(); void Close();
gcc_pure gcc_pure
std::chrono::steady_clock::duration Delay() const { std::chrono::steady_clock::duration Delay() const noexcept {
return filled < NUM_BUFFERS || HasProcessed() return filled < NUM_BUFFERS || HasProcessed()
? std::chrono::steady_clock::duration::zero() ? std::chrono::steady_clock::duration::zero()
/* we don't know exactly how long we must wait /* we don't know exactly how long we must wait
......
...@@ -391,7 +391,7 @@ oss_setup_sample_rate(int fd, AudioFormat &audio_format) ...@@ -391,7 +391,7 @@ oss_setup_sample_rate(int fd, AudioFormat &audio_format)
*/ */
gcc_const gcc_const
static int static int
sample_format_to_oss(SampleFormat format) sample_format_to_oss(SampleFormat format) noexcept
{ {
switch (format) { switch (format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
...@@ -430,7 +430,7 @@ sample_format_to_oss(SampleFormat format) ...@@ -430,7 +430,7 @@ sample_format_to_oss(SampleFormat format)
*/ */
gcc_const gcc_const
static SampleFormat static SampleFormat
sample_format_from_oss(int format) sample_format_from_oss(int format) noexcept
{ {
switch (format) { switch (format) {
case AFMT_S8: case AFMT_S8:
......
...@@ -90,7 +90,6 @@ public: ...@@ -90,7 +90,6 @@ public:
Signal(); Signal();
} }
gcc_const
static bool TestDefaultDevice(); static bool TestDefaultDevice();
static PulseOutput *Create(const ConfigBlock &block); static PulseOutput *Create(const ConfigBlock &block);
......
...@@ -73,7 +73,7 @@ static constexpr Domain roar_output_domain("roar_output"); ...@@ -73,7 +73,7 @@ static constexpr Domain roar_output_domain("roar_output");
gcc_pure gcc_pure
static int static int
GetConfiguredRole(const ConfigBlock &block) GetConfiguredRole(const ConfigBlock &block) noexcept
{ {
const char *role = block.GetBlockValue("role"); const char *role = block.GetBlockValue("role");
return role != nullptr return role != nullptr
......
...@@ -63,7 +63,7 @@ struct ShoutOutput final { ...@@ -63,7 +63,7 @@ struct ShoutOutput final {
void Open(AudioFormat &audio_format); void Open(AudioFormat &audio_format);
void Close(); void Close();
std::chrono::steady_clock::duration Delay() const; std::chrono::steady_clock::duration Delay() const noexcept;
void SendTag(const Tag &tag); void SendTag(const Tag &tag);
size_t Play(const void *chunk, size_t size); size_t Play(const void *chunk, size_t size);
void Cancel(); void Cancel();
...@@ -361,7 +361,7 @@ ShoutOutput::Open(AudioFormat &audio_format) ...@@ -361,7 +361,7 @@ ShoutOutput::Open(AudioFormat &audio_format)
} }
std::chrono::steady_clock::duration std::chrono::steady_clock::duration
ShoutOutput::Delay() const ShoutOutput::Delay() const noexcept
{ {
int delay = shout_delay(shout_conn); int delay = shout_delay(shout_conn);
if (delay < 0) if (delay < 0)
......
...@@ -260,7 +260,7 @@ HttpdClient::TryWritePageN(const Page &page, size_t position, ssize_t n) ...@@ -260,7 +260,7 @@ HttpdClient::TryWritePageN(const Page &page, size_t position, ssize_t n)
} }
ssize_t ssize_t
HttpdClient::GetBytesTillMetaData() const HttpdClient::GetBytesTillMetaData() const noexcept
{ {
if (metadata_requested && if (metadata_requested &&
current_page->size - current_position > metaint - metadata_fill) current_page->size - current_position > metaint - metadata_fill)
......
...@@ -168,7 +168,7 @@ public: ...@@ -168,7 +168,7 @@ public:
bool SendResponse(); bool SendResponse();
gcc_pure gcc_pure
ssize_t GetBytesTillMetaData() const; ssize_t GetBytesTillMetaData() const noexcept;
ssize_t TryWritePage(const Page &page, size_t position); ssize_t TryWritePage(const Page &page, size_t position);
ssize_t TryWritePageN(const Page &page, size_t position, ssize_t n); ssize_t TryWritePageN(const Page &page, size_t position, ssize_t n);
......
...@@ -218,7 +218,7 @@ public: ...@@ -218,7 +218,7 @@ public:
void SendHeader(HttpdClient &client) const; void SendHeader(HttpdClient &client) const;
gcc_pure gcc_pure
std::chrono::steady_clock::duration Delay() const; std::chrono::steady_clock::duration Delay() const noexcept;
/** /**
* Reads data from the encoder (as much as available) and * Reads data from the encoder (as much as available) and
......
...@@ -345,7 +345,7 @@ HttpdOutput::SendHeader(HttpdClient &client) const ...@@ -345,7 +345,7 @@ HttpdOutput::SendHeader(HttpdClient &client) const
} }
inline std::chrono::steady_clock::duration inline std::chrono::steady_clock::duration
HttpdOutput::Delay() const HttpdOutput::Delay() const noexcept
{ {
if (!LockHasClients() && base.pause) { if (!LockHasClients() && base.pause) {
/* if there's no client and this output is paused, /* if there's no client and this output is paused,
...@@ -366,7 +366,7 @@ HttpdOutput::Delay() const ...@@ -366,7 +366,7 @@ HttpdOutput::Delay() const
} }
static std::chrono::steady_clock::duration static std::chrono::steady_clock::duration
httpd_output_delay(AudioOutput *ao) httpd_output_delay(AudioOutput *ao) noexcept
{ {
HttpdOutput *httpd = HttpdOutput::Cast(ao); HttpdOutput *httpd = HttpdOutput::Cast(ao);
......
...@@ -57,7 +57,7 @@ PcmChannelsConverter::Close() ...@@ -57,7 +57,7 @@ PcmChannelsConverter::Close()
} }
ConstBuffer<void> ConstBuffer<void>
PcmChannelsConverter::Convert(ConstBuffer<void> src) PcmChannelsConverter::Convert(ConstBuffer<void> src) noexcept
{ {
switch (format) { switch (format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
......
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
* @return the destination buffer * @return the destination buffer
*/ */
gcc_pure gcc_pure
ConstBuffer<void> Convert(ConstBuffer<void> src); ConstBuffer<void> Convert(ConstBuffer<void> src) noexcept;
}; };
#endif #endif
...@@ -37,7 +37,7 @@ struct FloatToIntegerSampleConvert { ...@@ -37,7 +37,7 @@ struct FloatToIntegerSampleConvert {
static constexpr SV factor = 1 << (DstTraits::BITS - 1); static constexpr SV factor = 1 << (DstTraits::BITS - 1);
gcc_const gcc_const
static DV Convert(SV src) { static DV Convert(SV src) noexcept {
return PcmClamp<F, Traits>(SL(src * factor)); return PcmClamp<F, Traits>(SL(src * factor));
} }
}; };
...@@ -56,7 +56,7 @@ struct IntegerToFloatSampleConvert { ...@@ -56,7 +56,7 @@ struct IntegerToFloatSampleConvert {
static constexpr DV factor = 0.5 / (1 << (SrcTraits::BITS - 2)); static constexpr DV factor = 0.5 / (1 << (SrcTraits::BITS - 2));
gcc_const gcc_const
static DV Convert(SV src) { static DV Convert(SV src) noexcept {
return DV(src) * factor; return DV(src) * factor;
} }
}; };
......
...@@ -54,7 +54,7 @@ PcmFormatConverter::Open(SampleFormat _src_format, SampleFormat _dest_format) ...@@ -54,7 +54,7 @@ PcmFormatConverter::Open(SampleFormat _src_format, SampleFormat _dest_format)
} }
void void
PcmFormatConverter::Close() PcmFormatConverter::Close() noexcept
{ {
#ifndef NDEBUG #ifndef NDEBUG
src_format = SampleFormat::UNDEFINED; src_format = SampleFormat::UNDEFINED;
...@@ -63,7 +63,7 @@ PcmFormatConverter::Close() ...@@ -63,7 +63,7 @@ PcmFormatConverter::Close()
} }
ConstBuffer<void> ConstBuffer<void>
PcmFormatConverter::Convert(ConstBuffer<void> src) PcmFormatConverter::Convert(ConstBuffer<void> src) noexcept
{ {
switch (dest_format) { switch (dest_format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
......
...@@ -65,18 +65,16 @@ public: ...@@ -65,18 +65,16 @@ public:
/** /**
* Closes the object. After that, you may call Open() again. * Closes the object. After that, you may call Open() again.
*/ */
void Close(); void Close() noexcept;
/** /**
* Convert a block of PCM data. * Convert a block of PCM data.
* *
* Throws std::runtime_error on error.
*
* @param src the input buffer * @param src the input buffer
* @return the destination buffer * @return the destination buffer
*/ */
gcc_pure gcc_pure
ConstBuffer<void> Convert(ConstBuffer<void> src); ConstBuffer<void> Convert(ConstBuffer<void> src) noexcept;
}; };
#endif #endif
...@@ -84,7 +84,7 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels, ...@@ -84,7 +84,7 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
} }
size_t size_t
PcmExport::GetFrameSize(const AudioFormat &audio_format) const PcmExport::GetFrameSize(const AudioFormat &audio_format) const noexcept
{ {
if (pack24) if (pack24)
/* packed 24 bit samples (3 bytes per sample) */ /* packed 24 bit samples (3 bytes per sample) */
...@@ -109,7 +109,7 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const ...@@ -109,7 +109,7 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const
} }
unsigned unsigned
PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const noexcept
{ {
#ifdef ENABLE_DSD #ifdef ENABLE_DSD
if (dsd_u16) if (dsd_u16)
...@@ -132,7 +132,7 @@ PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const ...@@ -132,7 +132,7 @@ PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const
} }
unsigned unsigned
PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const noexcept
{ {
#ifdef ENABLE_DSD #ifdef ENABLE_DSD
if (dsd_u16) if (dsd_u16)
...@@ -209,7 +209,7 @@ PcmExport::Export(ConstBuffer<void> data) ...@@ -209,7 +209,7 @@ PcmExport::Export(ConstBuffer<void> data)
} }
size_t size_t
PcmExport::CalcSourceSize(size_t size) const PcmExport::CalcSourceSize(size_t size) const noexcept
{ {
if (pack24) if (pack24)
/* 32 bit to 24 bit conversion (4 to 3 bytes) */ /* 32 bit to 24 bit conversion (4 to 3 bytes) */
......
...@@ -135,13 +135,13 @@ public: ...@@ -135,13 +135,13 @@ public:
* one output word (32 bits), dividing the sample rate by 4. * one output word (32 bits), dividing the sample rate by 4.
*/ */
gcc_pure gcc_pure
unsigned CalcOutputSampleRate(unsigned input_sample_rate) const; unsigned CalcOutputSampleRate(unsigned input_sample_rate) const noexcept;
/** /**
* The inverse of CalcOutputSampleRate(). * The inverse of CalcOutputSampleRate().
*/ */
gcc_pure gcc_pure
unsigned CalcInputSampleRate(unsigned output_sample_rate) const; unsigned CalcInputSampleRate(unsigned output_sample_rate) const noexcept;
}; };
/** /**
...@@ -167,7 +167,7 @@ public: ...@@ -167,7 +167,7 @@ public:
* Calculate the size of one output frame. * Calculate the size of one output frame.
*/ */
gcc_pure gcc_pure
size_t GetFrameSize(const AudioFormat &audio_format) const; size_t GetFrameSize(const AudioFormat &audio_format) const noexcept;
/** /**
* Export a PCM buffer. * Export a PCM buffer.
...@@ -183,7 +183,7 @@ public: ...@@ -183,7 +183,7 @@ public:
* pcm_export() source buffer. * pcm_export() source buffer.
*/ */
gcc_pure gcc_pure
size_t CalcSourceSize(size_t dest_size) const; size_t CalcSourceSize(size_t dest_size) const noexcept;
}; };
#endif #endif
...@@ -161,7 +161,7 @@ pcm_allocate_float_to_16(PcmBuffer &buffer, ConstBuffer<float> src) ...@@ -161,7 +161,7 @@ pcm_allocate_float_to_16(PcmBuffer &buffer, ConstBuffer<float> src)
ConstBuffer<int16_t> ConstBuffer<int16_t>
pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither, pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
SampleFormat src_format, ConstBuffer<void> src) SampleFormat src_format, ConstBuffer<void> src) noexcept
{ {
switch (src_format) { switch (src_format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
...@@ -229,7 +229,7 @@ pcm_allocate_float_to_24(PcmBuffer &buffer, ConstBuffer<float> src) ...@@ -229,7 +229,7 @@ pcm_allocate_float_to_24(PcmBuffer &buffer, ConstBuffer<float> src)
ConstBuffer<int32_t> ConstBuffer<int32_t>
pcm_convert_to_24(PcmBuffer &buffer, pcm_convert_to_24(PcmBuffer &buffer,
SampleFormat src_format, ConstBuffer<void> src) SampleFormat src_format, ConstBuffer<void> src) noexcept
{ {
switch (src_format) { switch (src_format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
...@@ -297,7 +297,7 @@ pcm_allocate_float_to_32(PcmBuffer &buffer, ConstBuffer<float> src) ...@@ -297,7 +297,7 @@ pcm_allocate_float_to_32(PcmBuffer &buffer, ConstBuffer<float> src)
ConstBuffer<int32_t> ConstBuffer<int32_t>
pcm_convert_to_32(PcmBuffer &buffer, pcm_convert_to_32(PcmBuffer &buffer,
SampleFormat src_format, ConstBuffer<void> src) SampleFormat src_format, ConstBuffer<void> src) noexcept
{ {
switch (src_format) { switch (src_format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
...@@ -365,7 +365,7 @@ pcm_allocate_32_to_float(PcmBuffer &buffer, ConstBuffer<int32_t> src) ...@@ -365,7 +365,7 @@ pcm_allocate_32_to_float(PcmBuffer &buffer, ConstBuffer<int32_t> src)
ConstBuffer<float> ConstBuffer<float>
pcm_convert_to_float(PcmBuffer &buffer, pcm_convert_to_float(PcmBuffer &buffer,
SampleFormat src_format, ConstBuffer<void> src) SampleFormat src_format, ConstBuffer<void> src) noexcept
{ {
switch (src_format) { switch (src_format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
......
...@@ -40,7 +40,7 @@ class PcmDither; ...@@ -40,7 +40,7 @@ class PcmDither;
gcc_pure gcc_pure
ConstBuffer<int16_t> ConstBuffer<int16_t>
pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither, pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
SampleFormat src_format, ConstBuffer<void> src); SampleFormat src_format, ConstBuffer<void> src) noexcept;
/** /**
* Converts PCM samples to 24 bit (32 bit alignment). * Converts PCM samples to 24 bit (32 bit alignment).
...@@ -52,7 +52,7 @@ pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither, ...@@ -52,7 +52,7 @@ pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
gcc_pure gcc_pure
ConstBuffer<int32_t> ConstBuffer<int32_t>
pcm_convert_to_24(PcmBuffer &buffer, pcm_convert_to_24(PcmBuffer &buffer,
SampleFormat src_format, ConstBuffer<void> src); SampleFormat src_format, ConstBuffer<void> src) noexcept;
/** /**
* Converts PCM samples to 32 bit. * Converts PCM samples to 32 bit.
...@@ -64,7 +64,7 @@ pcm_convert_to_24(PcmBuffer &buffer, ...@@ -64,7 +64,7 @@ pcm_convert_to_24(PcmBuffer &buffer,
gcc_pure gcc_pure
ConstBuffer<int32_t> ConstBuffer<int32_t>
pcm_convert_to_32(PcmBuffer &buffer, pcm_convert_to_32(PcmBuffer &buffer,
SampleFormat src_format, ConstBuffer<void> src); SampleFormat src_format, ConstBuffer<void> src) noexcept;
/** /**
* Converts PCM samples to 32 bit floating point. * Converts PCM samples to 32 bit floating point.
...@@ -76,6 +76,6 @@ pcm_convert_to_32(PcmBuffer &buffer, ...@@ -76,6 +76,6 @@ pcm_convert_to_32(PcmBuffer &buffer,
gcc_pure gcc_pure
ConstBuffer<float> ConstBuffer<float>
pcm_convert_to_float(PcmBuffer &buffer, pcm_convert_to_float(PcmBuffer &buffer,
SampleFormat src_format, ConstBuffer<void> src); SampleFormat src_format, ConstBuffer<void> src) noexcept;
#endif #endif
...@@ -36,7 +36,7 @@ template<SampleFormat F> struct SampleTraits; ...@@ -36,7 +36,7 @@ template<SampleFormat F> struct SampleTraits;
template<SampleFormat F, class Traits=SampleTraits<F>> template<SampleFormat F, class Traits=SampleTraits<F>>
gcc_const gcc_const
static inline typename Traits::value_type static inline typename Traits::value_type
PcmClamp(typename Traits::long_type x) PcmClamp(typename Traits::long_type x) noexcept
{ {
typedef typename Traits::value_type T; typedef typename Traits::value_type T;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <assert.h> #include <assert.h>
const char * const char *
sample_format_to_string(SampleFormat format) sample_format_to_string(SampleFormat format) noexcept
{ {
switch (format) { switch (format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:
......
...@@ -124,6 +124,6 @@ sample_format_size(SampleFormat format) ...@@ -124,6 +124,6 @@ sample_format_size(SampleFormat format)
*/ */
gcc_pure gcc_malloc gcc_pure gcc_malloc
const char * const char *
sample_format_to_string(SampleFormat format); sample_format_to_string(SampleFormat format) noexcept;
#endif #endif
...@@ -56,7 +56,7 @@ static constexpr struct { ...@@ -56,7 +56,7 @@ static constexpr struct {
gcc_const gcc_const
static const char * static const char *
soxr_quality_name(unsigned long recipe) soxr_quality_name(unsigned long recipe) noexcept
{ {
for (const auto *i = soxr_quality_table;; ++i) { for (const auto *i = soxr_quality_table;; ++i) {
assert(i->name != nullptr); assert(i->name != nullptr);
...@@ -68,7 +68,7 @@ soxr_quality_name(unsigned long recipe) ...@@ -68,7 +68,7 @@ soxr_quality_name(unsigned long recipe)
gcc_pure gcc_pure
static unsigned long static unsigned long
soxr_parse_quality(const char *quality) soxr_parse_quality(const char *quality) noexcept
{ {
if (quality == nullptr) if (quality == nullptr)
return SOXR_DEFAULT_RECIPE; return SOXR_DEFAULT_RECIPE;
......
...@@ -123,7 +123,7 @@ PcmVolume::Open(SampleFormat _format) ...@@ -123,7 +123,7 @@ PcmVolume::Open(SampleFormat _format)
} }
ConstBuffer<void> ConstBuffer<void>
PcmVolume::Apply(ConstBuffer<void> src) PcmVolume::Apply(ConstBuffer<void> src) noexcept
{ {
if (volume == PCM_VOLUME_1) if (volume == PCM_VOLUME_1)
return src; return src;
......
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
* Apply the volume level. * Apply the volume level.
*/ */
gcc_pure gcc_pure
ConstBuffer<void> Apply(ConstBuffer<void> src); ConstBuffer<void> Apply(ConstBuffer<void> src) noexcept;
}; };
#endif #endif
...@@ -151,7 +151,7 @@ PlayerControl::LockSetBorderPause(bool _border_pause) ...@@ -151,7 +151,7 @@ PlayerControl::LockSetBorderPause(bool _border_pause)
} }
player_status player_status
PlayerControl::LockGetStatus() PlayerControl::LockGetStatus() noexcept
{ {
player_status status; player_status status;
......
...@@ -317,7 +317,7 @@ private: ...@@ -317,7 +317,7 @@ private:
* To be called from the main thread. Caller must lock the * To be called from the main thread. Caller must lock the
* object. * object.
*/ */
void SynchronousCommand(PlayerCommand cmd) { void SynchronousCommand(PlayerCommand cmd) noexcept {
assert(command == PlayerCommand::NONE); assert(command == PlayerCommand::NONE);
command = cmd; command = cmd;
...@@ -332,7 +332,7 @@ private: ...@@ -332,7 +332,7 @@ private:
* To be called from the main thread. This method locks the * To be called from the main thread. This method locks the
* object. * object.
*/ */
void LockSynchronousCommand(PlayerCommand cmd) { void LockSynchronousCommand(PlayerCommand cmd) noexcept {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
SynchronousCommand(cmd); SynchronousCommand(cmd);
} }
...@@ -383,7 +383,7 @@ public: ...@@ -383,7 +383,7 @@ public:
void Kill(); void Kill();
gcc_pure gcc_pure
player_status LockGetStatus(); player_status LockGetStatus() noexcept;
PlayerState GetState() const { PlayerState GetState() const {
return state; return state;
......
...@@ -32,7 +32,7 @@ static constexpr Domain cross_fade_domain("cross_fade"); ...@@ -32,7 +32,7 @@ static constexpr Domain cross_fade_domain("cross_fade");
gcc_pure gcc_pure
static float static float
mixramp_interpolate(const char *ramp_list, float required_db) mixramp_interpolate(const char *ramp_list, float required_db) noexcept
{ {
float last_db = 0, last_secs = 0; float last_db = 0, last_secs = 0;
bool have_last = false; bool have_last = false;
...@@ -91,7 +91,7 @@ CrossFadeSettings::Calculate(SignedSongTime total_time, ...@@ -91,7 +91,7 @@ CrossFadeSettings::Calculate(SignedSongTime total_time,
const char *mixramp_start, const char *mixramp_prev_end, const char *mixramp_start, const char *mixramp_prev_end,
const AudioFormat af, const AudioFormat af,
const AudioFormat old_format, const AudioFormat old_format,
unsigned max_chunks) const unsigned max_chunks) const noexcept
{ {
unsigned int chunks = 0; unsigned int chunks = 0;
float chunks_f; float chunks_f;
......
...@@ -66,7 +66,7 @@ struct CrossFadeSettings { ...@@ -66,7 +66,7 @@ struct CrossFadeSettings {
const char *mixramp_start, const char *mixramp_start,
const char *mixramp_prev_end, const char *mixramp_prev_end,
AudioFormat af, AudioFormat old_format, AudioFormat af, AudioFormat old_format,
unsigned max_chunks) const; unsigned max_chunks) const noexcept;
}; };
#endif #endif
...@@ -107,7 +107,7 @@ cue_parse_rem(char *p, TagBuilder &tag) ...@@ -107,7 +107,7 @@ cue_parse_rem(char *p, TagBuilder &tag)
} }
TagBuilder * TagBuilder *
CueParser::GetCurrentTag() CueParser::GetCurrentTag() noexcept
{ {
if (state == HEADER) if (state == HEADER)
return &header_tag; return &header_tag;
...@@ -139,7 +139,7 @@ cue_parse_position(const char *p) ...@@ -139,7 +139,7 @@ cue_parse_position(const char *p)
} }
void void
CueParser::Commit() CueParser::Commit() noexcept
{ {
/* the caller of this library must call cue_parser_get() often /* the caller of this library must call cue_parser_get() often
enough */ enough */
...@@ -158,7 +158,7 @@ CueParser::Commit() ...@@ -158,7 +158,7 @@ CueParser::Commit()
} }
void void
CueParser::Feed2(char *p) CueParser::Feed2(char *p) noexcept
{ {
assert(!end); assert(!end);
assert(p != nullptr); assert(p != nullptr);
...@@ -260,7 +260,7 @@ CueParser::Feed2(char *p) ...@@ -260,7 +260,7 @@ CueParser::Feed2(char *p)
} }
void void
CueParser::Feed(const char *line) CueParser::Feed(const char *line) noexcept
{ {
assert(!end); assert(!end);
assert(line != nullptr); assert(line != nullptr);
...@@ -271,7 +271,7 @@ CueParser::Feed(const char *line) ...@@ -271,7 +271,7 @@ CueParser::Feed(const char *line)
} }
void void
CueParser::Finish() CueParser::Finish() noexcept
{ {
if (end) if (end)
/* has already been called, ignore */ /* has already been called, ignore */
...@@ -282,7 +282,7 @@ CueParser::Finish() ...@@ -282,7 +282,7 @@ CueParser::Finish()
} }
std::unique_ptr<DetachedSong> std::unique_ptr<DetachedSong>
CueParser::Get() CueParser::Get() noexcept
{ {
if (finished == nullptr && end) { if (finished == nullptr && end) {
/* cue_parser_finish() has been called already: /* cue_parser_finish() has been called already:
......
...@@ -98,14 +98,14 @@ public: ...@@ -98,14 +98,14 @@ public:
* Feed a text line from the CUE file into the parser. Call * Feed a text line from the CUE file into the parser. Call
* Get() after this to see if a song has been finished. * Get() after this to see if a song has been finished.
*/ */
void Feed(const char *line); void Feed(const char *line) noexcept;
/** /**
* Tell the parser that the end of the file has been reached. Call * Tell the parser that the end of the file has been reached. Call
* Get() after this to see if a song has been finished. * Get() after this to see if a song has been finished.
* This procedure must be done twice! * This procedure must be done twice!
*/ */
void Finish(); void Finish() noexcept;
/** /**
* Check if a song was finished by the last Feed() or Finish() * Check if a song was finished by the last Feed() or Finish()
...@@ -114,20 +114,20 @@ public: ...@@ -114,20 +114,20 @@ public:
* @return a song object that must be freed by the caller, or NULL if * @return a song object that must be freed by the caller, or NULL if
* no song was finished at this time * no song was finished at this time
*/ */
std::unique_ptr<DetachedSong> Get(); std::unique_ptr<DetachedSong> Get() noexcept;
private: private:
gcc_pure gcc_pure
TagBuilder *GetCurrentTag(); TagBuilder *GetCurrentTag() noexcept;
/** /**
* Commit the current song. It will be moved to "previous", * Commit the current song. It will be moved to "previous",
* so the next song may soon edit its end time (using the next * so the next song may soon edit its end time (using the next
* song's start time). * song's start time).
*/ */
void Commit(); void Commit() noexcept;
void Feed2(char *p); void Feed2(char *p) noexcept;
}; };
#endif #endif
...@@ -92,7 +92,7 @@ playlist::QueuedSongStarted(PlayerControl &pc) ...@@ -92,7 +92,7 @@ playlist::QueuedSongStarted(PlayerControl &pc)
} }
const DetachedSong * const DetachedSong *
playlist::GetQueuedSong() const playlist::GetQueuedSong() const noexcept
{ {
return playing && queued >= 0 return playing && queued >= 0
? &queue.GetOrder(queued) ? &queue.GetOrder(queued)
...@@ -323,7 +323,7 @@ playlist::SetRandom(PlayerControl &pc, bool status) ...@@ -323,7 +323,7 @@ playlist::SetRandom(PlayerControl &pc, bool status)
} }
int int
playlist::GetCurrentPosition() const playlist::GetCurrentPosition() const noexcept
{ {
return current >= 0 return current >= 0
? queue.OrderToPosition(current) ? queue.OrderToPosition(current)
...@@ -331,7 +331,7 @@ playlist::GetCurrentPosition() const ...@@ -331,7 +331,7 @@ playlist::GetCurrentPosition() const
} }
int int
playlist::GetNextPosition() const playlist::GetNextPosition() const noexcept
{ {
if (current < 0) if (current < 0)
return -1; return -1;
......
...@@ -113,17 +113,17 @@ struct playlist { ...@@ -113,17 +113,17 @@ struct playlist {
} }
gcc_pure gcc_pure
int GetCurrentPosition() const; int GetCurrentPosition() const noexcept;
gcc_pure gcc_pure
int GetNextPosition() const; int GetNextPosition() const noexcept;
/** /**
* Returns the song object which is currently queued. Returns * Returns the song object which is currently queued. Returns
* none if there is none (yet?) or if MPD isn't playing. * none if there is none (yet?) or if MPD isn't playing.
*/ */
gcc_pure gcc_pure
const DetachedSong *GetQueuedSong() const; const DetachedSong *GetQueuedSong() const noexcept;
/** /**
* This is the "PLAYLIST" event handler. It is invoked by the * This is the "PLAYLIST" event handler. It is invoked by the
......
...@@ -43,7 +43,7 @@ Queue::~Queue() ...@@ -43,7 +43,7 @@ Queue::~Queue()
} }
int int
Queue::GetNextOrder(unsigned _order) const Queue::GetNextOrder(unsigned _order) const noexcept
{ {
assert(_order < length); assert(_order < length);
...@@ -60,7 +60,7 @@ Queue::GetNextOrder(unsigned _order) const ...@@ -60,7 +60,7 @@ Queue::GetNextOrder(unsigned _order) const
} }
void void
Queue::IncrementVersion() Queue::IncrementVersion() noexcept
{ {
static unsigned long max = ((uint32_t) 1 << 31) - 1; static unsigned long max = ((uint32_t) 1 << 31) - 1;
...@@ -75,7 +75,7 @@ Queue::IncrementVersion() ...@@ -75,7 +75,7 @@ Queue::IncrementVersion()
} }
void void
Queue::ModifyAtOrder(unsigned _order) Queue::ModifyAtOrder(unsigned _order) noexcept
{ {
assert(_order < length); assert(_order < length);
...@@ -103,7 +103,7 @@ Queue::Append(DetachedSong &&song, uint8_t priority) ...@@ -103,7 +103,7 @@ Queue::Append(DetachedSong &&song, uint8_t priority)
} }
void void
Queue::SwapPositions(unsigned position1, unsigned position2) Queue::SwapPositions(unsigned position1, unsigned position2) noexcept
{ {
unsigned id1 = items[position1].id; unsigned id1 = items[position1].id;
unsigned id2 = items[position2].id; unsigned id2 = items[position2].id;
...@@ -118,7 +118,7 @@ Queue::SwapPositions(unsigned position1, unsigned position2) ...@@ -118,7 +118,7 @@ Queue::SwapPositions(unsigned position1, unsigned position2)
} }
void void
Queue::MovePostion(unsigned from, unsigned to) Queue::MovePostion(unsigned from, unsigned to) noexcept
{ {
const Item tmp = items[from]; const Item tmp = items[from];
...@@ -154,7 +154,7 @@ Queue::MovePostion(unsigned from, unsigned to) ...@@ -154,7 +154,7 @@ Queue::MovePostion(unsigned from, unsigned to)
} }
void void
Queue::MoveRange(unsigned start, unsigned end, unsigned to) Queue::MoveRange(unsigned start, unsigned end, unsigned to) noexcept
{ {
Item tmp[end - start]; Item tmp[end - start];
// Copy the original block [start,end-1] // Copy the original block [start,end-1]
...@@ -196,7 +196,7 @@ Queue::MoveRange(unsigned start, unsigned end, unsigned to) ...@@ -196,7 +196,7 @@ Queue::MoveRange(unsigned start, unsigned end, unsigned to)
} }
void void
Queue::MoveOrder(unsigned from_order, unsigned to_order) Queue::MoveOrder(unsigned from_order, unsigned to_order) noexcept
{ {
assert(from_order < length); assert(from_order < length);
assert(to_order <= length); assert(to_order <= length);
...@@ -215,7 +215,7 @@ Queue::MoveOrder(unsigned from_order, unsigned to_order) ...@@ -215,7 +215,7 @@ Queue::MoveOrder(unsigned from_order, unsigned to_order)
} }
void void
Queue::DeletePosition(unsigned position) Queue::DeletePosition(unsigned position) noexcept
{ {
assert(position < length); assert(position < length);
...@@ -248,7 +248,7 @@ Queue::DeletePosition(unsigned position) ...@@ -248,7 +248,7 @@ Queue::DeletePosition(unsigned position)
} }
void void
Queue::Clear() Queue::Clear() noexcept
{ {
for (unsigned i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
Item *item = &items[i]; Item *item = &items[i];
...@@ -262,7 +262,8 @@ Queue::Clear() ...@@ -262,7 +262,8 @@ Queue::Clear()
} }
static void static void
queue_sort_order_by_priority(Queue *queue, unsigned start, unsigned end) queue_sort_order_by_priority(Queue *queue,
unsigned start, unsigned end) noexcept
{ {
assert(queue != nullptr); assert(queue != nullptr);
assert(queue->random); assert(queue->random);
...@@ -370,7 +371,7 @@ Queue::ShuffleRange(unsigned start, unsigned end) ...@@ -370,7 +371,7 @@ Queue::ShuffleRange(unsigned start, unsigned end)
unsigned unsigned
Queue::FindPriorityOrder(unsigned start_order, uint8_t priority, Queue::FindPriorityOrder(unsigned start_order, uint8_t priority,
unsigned exclude_order) const unsigned exclude_order) const noexcept
{ {
assert(random); assert(random);
assert(start_order <= length); assert(start_order <= length);
...@@ -386,7 +387,7 @@ Queue::FindPriorityOrder(unsigned start_order, uint8_t priority, ...@@ -386,7 +387,7 @@ Queue::FindPriorityOrder(unsigned start_order, uint8_t priority,
} }
unsigned unsigned
Queue::CountSamePriority(unsigned start_order, uint8_t priority) const Queue::CountSamePriority(unsigned start_order, uint8_t priority) const noexcept
{ {
assert(random); assert(random);
assert(start_order <= length); assert(start_order <= length);
......
...@@ -232,13 +232,13 @@ struct Queue { ...@@ -232,13 +232,13 @@ struct Queue {
* @return the next order number, or -1 to stop playback * @return the next order number, or -1 to stop playback
*/ */
gcc_pure gcc_pure
int GetNextOrder(unsigned order) const; int GetNextOrder(unsigned order) const noexcept;
/** /**
* Increments the queue's version number. This handles integer * Increments the queue's version number. This handles integer
* overflow well. * overflow well.
*/ */
void IncrementVersion(); void IncrementVersion() noexcept;
/** /**
* Marks the specified song as "modified". Call * Marks the specified song as "modified". Call
...@@ -256,7 +256,7 @@ struct Queue { ...@@ -256,7 +256,7 @@ struct Queue {
* IncrementVersion() after all modifications have been made. * IncrementVersion() after all modifications have been made.
* number. * number.
*/ */
void ModifyAtOrder(unsigned order); void ModifyAtOrder(unsigned order) noexcept;
/** /**
* Appends a song to the queue and returns its position. Prior to * Appends a song to the queue and returns its position. Prior to
...@@ -273,7 +273,7 @@ struct Queue { ...@@ -273,7 +273,7 @@ struct Queue {
/** /**
* Swaps two songs, addressed by their position. * Swaps two songs, addressed by their position.
*/ */
void SwapPositions(unsigned position1, unsigned position2); void SwapPositions(unsigned position1, unsigned position2) noexcept;
/** /**
* Swaps two songs, addressed by their order number. * Swaps two songs, addressed by their order number.
...@@ -285,27 +285,27 @@ struct Queue { ...@@ -285,27 +285,27 @@ struct Queue {
/** /**
* Moves a song to a new position in the "order" list. * Moves a song to a new position in the "order" list.
*/ */
void MoveOrder(unsigned from_order, unsigned to_order); void MoveOrder(unsigned from_order, unsigned to_order) noexcept;
/** /**
* Moves a song to a new position. * Moves a song to a new position.
*/ */
void MovePostion(unsigned from, unsigned to); void MovePostion(unsigned from, unsigned to) noexcept;
/** /**
* Moves a range of songs to a new position. * Moves a range of songs to a new position.
*/ */
void MoveRange(unsigned start, unsigned end, unsigned to); void MoveRange(unsigned start, unsigned end, unsigned to) noexcept;
/** /**
* Removes a song from the playlist. * Removes a song from the playlist.
*/ */
void DeletePosition(unsigned position); void DeletePosition(unsigned position) noexcept;
/** /**
* Removes all songs from the playlist. * Removes all songs from the playlist.
*/ */
void Clear(); void Clear() noexcept;
/** /**
* Initializes the "order" array, and restores "normal" order. * Initializes the "order" array, and restores "normal" order.
...@@ -369,11 +369,11 @@ private: ...@@ -369,11 +369,11 @@ private:
*/ */
gcc_pure gcc_pure
unsigned FindPriorityOrder(unsigned start_order, uint8_t priority, unsigned FindPriorityOrder(unsigned start_order, uint8_t priority,
unsigned exclude_order) const; unsigned exclude_order) const noexcept;
gcc_pure gcc_pure
unsigned CountSamePriority(unsigned start_order, unsigned CountSamePriority(unsigned start_order,
uint8_t priority) const; uint8_t priority) const noexcept;
}; };
#endif #endif
...@@ -151,7 +151,7 @@ sticker_global_finish() ...@@ -151,7 +151,7 @@ sticker_global_finish()
} }
bool bool
sticker_enabled() sticker_enabled() noexcept
{ {
return sticker_db != nullptr; return sticker_db != nullptr;
} }
...@@ -328,7 +328,7 @@ sticker_free(Sticker *sticker) ...@@ -328,7 +328,7 @@ sticker_free(Sticker *sticker)
} }
const char * const char *
sticker_get_value(const Sticker &sticker, const char *name) sticker_get_value(const Sticker &sticker, const char *name) noexcept
{ {
auto i = sticker.table.find(name); auto i = sticker.table.find(name);
if (i == sticker.table.end()) if (i == sticker.table.end())
......
...@@ -69,7 +69,7 @@ sticker_global_finish(); ...@@ -69,7 +69,7 @@ sticker_global_finish();
*/ */
gcc_const gcc_const
bool bool
sticker_enabled(); sticker_enabled() noexcept;
/** /**
* Returns one value from an object's sticker record. Returns an * Returns one value from an object's sticker record. Returns an
...@@ -125,7 +125,7 @@ sticker_free(Sticker *sticker); ...@@ -125,7 +125,7 @@ sticker_free(Sticker *sticker);
*/ */
gcc_pure gcc_pure
const char * const char *
sticker_get_value(const Sticker &sticker, const char *name); sticker_get_value(const Sticker &sticker, const char *name) noexcept;
/** /**
* Iterates over all sticker items in a sticker. * Iterates over all sticker items in a sticker.
......
...@@ -114,7 +114,7 @@ CompositeStorage::Directory::~Directory() ...@@ -114,7 +114,7 @@ CompositeStorage::Directory::~Directory()
} }
const CompositeStorage::Directory * const CompositeStorage::Directory *
CompositeStorage::Directory::Find(const char *uri) const CompositeStorage::Directory::Find(const char *uri) const noexcept
{ {
const Directory *directory = this; const Directory *directory = this;
while (*uri != 0) { while (*uri != 0) {
...@@ -180,7 +180,7 @@ CompositeStorage::Directory::Unmount(const char *uri) ...@@ -180,7 +180,7 @@ CompositeStorage::Directory::Unmount(const char *uri)
bool bool
CompositeStorage::Directory::MapToRelativeUTF8(std::string &buffer, CompositeStorage::Directory::MapToRelativeUTF8(std::string &buffer,
const char *uri) const const char *uri) const noexcept
{ {
if (storage != nullptr) { if (storage != nullptr) {
const char *result = storage->MapToRelativeUTF8(uri); const char *result = storage->MapToRelativeUTF8(uri);
...@@ -202,7 +202,7 @@ CompositeStorage::Directory::MapToRelativeUTF8(std::string &buffer, ...@@ -202,7 +202,7 @@ CompositeStorage::Directory::MapToRelativeUTF8(std::string &buffer,
return false; return false;
} }
CompositeStorage::CompositeStorage() CompositeStorage::CompositeStorage() noexcept
{ {
} }
...@@ -211,7 +211,7 @@ CompositeStorage::~CompositeStorage() ...@@ -211,7 +211,7 @@ CompositeStorage::~CompositeStorage()
} }
Storage * Storage *
CompositeStorage::GetMount(const char *uri) CompositeStorage::GetMount(const char *uri) noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
...@@ -243,7 +243,7 @@ CompositeStorage::Unmount(const char *uri) ...@@ -243,7 +243,7 @@ CompositeStorage::Unmount(const char *uri)
} }
CompositeStorage::FindResult CompositeStorage::FindResult
CompositeStorage::FindStorage(const char *uri) const CompositeStorage::FindStorage(const char *uri) const noexcept
{ {
FindResult result{&root, uri}; FindResult result{&root, uri};
...@@ -322,7 +322,7 @@ CompositeStorage::OpenDirectory(const char *uri) ...@@ -322,7 +322,7 @@ CompositeStorage::OpenDirectory(const char *uri)
} }
std::string std::string
CompositeStorage::MapUTF8(const char *uri) const CompositeStorage::MapUTF8(const char *uri) const noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
...@@ -334,7 +334,7 @@ CompositeStorage::MapUTF8(const char *uri) const ...@@ -334,7 +334,7 @@ CompositeStorage::MapUTF8(const char *uri) const
} }
AllocatedPath AllocatedPath
CompositeStorage::MapFS(const char *uri) const CompositeStorage::MapFS(const char *uri) const noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
...@@ -346,7 +346,7 @@ CompositeStorage::MapFS(const char *uri) const ...@@ -346,7 +346,7 @@ CompositeStorage::MapFS(const char *uri) const
} }
const char * const char *
CompositeStorage::MapToRelativeUTF8(const char *uri) const CompositeStorage::MapToRelativeUTF8(const char *uri) const noexcept
{ {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
......
...@@ -60,7 +60,7 @@ class CompositeStorage final : public Storage { ...@@ -60,7 +60,7 @@ class CompositeStorage final : public Storage {
} }
gcc_pure gcc_pure
const Directory *Find(const char *uri) const; const Directory *Find(const char *uri) const noexcept;
Directory &Make(const char *uri); Directory &Make(const char *uri);
...@@ -69,7 +69,7 @@ class CompositeStorage final : public Storage { ...@@ -69,7 +69,7 @@ class CompositeStorage final : public Storage {
gcc_pure gcc_pure
bool MapToRelativeUTF8(std::string &buffer, bool MapToRelativeUTF8(std::string &buffer,
const char *uri) const; const char *uri) const noexcept;
}; };
struct FindResult { struct FindResult {
...@@ -89,7 +89,7 @@ class CompositeStorage final : public Storage { ...@@ -89,7 +89,7 @@ class CompositeStorage final : public Storage {
mutable std::string relative_buffer; mutable std::string relative_buffer;
public: public:
CompositeStorage(); CompositeStorage() noexcept;
virtual ~CompositeStorage(); virtual ~CompositeStorage();
/** /**
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
* value is being used. * value is being used.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
Storage *GetMount(const char *uri); Storage *GetMount(const char *uri) noexcept;
/** /**
* Call the given function for each mounted storage, including * Call the given function for each mounted storage, including
...@@ -123,11 +123,11 @@ public: ...@@ -123,11 +123,11 @@ public:
StorageDirectoryReader *OpenDirectory(const char *uri) override; StorageDirectoryReader *OpenDirectory(const char *uri) override;
std::string MapUTF8(const char *uri) const override; std::string MapUTF8(const char *uri) const noexcept override;
AllocatedPath MapFS(const char *uri) const override; AllocatedPath MapFS(const char *uri) const noexcept override;
const char *MapToRelativeUTF8(const char *uri) const override; const char *MapToRelativeUTF8(const char *uri) const noexcept override;
private: private:
template<typename T> template<typename T>
...@@ -159,7 +159,7 @@ private: ...@@ -159,7 +159,7 @@ private:
* the URI was used). * the URI was used).
*/ */
gcc_pure gcc_pure
FindResult FindStorage(const char *uri) const; FindResult FindStorage(const char *uri) const noexcept;
const char *MapToRelativeUTF8(const Directory &directory, const char *MapToRelativeUTF8(const Directory &directory,
const char *uri) const; const char *uri) const;
......
...@@ -73,7 +73,7 @@ CreateConfiguredStorage(EventLoop &event_loop) ...@@ -73,7 +73,7 @@ CreateConfiguredStorage(EventLoop &event_loop)
} }
bool bool
IsStorageConfigured() IsStorageConfigured() noexcept
{ {
return config_get_string(ConfigOption::MUSIC_DIR) != nullptr; return config_get_string(ConfigOption::MUSIC_DIR) != nullptr;
} }
...@@ -40,6 +40,6 @@ CreateConfiguredStorage(EventLoop &event_loop); ...@@ -40,6 +40,6 @@ CreateConfiguredStorage(EventLoop &event_loop);
*/ */
gcc_const gcc_const
bool bool
IsStorageConfigured(); IsStorageConfigured() noexcept;
#endif #endif
...@@ -43,7 +43,7 @@ const StoragePlugin *const storage_plugins[] = { ...@@ -43,7 +43,7 @@ const StoragePlugin *const storage_plugins[] = {
}; };
const StoragePlugin * const StoragePlugin *
GetStoragePluginByName(const char *name) GetStoragePluginByName(const char *name) noexcept
{ {
for (auto i = storage_plugins; *i != nullptr; ++i) { for (auto i = storage_plugins; *i != nullptr; ++i) {
const StoragePlugin &plugin = **i; const StoragePlugin &plugin = **i;
......
...@@ -35,7 +35,7 @@ extern const StoragePlugin *const storage_plugins[]; ...@@ -35,7 +35,7 @@ extern const StoragePlugin *const storage_plugins[];
gcc_nonnull_all gcc_pure gcc_nonnull_all gcc_pure
const StoragePlugin * const StoragePlugin *
GetStoragePluginByName(const char *name); GetStoragePluginByName(const char *name) noexcept;
gcc_nonnull_all gcc_malloc gcc_nonnull_all gcc_malloc
Storage * Storage *
......
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
#include "fs/Traits.hxx" #include "fs/Traits.hxx"
AllocatedPath AllocatedPath
Storage::MapFS(gcc_unused const char *uri_utf8) const Storage::MapFS(gcc_unused const char *uri_utf8) const noexcept
{ {
return AllocatedPath::Null(); return AllocatedPath::Null();
} }
AllocatedPath AllocatedPath
Storage::MapChildFS(const char *uri_utf8, Storage::MapChildFS(const char *uri_utf8,
const char *child_utf8) const const char *child_utf8) const noexcept
{ {
const auto uri2 = PathTraitsUTF8::Build(uri_utf8, child_utf8); const auto uri2 = PathTraitsUTF8::Build(uri_utf8, child_utf8);
return MapFS(uri2.c_str()); return MapFS(uri2.c_str());
......
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
* Map the given relative URI to an absolute URI. * Map the given relative URI to an absolute URI.
*/ */
gcc_pure gcc_pure
virtual std::string MapUTF8(const char *uri_utf8) const = 0; virtual std::string MapUTF8(const char *uri_utf8) const noexcept = 0;
/** /**
* Map the given relative URI to a local file path. Returns * Map the given relative URI to a local file path. Returns
...@@ -72,11 +72,11 @@ public: ...@@ -72,11 +72,11 @@ public:
* support local files. * support local files.
*/ */
gcc_pure gcc_pure
virtual AllocatedPath MapFS(const char *uri_utf8) const; virtual AllocatedPath MapFS(const char *uri_utf8) const noexcept;
gcc_pure gcc_pure
AllocatedPath MapChildFS(const char *uri_utf8, AllocatedPath MapChildFS(const char *uri_utf8,
const char *child_utf8) const; const char *child_utf8) const noexcept;
/** /**
* Check if the given URI points inside this storage. If yes, * Check if the given URI points inside this storage. If yes,
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
* string); if not, returns nullptr. * string); if not, returns nullptr.
*/ */
gcc_pure gcc_pure
virtual const char *MapToRelativeUTF8(const char *uri_utf8) const = 0; virtual const char *MapToRelativeUTF8(const char *uri_utf8) const noexcept = 0;
}; };
#endif #endif
...@@ -64,13 +64,13 @@ public: ...@@ -64,13 +64,13 @@ public:
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override; StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
std::string MapUTF8(const char *uri_utf8) const override; std::string MapUTF8(const char *uri_utf8) const noexcept override;
const char *MapToRelativeUTF8(const char *uri_utf8) const override; const char *MapToRelativeUTF8(const char *uri_utf8) const noexcept override;
}; };
std::string std::string
CurlStorage::MapUTF8(const char *uri_utf8) const CurlStorage::MapUTF8(const char *uri_utf8) const noexcept
{ {
assert(uri_utf8 != nullptr); assert(uri_utf8 != nullptr);
...@@ -83,7 +83,7 @@ CurlStorage::MapUTF8(const char *uri_utf8) const ...@@ -83,7 +83,7 @@ CurlStorage::MapUTF8(const char *uri_utf8) const
} }
const char * const char *
CurlStorage::MapToRelativeUTF8(const char *uri_utf8) const CurlStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{ {
// TODO: escape/unescape? // TODO: escape/unescape?
...@@ -475,7 +475,7 @@ CurlStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow) ...@@ -475,7 +475,7 @@ CurlStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow)
gcc_pure gcc_pure
static const char * static const char *
UriPathOrSlash(const char *uri) UriPathOrSlash(const char *uri) noexcept
{ {
const char *path = uri_get_path(uri); const char *path = uri_get_path(uri);
if (path == nullptr) if (path == nullptr)
......
...@@ -61,11 +61,11 @@ public: ...@@ -61,11 +61,11 @@ public:
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override; StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
std::string MapUTF8(const char *uri_utf8) const override; std::string MapUTF8(const char *uri_utf8) const noexcept override;
AllocatedPath MapFS(const char *uri_utf8) const override; AllocatedPath MapFS(const char *uri_utf8) const noexcept override;
const char *MapToRelativeUTF8(const char *uri_utf8) const override; const char *MapToRelativeUTF8(const char *uri_utf8) const noexcept override;
private: private:
AllocatedPath MapFSOrThrow(const char *uri_utf8) const; AllocatedPath MapFSOrThrow(const char *uri_utf8) const;
...@@ -97,7 +97,7 @@ Stat(Path path, bool follow) ...@@ -97,7 +97,7 @@ Stat(Path path, bool follow)
} }
std::string std::string
LocalStorage::MapUTF8(const char *uri_utf8) const LocalStorage::MapUTF8(const char *uri_utf8) const noexcept
{ {
assert(uri_utf8 != nullptr); assert(uri_utf8 != nullptr);
...@@ -120,7 +120,7 @@ LocalStorage::MapFSOrThrow(const char *uri_utf8) const ...@@ -120,7 +120,7 @@ LocalStorage::MapFSOrThrow(const char *uri_utf8) const
} }
AllocatedPath AllocatedPath
LocalStorage::MapFS(const char *uri_utf8) const LocalStorage::MapFS(const char *uri_utf8) const noexcept
{ {
try { try {
return MapFSOrThrow(uri_utf8); return MapFSOrThrow(uri_utf8);
...@@ -130,7 +130,7 @@ LocalStorage::MapFS(const char *uri_utf8) const ...@@ -130,7 +130,7 @@ LocalStorage::MapFS(const char *uri_utf8) const
} }
const char * const char *
LocalStorage::MapToRelativeUTF8(const char *uri_utf8) const LocalStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{ {
return PathTraitsUTF8::Relative(base_utf8.c_str(), uri_utf8); return PathTraitsUTF8::Relative(base_utf8.c_str(), uri_utf8);
} }
...@@ -149,7 +149,7 @@ LocalStorage::OpenDirectory(const char *uri_utf8) ...@@ -149,7 +149,7 @@ LocalStorage::OpenDirectory(const char *uri_utf8)
gcc_pure gcc_pure
static bool static bool
SkipNameFS(PathTraitsFS::const_pointer_type name_fs) SkipNameFS(PathTraitsFS::const_pointer_type name_fs) noexcept
{ {
return name_fs[0] == '.' && return name_fs[0] == '.' &&
(name_fs[1] == 0 || (name_fs[1] == 0 ||
......
...@@ -87,9 +87,9 @@ public: ...@@ -87,9 +87,9 @@ public:
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override; StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
std::string MapUTF8(const char *uri_utf8) const override; std::string MapUTF8(const char *uri_utf8) const noexcept override;
const char *MapToRelativeUTF8(const char *uri_utf8) const override; const char *MapToRelativeUTF8(const char *uri_utf8) const noexcept override;
/* virtual methods from NfsLease */ /* virtual methods from NfsLease */
void OnNfsConnectionReady() final { void OnNfsConnectionReady() final {
...@@ -223,7 +223,7 @@ UriToNfsPath(const char *_uri_utf8) ...@@ -223,7 +223,7 @@ UriToNfsPath(const char *_uri_utf8)
} }
std::string std::string
NfsStorage::MapUTF8(const char *uri_utf8) const NfsStorage::MapUTF8(const char *uri_utf8) const noexcept
{ {
assert(uri_utf8 != nullptr); assert(uri_utf8 != nullptr);
...@@ -234,7 +234,7 @@ NfsStorage::MapUTF8(const char *uri_utf8) const ...@@ -234,7 +234,7 @@ NfsStorage::MapUTF8(const char *uri_utf8) const
} }
const char * const char *
NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{ {
return PathTraitsUTF8::Relative(base.c_str(), uri_utf8); return PathTraitsUTF8::Relative(base.c_str(), uri_utf8);
} }
...@@ -291,7 +291,7 @@ NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow) ...@@ -291,7 +291,7 @@ NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow)
gcc_pure gcc_pure
static bool static bool
SkipNameFS(const char *name) SkipNameFS(const char *name) noexcept
{ {
return name[0] == '.' && return name[0] == '.' &&
(name[1] == 0 || (name[1] == 0 ||
......
...@@ -69,13 +69,13 @@ public: ...@@ -69,13 +69,13 @@ public:
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override; StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
std::string MapUTF8(const char *uri_utf8) const override; std::string MapUTF8(const char *uri_utf8) const noexcept override;
const char *MapToRelativeUTF8(const char *uri_utf8) const override; const char *MapToRelativeUTF8(const char *uri_utf8) const noexcept override;
}; };
std::string std::string
SmbclientStorage::MapUTF8(const char *uri_utf8) const SmbclientStorage::MapUTF8(const char *uri_utf8) const noexcept
{ {
assert(uri_utf8 != nullptr); assert(uri_utf8 != nullptr);
...@@ -86,7 +86,7 @@ SmbclientStorage::MapUTF8(const char *uri_utf8) const ...@@ -86,7 +86,7 @@ SmbclientStorage::MapUTF8(const char *uri_utf8) const
} }
const char * const char *
SmbclientStorage::MapToRelativeUTF8(const char *uri_utf8) const SmbclientStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{ {
return PathTraitsUTF8::Relative(base.c_str(), uri_utf8); return PathTraitsUTF8::Relative(base.c_str(), uri_utf8);
} }
...@@ -143,7 +143,7 @@ SmbclientStorage::OpenDirectory(const char *uri_utf8) ...@@ -143,7 +143,7 @@ SmbclientStorage::OpenDirectory(const char *uri_utf8)
gcc_pure gcc_pure
static bool static bool
SkipNameFS(const char *name) SkipNameFS(const char *name) noexcept
{ {
return name[0] == '.' && return name[0] == '.' &&
(name[1] == 0 || (name[1] == 0 ||
......
...@@ -149,7 +149,7 @@ FormatErrno(const char *fmt, Args&&... args) ...@@ -149,7 +149,7 @@ FormatErrno(const char *fmt, Args&&... args)
gcc_pure gcc_pure
static inline bool static inline bool
IsFileNotFound(const std::system_error &e) IsFileNotFound(const std::system_error &e) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return e.code().category() == std::system_category() && return e.code().category() == std::system_category() &&
...@@ -162,7 +162,7 @@ IsFileNotFound(const std::system_error &e) ...@@ -162,7 +162,7 @@ IsFileNotFound(const std::system_error &e)
gcc_pure gcc_pure
static inline bool static inline bool
IsPathNotFound(const std::system_error &e) IsPathNotFound(const std::system_error &e) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return e.code().category() == std::system_category() && return e.code().category() == std::system_category() &&
...@@ -175,7 +175,7 @@ IsPathNotFound(const std::system_error &e) ...@@ -175,7 +175,7 @@ IsPathNotFound(const std::system_error &e)
gcc_pure gcc_pure
static inline bool static inline bool
IsAccessDenied(const std::system_error &e) IsAccessDenied(const std::system_error &e) noexcept
{ {
#ifdef WIN32 #ifdef WIN32
return e.code().category() == std::system_category() && return e.code().category() == std::system_category() &&
......
...@@ -58,14 +58,14 @@ ...@@ -58,14 +58,14 @@
#endif #endif
bool bool
FileDescriptor::Open(const char *pathname, int flags, mode_t mode) FileDescriptor::Open(const char *pathname, int flags, mode_t mode) noexcept
{ {
fd = ::open(pathname, flags | O_NOCTTY | O_CLOEXEC, mode); fd = ::open(pathname, flags | O_NOCTTY | O_CLOEXEC, mode);
return IsDefined(); return IsDefined();
} }
bool bool
FileDescriptor::OpenReadOnly(const char *pathname) FileDescriptor::OpenReadOnly(const char *pathname) noexcept
{ {
return Open(pathname, O_RDONLY); return Open(pathname, O_RDONLY);
} }
...@@ -73,13 +73,13 @@ FileDescriptor::OpenReadOnly(const char *pathname) ...@@ -73,13 +73,13 @@ FileDescriptor::OpenReadOnly(const char *pathname)
#ifndef WIN32 #ifndef WIN32
bool bool
FileDescriptor::OpenNonBlocking(const char *pathname) FileDescriptor::OpenNonBlocking(const char *pathname) noexcept
{ {
return Open(pathname, O_RDWR | O_NONBLOCK); return Open(pathname, O_RDWR | O_NONBLOCK);
} }
bool bool
FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept
{ {
int fds[2]; int fds[2];
...@@ -99,7 +99,7 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w) ...@@ -99,7 +99,7 @@ FileDescriptor::CreatePipe(FileDescriptor &r, FileDescriptor &w)
} }
void void
FileDescriptor::SetNonBlocking() FileDescriptor::SetNonBlocking() noexcept
{ {
assert(IsDefined()); assert(IsDefined());
...@@ -108,7 +108,7 @@ FileDescriptor::SetNonBlocking() ...@@ -108,7 +108,7 @@ FileDescriptor::SetNonBlocking()
} }
void void
FileDescriptor::SetBlocking() FileDescriptor::SetBlocking() noexcept
{ {
assert(IsDefined()); assert(IsDefined());
...@@ -121,7 +121,7 @@ FileDescriptor::SetBlocking() ...@@ -121,7 +121,7 @@ FileDescriptor::SetBlocking()
#ifdef USE_EVENTFD #ifdef USE_EVENTFD
bool bool
FileDescriptor::CreateEventFD(unsigned initval) FileDescriptor::CreateEventFD(unsigned initval) noexcept
{ {
fd = ::eventfd(initval, EFD_NONBLOCK|EFD_CLOEXEC); fd = ::eventfd(initval, EFD_NONBLOCK|EFD_CLOEXEC);
return fd >= 0; return fd >= 0;
...@@ -132,7 +132,7 @@ FileDescriptor::CreateEventFD(unsigned initval) ...@@ -132,7 +132,7 @@ FileDescriptor::CreateEventFD(unsigned initval)
#ifdef USE_SIGNALFD #ifdef USE_SIGNALFD
bool bool
FileDescriptor::CreateSignalFD(const sigset_t *mask) FileDescriptor::CreateSignalFD(const sigset_t *mask) noexcept
{ {
int new_fd = ::signalfd(fd, mask, SFD_NONBLOCK|SFD_CLOEXEC); int new_fd = ::signalfd(fd, mask, SFD_NONBLOCK|SFD_CLOEXEC);
if (new_fd < 0) if (new_fd < 0)
...@@ -147,7 +147,7 @@ FileDescriptor::CreateSignalFD(const sigset_t *mask) ...@@ -147,7 +147,7 @@ FileDescriptor::CreateSignalFD(const sigset_t *mask)
#ifdef HAVE_INOTIFY_INIT #ifdef HAVE_INOTIFY_INIT
bool bool
FileDescriptor::CreateInotify() FileDescriptor::CreateInotify() noexcept
{ {
#ifdef HAVE_INOTIFY_INIT1 #ifdef HAVE_INOTIFY_INIT1
int new_fd = inotify_init1(IN_CLOEXEC|IN_NONBLOCK); int new_fd = inotify_init1(IN_CLOEXEC|IN_NONBLOCK);
...@@ -168,7 +168,7 @@ FileDescriptor::CreateInotify() ...@@ -168,7 +168,7 @@ FileDescriptor::CreateInotify()
#endif #endif
bool bool
FileDescriptor::Rewind() FileDescriptor::Rewind() noexcept
{ {
assert(IsDefined()); assert(IsDefined());
...@@ -176,7 +176,7 @@ FileDescriptor::Rewind() ...@@ -176,7 +176,7 @@ FileDescriptor::Rewind()
} }
off_t off_t
FileDescriptor::GetSize() const FileDescriptor::GetSize() const noexcept
{ {
struct stat st; struct stat st;
return ::fstat(fd, &st) >= 0 return ::fstat(fd, &st) >= 0
...@@ -187,7 +187,7 @@ FileDescriptor::GetSize() const ...@@ -187,7 +187,7 @@ FileDescriptor::GetSize() const
#ifndef WIN32 #ifndef WIN32
int int
FileDescriptor::Poll(short events, int timeout) const FileDescriptor::Poll(short events, int timeout) const noexcept
{ {
assert(IsDefined()); assert(IsDefined());
...@@ -201,13 +201,13 @@ FileDescriptor::Poll(short events, int timeout) const ...@@ -201,13 +201,13 @@ FileDescriptor::Poll(short events, int timeout) const
} }
int int
FileDescriptor::WaitReadable(int timeout) const FileDescriptor::WaitReadable(int timeout) const noexcept
{ {
return Poll(POLLIN, timeout); return Poll(POLLIN, timeout);
} }
int int
FileDescriptor::WaitWritable(int timeout) const FileDescriptor::WaitWritable(int timeout) const noexcept
{ {
return Poll(POLLOUT, timeout); return Poll(POLLOUT, timeout);
} }
......
...@@ -70,11 +70,11 @@ public: ...@@ -70,11 +70,11 @@ public:
return fd; return fd;
} }
void Set(int _fd) { void Set(int _fd) noexcept {
fd = _fd; fd = _fd;
} }
int Steal() { int Steal() noexcept {
assert(IsDefined()); assert(IsDefined());
int _fd = fd; int _fd = fd;
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
return _fd; return _fd;
} }
void SetUndefined() { void SetUndefined() noexcept {
fd = -1; fd = -1;
} }
...@@ -90,42 +90,42 @@ public: ...@@ -90,42 +90,42 @@ public:
return FileDescriptor(-1); return FileDescriptor(-1);
} }
bool Open(const char *pathname, int flags, mode_t mode=0666); bool Open(const char *pathname, int flags, mode_t mode=0666) noexcept;
bool OpenReadOnly(const char *pathname); bool OpenReadOnly(const char *pathname) noexcept;
#ifndef WIN32 #ifndef WIN32
bool OpenNonBlocking(const char *pathname); bool OpenNonBlocking(const char *pathname) noexcept;
static bool CreatePipe(FileDescriptor &r, FileDescriptor &w); static bool CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept;
/** /**
* Enable non-blocking mode on this file descriptor. * Enable non-blocking mode on this file descriptor.
*/ */
void SetNonBlocking(); void SetNonBlocking() noexcept;
/** /**
* Enable blocking mode on this file descriptor. * Enable blocking mode on this file descriptor.
*/ */
void SetBlocking(); void SetBlocking() noexcept;
/** /**
* Duplicate the file descriptor onto the given file descriptor. * Duplicate the file descriptor onto the given file descriptor.
*/ */
bool Duplicate(int new_fd) const { bool Duplicate(int new_fd) const noexcept {
return ::dup2(Get(), new_fd) == 0; return ::dup2(Get(), new_fd) == 0;
} }
#endif #endif
#ifdef USE_EVENTFD #ifdef USE_EVENTFD
bool CreateEventFD(unsigned initval=0); bool CreateEventFD(unsigned initval=0) noexcept;
#endif #endif
#ifdef USE_SIGNALFD #ifdef USE_SIGNALFD
bool CreateSignalFD(const sigset_t *mask); bool CreateSignalFD(const sigset_t *mask) noexcept;
#endif #endif
#ifdef HAVE_INOTIFY_INIT #ifdef HAVE_INOTIFY_INIT
bool CreateInotify(); bool CreateInotify() noexcept;
#endif #endif
/** /**
...@@ -133,25 +133,25 @@ public: ...@@ -133,25 +133,25 @@ public:
* "undefined" object. After this call, IsDefined() is guaranteed * "undefined" object. After this call, IsDefined() is guaranteed
* to return false, and this object may be reused. * to return false, and this object may be reused.
*/ */
bool Close() { bool Close() noexcept {
return ::close(Steal()) == 0; return ::close(Steal()) == 0;
} }
/** /**
* Rewind the pointer to the beginning of the file. * Rewind the pointer to the beginning of the file.
*/ */
bool Rewind(); bool Rewind() noexcept;
off_t Seek(off_t offset) { off_t Seek(off_t offset) noexcept {
return lseek(Get(), offset, SEEK_SET); return lseek(Get(), offset, SEEK_SET);
} }
off_t Skip(off_t offset) { off_t Skip(off_t offset) noexcept {
return lseek(Get(), offset, SEEK_CUR); return lseek(Get(), offset, SEEK_CUR);
} }
gcc_pure gcc_pure
off_t Tell() const { off_t Tell() const noexcept {
return lseek(Get(), 0, SEEK_CUR); return lseek(Get(), 0, SEEK_CUR);
} }
...@@ -159,21 +159,21 @@ public: ...@@ -159,21 +159,21 @@ public:
* Returns the size of the file in bytes, or -1 on error. * Returns the size of the file in bytes, or -1 on error.
*/ */
gcc_pure gcc_pure
off_t GetSize() const; off_t GetSize() const noexcept;
ssize_t Read(void *buffer, size_t length) { ssize_t Read(void *buffer, size_t length) noexcept {
return ::read(fd, buffer, length); return ::read(fd, buffer, length);
} }
ssize_t Write(const void *buffer, size_t length) { ssize_t Write(const void *buffer, size_t length) noexcept {
return ::write(fd, buffer, length); return ::write(fd, buffer, length);
} }
#ifndef WIN32 #ifndef WIN32
int Poll(short events, int timeout) const; int Poll(short events, int timeout) const noexcept;
int WaitReadable(int timeout) const; int WaitReadable(int timeout) const noexcept;
int WaitWritable(int timeout) const; int WaitWritable(int timeout) const noexcept;
#endif #endif
}; };
......
...@@ -53,7 +53,7 @@ IsUnsafeChar(char ch) ...@@ -53,7 +53,7 @@ IsUnsafeChar(char ch)
gcc_pure gcc_pure
static bool static bool
HasUnsafeChar(const char *s) HasUnsafeChar(const char *s) noexcept
{ {
for (; *s; ++s) for (; *s; ++s)
if (IsUnsafeChar(*s)) if (IsUnsafeChar(*s))
...@@ -63,7 +63,7 @@ HasUnsafeChar(const char *s) ...@@ -63,7 +63,7 @@ HasUnsafeChar(const char *s)
} }
static const char * static const char *
SanitizeString(const char *s, char *buffer, size_t buffer_size) SanitizeString(const char *s, char *buffer, size_t buffer_size) noexcept
{ {
/* skip leading dots to avoid generating "../" sequences */ /* skip leading dots to avoid generating "../" sequences */
while (*s == '.') while (*s == '.')
...@@ -79,7 +79,7 @@ SanitizeString(const char *s, char *buffer, size_t buffer_size) ...@@ -79,7 +79,7 @@ SanitizeString(const char *s, char *buffer, size_t buffer_size)
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const char * static const char *
TagGetter(const void *object, const char *name) TagGetter(const void *object, const char *name) noexcept
{ {
const auto &_ctx = *(const FormatTagContext *)object; const auto &_ctx = *(const FormatTagContext *)object;
auto &ctx = const_cast<FormatTagContext &>(_ctx); auto &ctx = const_cast<FormatTagContext &>(_ctx);
...@@ -126,7 +126,7 @@ TagGetter(const void *object, const char *name) ...@@ -126,7 +126,7 @@ TagGetter(const void *object, const char *name)
} }
char * char *
FormatTag(const Tag &tag, const char *format) FormatTag(const Tag &tag, const char *format) noexcept
{ {
FormatTagContext ctx(tag); FormatTagContext ctx(tag);
return format_object(format, &ctx, TagGetter); return format_object(format, &ctx, TagGetter);
......
...@@ -27,6 +27,6 @@ struct Tag; ...@@ -27,6 +27,6 @@ struct Tag;
gcc_malloc gcc_nonnull_all gcc_malloc gcc_nonnull_all
char * char *
FormatTag(const Tag &tag, const char *format); FormatTag(const Tag &tag, const char *format) noexcept;
#endif #endif
...@@ -33,7 +33,7 @@ static constexpr size_t ID3V1_SIZE = 128; ...@@ -33,7 +33,7 @@ static constexpr size_t ID3V1_SIZE = 128;
gcc_pure gcc_pure
static inline bool static inline bool
tag_is_id3v1(struct id3_tag *tag) tag_is_id3v1(struct id3_tag *tag) noexcept
{ {
return (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) != 0; return (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) != 0;
} }
......
...@@ -28,14 +28,14 @@ extern tag_mask_t global_tag_mask; ...@@ -28,14 +28,14 @@ extern tag_mask_t global_tag_mask;
gcc_const gcc_const
static inline bool static inline bool
IsTagEnabled(unsigned tag) IsTagEnabled(unsigned tag) noexcept
{ {
return global_tag_mask & (1u << tag); return global_tag_mask & (1u << tag);
} }
gcc_const gcc_const
static inline bool static inline bool
IsTagEnabled(TagType tag) IsTagEnabled(TagType tag) noexcept
{ {
return IsTagEnabled(unsigned(tag)); return IsTagEnabled(unsigned(tag));
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <string.h> #include <string.h>
TagType TagType
tag_name_parse(const char *name) tag_name_parse(const char *name) noexcept
{ {
assert(name != nullptr); assert(name != nullptr);
...@@ -42,7 +42,7 @@ tag_name_parse(const char *name) ...@@ -42,7 +42,7 @@ tag_name_parse(const char *name)
} }
TagType TagType
tag_name_parse_i(const char *name) tag_name_parse_i(const char *name) noexcept
{ {
assert(name != nullptr); assert(name != nullptr);
...@@ -112,7 +112,7 @@ Tag::MergeReplace(Tag *base, Tag *add) ...@@ -112,7 +112,7 @@ Tag::MergeReplace(Tag *base, Tag *add)
} }
const char * const char *
Tag::GetValue(TagType type) const Tag::GetValue(TagType type) const noexcept
{ {
assert(type < TAG_NUM_OF_ITEM_TYPES); assert(type < TAG_NUM_OF_ITEM_TYPES);
...@@ -124,7 +124,7 @@ Tag::GetValue(TagType type) const ...@@ -124,7 +124,7 @@ Tag::GetValue(TagType type) const
} }
bool bool
Tag::HasType(TagType type) const Tag::HasType(TagType type) const noexcept
{ {
return GetValue(type) != nullptr; return GetValue(type) != nullptr;
} }
...@@ -133,14 +133,14 @@ struct Tag { ...@@ -133,14 +133,14 @@ struct Tag {
* nullptr if none is present in this tag object. * nullptr if none is present in this tag object.
*/ */
gcc_pure gcc_pure
const char *GetValue(TagType type) const; const char *GetValue(TagType type) const noexcept;
/** /**
* Checks whether the tag contains one or more items with * Checks whether the tag contains one or more items with
* the specified type. * the specified type.
*/ */
gcc_pure gcc_pure
bool HasType(TagType type) const; bool HasType(TagType type) const noexcept;
class const_iterator { class const_iterator {
friend struct Tag; friend struct Tag;
...@@ -202,7 +202,7 @@ struct Tag { ...@@ -202,7 +202,7 @@ struct Tag {
*/ */
gcc_pure gcc_pure
TagType TagType
tag_name_parse(const char *name); tag_name_parse(const char *name) noexcept;
/** /**
* Parse the string, and convert it into a #TagType. Returns * Parse the string, and convert it into a #TagType. Returns
...@@ -212,6 +212,6 @@ tag_name_parse(const char *name); ...@@ -212,6 +212,6 @@ tag_name_parse(const char *name);
*/ */
gcc_pure gcc_pure
TagType TagType
tag_name_parse_i(const char *name); tag_name_parse_i(const char *name) noexcept;
#endif #endif
...@@ -153,7 +153,7 @@ TagBuilder::CommitNew() ...@@ -153,7 +153,7 @@ TagBuilder::CommitNew()
} }
bool bool
TagBuilder::HasType(TagType type) const TagBuilder::HasType(TagType type) const noexcept
{ {
for (auto i : items) for (auto i : items)
if (i->type == type) if (i->type == type)
...@@ -237,7 +237,7 @@ TagBuilder::AddEmptyItem(TagType type) ...@@ -237,7 +237,7 @@ TagBuilder::AddEmptyItem(TagType type)
} }
void void
TagBuilder::RemoveAll() TagBuilder::RemoveAll() noexcept
{ {
tag_pool_lock.lock(); tag_pool_lock.lock();
for (auto i : items) for (auto i : items)
...@@ -248,7 +248,7 @@ TagBuilder::RemoveAll() ...@@ -248,7 +248,7 @@ TagBuilder::RemoveAll()
} }
void void
TagBuilder::RemoveType(TagType type) TagBuilder::RemoveType(TagType type) noexcept
{ {
const auto begin = items.begin(), end = items.end(); const auto begin = items.begin(), end = items.end();
......
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
* the specified type. * the specified type.
*/ */
gcc_pure gcc_pure
bool HasType(TagType type) const; bool HasType(TagType type) const noexcept;
/** /**
* Copy attributes and items from the other object that do not * Copy attributes and items from the other object that do not
...@@ -161,12 +161,12 @@ public: ...@@ -161,12 +161,12 @@ public:
/** /**
* Removes all tag items. * Removes all tag items.
*/ */
void RemoveAll(); void RemoveAll() noexcept;
/** /**
* Removes all tag items of the specified type. * Removes all tag items of the specified type.
*/ */
void RemoveType(TagType type); void RemoveType(TagType type) noexcept;
private: private:
gcc_nonnull_all gcc_nonnull_all
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
gcc_pure gcc_pure
static id3_utf8_t * static id3_utf8_t *
tag_id3_getstring(const struct id3_frame *frame, unsigned i) tag_id3_getstring(const struct id3_frame *frame, unsigned i) noexcept
{ {
id3_field *field = id3_frame_field(frame, i); id3_field *field = id3_frame_field(frame, i);
if (field == nullptr) if (field == nullptr)
...@@ -203,7 +203,7 @@ tag_id3_import_comment(struct id3_tag *tag, const char *id, TagType type, ...@@ -203,7 +203,7 @@ tag_id3_import_comment(struct id3_tag *tag, const char *id, TagType type,
*/ */
gcc_pure gcc_pure
static TagType static TagType
tag_id3_parse_txxx_name(const char *name) tag_id3_parse_txxx_name(const char *name) noexcept
{ {
static constexpr struct tag_table txxx_tags[] = { static constexpr struct tag_table txxx_tags[] = {
{ "ALBUMARTISTSORT", TAG_ALBUM_ARTIST_SORT }, { "ALBUMARTISTSORT", TAG_ALBUM_ARTIST_SORT },
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
gcc_pure gcc_pure
static const char * static const char *
FindInvalidUTF8(const char *p, const char *const end) FindInvalidUTF8(const char *p, const char *const end) noexcept
{ {
while (p < end) { while (p < end) {
const size_t s = SequenceLengthUTF8(*p); const size_t s = SequenceLengthUTF8(*p);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* in the table. * in the table.
*/ */
TagType TagType
tag_table_lookup(const struct tag_table *table, const char *name) tag_table_lookup(const struct tag_table *table, const char *name) noexcept
{ {
for (; table->name != nullptr; ++table) for (; table->name != nullptr; ++table)
if (strcmp(name, table->name) == 0) if (strcmp(name, table->name) == 0)
...@@ -43,7 +43,7 @@ tag_table_lookup(const struct tag_table *table, const char *name) ...@@ -43,7 +43,7 @@ tag_table_lookup(const struct tag_table *table, const char *name)
* in the table. * in the table.
*/ */
TagType TagType
tag_table_lookup_i(const struct tag_table *table, const char *name) tag_table_lookup_i(const struct tag_table *table, const char *name) noexcept
{ {
for (; table->name != nullptr; ++table) for (; table->name != nullptr; ++table)
if (StringEqualsCaseASCII(name, table->name)) if (StringEqualsCaseASCII(name, table->name))
...@@ -53,7 +53,7 @@ tag_table_lookup_i(const struct tag_table *table, const char *name) ...@@ -53,7 +53,7 @@ tag_table_lookup_i(const struct tag_table *table, const char *name)
} }
const char * const char *
tag_table_lookup(const tag_table *table, TagType type) tag_table_lookup(const tag_table *table, TagType type) noexcept
{ {
for (; table->name != nullptr; ++table) for (; table->name != nullptr; ++table)
if (table->type == type) if (table->type == type)
......
...@@ -36,7 +36,7 @@ struct tag_table { ...@@ -36,7 +36,7 @@ struct tag_table {
*/ */
gcc_pure gcc_pure
TagType TagType
tag_table_lookup(const tag_table *table, const char *name); tag_table_lookup(const tag_table *table, const char *name) noexcept;
/** /**
* Looks up a string in a tag translation table (case insensitive). * Looks up a string in a tag translation table (case insensitive).
...@@ -45,7 +45,7 @@ tag_table_lookup(const tag_table *table, const char *name); ...@@ -45,7 +45,7 @@ tag_table_lookup(const tag_table *table, const char *name);
*/ */
gcc_pure gcc_pure
TagType TagType
tag_table_lookup_i(const tag_table *table, const char *name); tag_table_lookup_i(const tag_table *table, const char *name) noexcept;
/** /**
* Looks up a #TagType in a tag translation table and returns its * Looks up a #TagType in a tag translation table and returns its
...@@ -54,6 +54,6 @@ tag_table_lookup_i(const tag_table *table, const char *name); ...@@ -54,6 +54,6 @@ tag_table_lookup_i(const tag_table *table, const char *name);
*/ */
gcc_pure gcc_pure
const char * const char *
tag_table_lookup(const tag_table *table, TagType type); tag_table_lookup(const tag_table *table, TagType type) noexcept;
#endif #endif
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <string.h> #include <string.h>
const char * const char *
vorbis_comment_value(const char *entry, const char *name) vorbis_comment_value(const char *entry, const char *name) noexcept
{ {
assert(entry != nullptr); assert(entry != nullptr);
assert(name != nullptr); assert(name != nullptr);
......
...@@ -29,6 +29,6 @@ ...@@ -29,6 +29,6 @@
*/ */
gcc_pure gcc_pure
const char * const char *
vorbis_comment_value(const char *entry, const char *name); vorbis_comment_value(const char *entry, const char *name) noexcept;
#endif #endif
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
* Return the current thread's id . * Return the current thread's id .
*/ */
gcc_pure gcc_pure
static const ThreadId GetCurrent() { static const ThreadId GetCurrent() noexcept {
#ifdef WIN32 #ifdef WIN32
return ::GetCurrentThreadId(); return ::GetCurrentThreadId();
#else #else
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
/** /**
* Check if this thread is the current thread. * Check if this thread is the current thread.
*/ */
bool IsInside() const { bool IsInside() const noexcept {
return *this == GetCurrent(); return *this == GetCurrent();
} }
}; };
......
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
gcc_pure gcc_pure
static inline pid_t static inline pid_t
ReadPidFile(Path path) ReadPidFile(Path path) noexcept
{ {
int fd = OpenFile(path, O_RDONLY, 0); int fd = OpenFile(path, O_RDONLY, 0);
if (fd < 0) if (fd < 0)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringEqualsCaseASCII(const char *a, const char *b) StringEqualsCaseASCII(const char *a, const char *b) noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
...@@ -56,7 +56,7 @@ StringEqualsCaseASCII(const char *a, const char *b) ...@@ -56,7 +56,7 @@ StringEqualsCaseASCII(const char *a, const char *b)
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringEqualsCaseASCII(const char *a, const char *b, size_t n) StringEqualsCaseASCII(const char *a, const char *b, size_t n) noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
*/ */
gcc_const gcc_const
static size_t static size_t
AlignToPageSize(size_t size) AlignToPageSize(size_t size) noexcept
{ {
static const long page_size = sysconf(_SC_PAGESIZE); static const long page_size = sysconf(_SC_PAGESIZE);
if (page_size <= 0) if (page_size <= 0)
......
...@@ -32,14 +32,14 @@ PeakBuffer::~PeakBuffer() ...@@ -32,14 +32,14 @@ PeakBuffer::~PeakBuffer()
} }
bool bool
PeakBuffer::IsEmpty() const PeakBuffer::IsEmpty() const noexcept
{ {
return (normal_buffer == nullptr || normal_buffer->IsEmpty()) && return (normal_buffer == nullptr || normal_buffer->IsEmpty()) &&
(peak_buffer == nullptr || peak_buffer->IsEmpty()); (peak_buffer == nullptr || peak_buffer->IsEmpty());
} }
WritableBuffer<void> WritableBuffer<void>
PeakBuffer::Read() const PeakBuffer::Read() const noexcept
{ {
if (normal_buffer != nullptr) { if (normal_buffer != nullptr) {
const auto p = normal_buffer->Read(); const auto p = normal_buffer->Read();
...@@ -57,7 +57,7 @@ PeakBuffer::Read() const ...@@ -57,7 +57,7 @@ PeakBuffer::Read() const
} }
void void
PeakBuffer::Consume(size_t length) PeakBuffer::Consume(size_t length) noexcept
{ {
if (normal_buffer != nullptr && !normal_buffer->IsEmpty()) { if (normal_buffer != nullptr && !normal_buffer->IsEmpty()) {
normal_buffer->Consume(length); normal_buffer->Consume(length);
...@@ -76,7 +76,8 @@ PeakBuffer::Consume(size_t length) ...@@ -76,7 +76,8 @@ PeakBuffer::Consume(size_t length)
} }
static size_t static size_t
AppendTo(DynamicFifoBuffer<uint8_t> &buffer, const void *data, size_t length) AppendTo(DynamicFifoBuffer<uint8_t> &buffer,
const void *data, size_t length) noexcept
{ {
assert(data != nullptr); assert(data != nullptr);
assert(length > 0); assert(length > 0);
......
...@@ -57,12 +57,12 @@ public: ...@@ -57,12 +57,12 @@ public:
PeakBuffer &operator=(const PeakBuffer &) = delete; PeakBuffer &operator=(const PeakBuffer &) = delete;
gcc_pure gcc_pure
bool IsEmpty() const; bool IsEmpty() const noexcept;
gcc_pure gcc_pure
WritableBuffer<void> Read() const; WritableBuffer<void> Read() const noexcept;
void Consume(size_t length); void Consume(size_t length) noexcept;
bool Append(const void *data, size_t length); bool Append(const void *data, size_t length);
}; };
......
/* /*
* Copyright (C) 2010-2015 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2010-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -40,70 +40,70 @@ ...@@ -40,70 +40,70 @@
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline size_t static inline size_t
StringLength(const char *p) StringLength(const char *p) noexcept
{ {
return strlen(p); return strlen(p);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const char * static inline const char *
StringFind(const char *haystack, const char *needle) StringFind(const char *haystack, const char *needle) noexcept
{ {
return strstr(haystack, needle); return strstr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline char * static inline char *
StringFind(char *haystack, char needle, size_t size) StringFind(char *haystack, char needle, size_t size) noexcept
{ {
return (char *)memchr(haystack, needle, size); return (char *)memchr(haystack, needle, size);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const char * static inline const char *
StringFind(const char *haystack, char needle, size_t size) StringFind(const char *haystack, char needle, size_t size) noexcept
{ {
return (const char *)memchr(haystack, needle, size); return (const char *)memchr(haystack, needle, size);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const char * static inline const char *
StringFind(const char *haystack, char needle) StringFind(const char *haystack, char needle) noexcept
{ {
return strchr(haystack, needle); return strchr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline char * static inline char *
StringFind(char *haystack, char needle) StringFind(char *haystack, char needle) noexcept
{ {
return strchr(haystack, needle); return strchr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const char * static inline const char *
StringFindLast(const char *haystack, char needle) StringFindLast(const char *haystack, char needle) noexcept
{ {
return strrchr(haystack, needle); return strrchr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline char * static inline char *
StringFindLast(char *haystack, char needle) StringFindLast(char *haystack, char needle) noexcept
{ {
return strrchr(haystack, needle); return strrchr(haystack, needle);
} }
gcc_nonnull_all gcc_nonnull_all
static inline void static inline void
UnsafeCopyString(char *dest, const char *src) UnsafeCopyString(char *dest, const char *src) noexcept
{ {
strcpy(dest, src); strcpy(dest, src);
} }
gcc_nonnull_all gcc_nonnull_all
static inline char * static inline char *
UnsafeCopyStringP(char *dest, const char *src) UnsafeCopyStringP(char *dest, const char *src) noexcept
{ {
#if defined(WIN32) || defined(__BIONIC__) #if defined(WIN32) || defined(__BIONIC__)
/* emulate stpcpy() */ /* emulate stpcpy() */
...@@ -119,7 +119,7 @@ UnsafeCopyStringP(char *dest, const char *src) ...@@ -119,7 +119,7 @@ UnsafeCopyStringP(char *dest, const char *src)
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringIsEqual(const char *a, const char *b) StringIsEqual(const char *a, const char *b) noexcept
{ {
return strcmp(a, b) == 0; return strcmp(a, b) == 0;
} }
...@@ -129,7 +129,7 @@ StringIsEqual(const char *a, const char *b) ...@@ -129,7 +129,7 @@ StringIsEqual(const char *a, const char *b)
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringIsEqual(const char *a, const char *b, size_t length) StringIsEqual(const char *a, const char *b, size_t length) noexcept
{ {
return strncmp(a, b, length) == 0; return strncmp(a, b, length) == 0;
} }
......
/* /*
* Copyright (C) 2013-2015 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2013-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "StringCompare.hxx" #include "StringCompare.hxx"
bool bool
StringEndsWith(const char *haystack, const char *needle) StringEndsWith(const char *haystack, const char *needle) noexcept
{ {
const size_t haystack_length = strlen(haystack); const size_t haystack_length = strlen(haystack);
const size_t needle_length = strlen(needle); const size_t needle_length = strlen(needle);
...@@ -41,7 +41,7 @@ StringEndsWith(const char *haystack, const char *needle) ...@@ -41,7 +41,7 @@ StringEndsWith(const char *haystack, const char *needle)
} }
const char * const char *
FindStringSuffix(const char *p, const char *suffix) FindStringSuffix(const char *p, const char *suffix) noexcept
{ {
const size_t p_length = strlen(p); const size_t p_length = strlen(p);
const size_t suffix_length = strlen(suffix); const size_t suffix_length = strlen(suffix);
......
/* /*
* Copyright (C) 2013-2015 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2013-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -45,14 +45,14 @@ StringIsEmpty(const char *string) ...@@ -45,14 +45,14 @@ StringIsEmpty(const char *string)
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringStartsWith(const char *haystack, StringView needle) StringStartsWith(const char *haystack, StringView needle) noexcept
{ {
return strncmp(haystack, needle.data, needle.size) == 0; return strncmp(haystack, needle.data, needle.size) == 0;
} }
gcc_pure gcc_pure
bool bool
StringEndsWith(const char *haystack, const char *needle); StringEndsWith(const char *haystack, const char *needle) noexcept;
/** /**
* Returns the portion of the string after a prefix. If the string * Returns the portion of the string after a prefix. If the string
...@@ -61,7 +61,7 @@ StringEndsWith(const char *haystack, const char *needle); ...@@ -61,7 +61,7 @@ StringEndsWith(const char *haystack, const char *needle);
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const char * static inline const char *
StringAfterPrefix(const char *haystack, StringView needle) StringAfterPrefix(const char *haystack, StringView needle) noexcept
{ {
return StringStartsWith(haystack, needle) return StringStartsWith(haystack, needle)
? haystack + needle.size ? haystack + needle.size
...@@ -74,6 +74,6 @@ StringAfterPrefix(const char *haystack, StringView needle) ...@@ -74,6 +74,6 @@ StringAfterPrefix(const char *haystack, StringView needle)
*/ */
gcc_pure gcc_pure
const char * const char *
FindStringSuffix(const char *p, const char *suffix); FindStringSuffix(const char *p, const char *suffix) noexcept;
#endif #endif
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
#include <string.h> #include <string.h>
char * char *
CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size) CopyString(char *gcc_restrict dest, const char *gcc_restrict src,
size_t size) noexcept
{ {
size_t length = strlen(src); size_t length = strlen(src);
if (length >= size) if (length >= size)
...@@ -39,7 +40,7 @@ CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size) ...@@ -39,7 +40,7 @@ CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size)
} }
const char * const char *
StripLeft(const char *p) StripLeft(const char *p) noexcept
{ {
while (IsWhitespaceNotNull(*p)) while (IsWhitespaceNotNull(*p))
++p; ++p;
...@@ -48,7 +49,7 @@ StripLeft(const char *p) ...@@ -48,7 +49,7 @@ StripLeft(const char *p)
} }
const char * const char *
StripLeft(const char *p, const char *end) StripLeft(const char *p, const char *end) noexcept
{ {
while (p < end && IsWhitespaceOrNull(*p)) while (p < end && IsWhitespaceOrNull(*p))
++p; ++p;
...@@ -57,7 +58,7 @@ StripLeft(const char *p, const char *end) ...@@ -57,7 +58,7 @@ StripLeft(const char *p, const char *end)
} }
const char * const char *
StripRight(const char *p, const char *end) StripRight(const char *p, const char *end) noexcept
{ {
while (end > p && IsWhitespaceOrNull(end[-1])) while (end > p && IsWhitespaceOrNull(end[-1]))
--end; --end;
...@@ -66,7 +67,7 @@ StripRight(const char *p, const char *end) ...@@ -66,7 +67,7 @@ StripRight(const char *p, const char *end)
} }
size_t size_t
StripRight(const char *p, size_t length) StripRight(const char *p, size_t length) noexcept
{ {
while (length > 0 && IsWhitespaceOrNull(p[length - 1])) while (length > 0 && IsWhitespaceOrNull(p[length - 1]))
--length; --length;
...@@ -75,7 +76,7 @@ StripRight(const char *p, size_t length) ...@@ -75,7 +76,7 @@ StripRight(const char *p, size_t length)
} }
void void
StripRight(char *p) StripRight(char *p) noexcept
{ {
size_t old_length = strlen(p); size_t old_length = strlen(p);
size_t new_length = StripRight(p, old_length); size_t new_length = StripRight(p, old_length);
...@@ -83,7 +84,7 @@ StripRight(char *p) ...@@ -83,7 +84,7 @@ StripRight(char *p)
} }
char * char *
Strip(char *p) Strip(char *p) noexcept
{ {
p = StripLeft(p); p = StripLeft(p);
StripRight(p); StripRight(p);
...@@ -91,7 +92,8 @@ Strip(char *p) ...@@ -91,7 +92,8 @@ Strip(char *p)
} }
bool bool
StringArrayContainsCase(const char *const*haystack, const char *needle) StringArrayContainsCase(const char *const*haystack,
const char *needle) noexcept
{ {
assert(haystack != nullptr); assert(haystack != nullptr);
assert(needle != nullptr); assert(needle != nullptr);
...@@ -104,7 +106,7 @@ StringArrayContainsCase(const char *const*haystack, const char *needle) ...@@ -104,7 +106,7 @@ StringArrayContainsCase(const char *const*haystack, const char *needle)
} }
void void
ToUpperASCII(char *dest, const char *src, size_t size) ToUpperASCII(char *dest, const char *src, size_t size) noexcept
{ {
assert(dest != nullptr); assert(dest != nullptr);
assert(src != nullptr); assert(src != nullptr);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
*/ */
gcc_nonnull_all gcc_nonnull_all
char * char *
CopyString(char *dest, const char *src, size_t size); CopyString(char *dest, const char *src, size_t size) noexcept;
/** /**
* Returns a pointer to the first non-whitespace character in the * Returns a pointer to the first non-whitespace character in the
...@@ -42,32 +42,32 @@ CopyString(char *dest, const char *src, size_t size); ...@@ -42,32 +42,32 @@ CopyString(char *dest, const char *src, size_t size);
*/ */
gcc_pure gcc_pure
const char * const char *
StripLeft(const char *p); StripLeft(const char *p) noexcept;
gcc_pure gcc_pure
static inline char * static inline char *
StripLeft(char *p) StripLeft(char *p) noexcept
{ {
return const_cast<char *>(StripLeft((const char *)p)); return const_cast<char *>(StripLeft((const char *)p));
} }
gcc_pure gcc_pure
const char * const char *
StripLeft(const char *p, const char *end); StripLeft(const char *p, const char *end) noexcept;
/** /**
* Determine the string's end as if it was stripped on the right side. * Determine the string's end as if it was stripped on the right side.
*/ */
gcc_pure gcc_pure
const char * const char *
StripRight(const char *p, const char *end); StripRight(const char *p, const char *end) noexcept;
/** /**
* Determine the string's end as if it was stripped on the right side. * Determine the string's end as if it was stripped on the right side.
*/ */
gcc_pure gcc_pure
static inline char * static inline char *
StripRight(char *p, char *end) StripRight(char *p, char *end) noexcept
{ {
return const_cast<char *>(StripRight((const char *)p, return const_cast<char *>(StripRight((const char *)p,
(const char *)end)); (const char *)end));
...@@ -79,20 +79,20 @@ StripRight(char *p, char *end) ...@@ -79,20 +79,20 @@ StripRight(char *p, char *end)
*/ */
gcc_pure gcc_pure
size_t size_t
StripRight(const char *p, size_t length); StripRight(const char *p, size_t length) noexcept;
/** /**
* Strip trailing whitespace by null-terminating the string. * Strip trailing whitespace by null-terminating the string.
*/ */
void void
StripRight(char *p); StripRight(char *p) noexcept;
/** /**
* Skip whitespace at the beginning and terminate the string after the * Skip whitespace at the beginning and terminate the string after the
* last non-whitespace character. * last non-whitespace character.
*/ */
char * char *
Strip(char *p); Strip(char *p) noexcept;
/** /**
* Checks whether a string array contains the specified string. * Checks whether a string array contains the specified string.
...@@ -104,7 +104,8 @@ Strip(char *p); ...@@ -104,7 +104,8 @@ Strip(char *p);
*/ */
gcc_pure gcc_pure
bool bool
StringArrayContainsCase(const char *const*haystack, const char *needle); StringArrayContainsCase(const char *const*haystack,
const char *needle) noexcept;
/** /**
* Convert the specified ASCII string (0x00..0x7f) to upper case. * Convert the specified ASCII string (0x00..0x7f) to upper case.
...@@ -112,6 +113,6 @@ StringArrayContainsCase(const char *const*haystack, const char *needle); ...@@ -112,6 +113,6 @@ StringArrayContainsCase(const char *const*haystack, const char *needle);
* @param size the destination buffer size * @param size the destination buffer size
*/ */
void void
ToUpperASCII(char *dest, const char *src, size_t size); ToUpperASCII(char *dest, const char *src, size_t size) noexcept;
#endif #endif
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
*/ */
gcc_const gcc_const
static time_t static time_t
GetTimeZoneOffset() GetTimeZoneOffset() noexcept
{ {
time_t t = 1234567890; time_t t = 1234567890;
struct tm tm; struct tm tm;
......
...@@ -124,7 +124,7 @@ MakeContinuation(unsigned char value) ...@@ -124,7 +124,7 @@ MakeContinuation(unsigned char value)
} }
bool bool
ValidateUTF8(const char *p) ValidateUTF8(const char *p) noexcept
{ {
for (; *p != 0; ++p) { for (; *p != 0; ++p) {
unsigned char ch = *p; unsigned char ch = *p;
...@@ -167,7 +167,7 @@ ValidateUTF8(const char *p) ...@@ -167,7 +167,7 @@ ValidateUTF8(const char *p)
} }
size_t size_t
SequenceLengthUTF8(char ch) SequenceLengthUTF8(char ch) noexcept
{ {
if (IsASCII(ch)) if (IsASCII(ch))
return 1; return 1;
...@@ -196,14 +196,14 @@ SequenceLengthUTF8(char ch) ...@@ -196,14 +196,14 @@ SequenceLengthUTF8(char ch)
template<size_t L> template<size_t L>
struct CheckSequenceUTF8 { struct CheckSequenceUTF8 {
gcc_pure gcc_pure
bool operator()(const char *p) const { bool operator()(const char *p) const noexcept {
return IsContinuation(*p) && CheckSequenceUTF8<L-1>()(p + 1); return IsContinuation(*p) && CheckSequenceUTF8<L-1>()(p + 1);
} }
}; };
template<> template<>
struct CheckSequenceUTF8<0u> { struct CheckSequenceUTF8<0u> {
constexpr bool operator()(gcc_unused const char *p) const { constexpr bool operator()(gcc_unused const char *p) const noexcept {
return true; return true;
} }
}; };
...@@ -211,7 +211,7 @@ struct CheckSequenceUTF8<0u> { ...@@ -211,7 +211,7 @@ struct CheckSequenceUTF8<0u> {
template<size_t L> template<size_t L>
gcc_pure gcc_pure
static size_t static size_t
InnerSequenceLengthUTF8(const char *p) InnerSequenceLengthUTF8(const char *p) noexcept
{ {
return CheckSequenceUTF8<L>()(p) return CheckSequenceUTF8<L>()(p)
? L + 1 ? L + 1
...@@ -219,7 +219,7 @@ InnerSequenceLengthUTF8(const char *p) ...@@ -219,7 +219,7 @@ InnerSequenceLengthUTF8(const char *p)
} }
size_t size_t
SequenceLengthUTF8(const char *p) SequenceLengthUTF8(const char *p) noexcept
{ {
const unsigned char ch = *p++; const unsigned char ch = *p++;
...@@ -246,8 +246,9 @@ SequenceLengthUTF8(const char *p) ...@@ -246,8 +246,9 @@ SequenceLengthUTF8(const char *p)
return 0; return 0;
} }
gcc_pure
static const char * static const char *
FindNonASCIIOrZero(const char *p) FindNonASCIIOrZero(const char *p) noexcept
{ {
while (*p != 0 && IsASCII(*p)) while (*p != 0 && IsASCII(*p))
++p; ++p;
...@@ -256,7 +257,7 @@ FindNonASCIIOrZero(const char *p) ...@@ -256,7 +257,7 @@ FindNonASCIIOrZero(const char *p)
const char * const char *
Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer, Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer,
size_t buffer_size) size_t buffer_size) noexcept
{ {
const char *p = FindNonASCIIOrZero(src); const char *p = FindNonASCIIOrZero(src);
if (*p == 0) if (*p == 0)
...@@ -294,7 +295,7 @@ Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer, ...@@ -294,7 +295,7 @@ Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer,
} }
char * char *
UnicodeToUTF8(unsigned ch, char *q) UnicodeToUTF8(unsigned ch, char *q) noexcept
{ {
if (gcc_likely(ch < 0x80)) { if (gcc_likely(ch < 0x80)) {
*q++ = (char)ch; *q++ = (char)ch;
...@@ -331,7 +332,7 @@ UnicodeToUTF8(unsigned ch, char *q) ...@@ -331,7 +332,7 @@ UnicodeToUTF8(unsigned ch, char *q)
} }
size_t size_t
LengthUTF8(const char *p) LengthUTF8(const char *p) noexcept
{ {
/* this is a very naive implementation: it does not do any /* this is a very naive implementation: it does not do any
verification, it just counts the bytes that are not a UTF-8 verification, it just counts the bytes that are not a UTF-8
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
bool bool
ValidateUTF8(const char *p); ValidateUTF8(const char *p) noexcept;
/** /**
* @return the number of the sequence beginning with the given * @return the number of the sequence beginning with the given
...@@ -48,7 +48,7 @@ ValidateUTF8(const char *p); ...@@ -48,7 +48,7 @@ ValidateUTF8(const char *p);
*/ */
gcc_const gcc_const
size_t size_t
SequenceLengthUTF8(char ch); SequenceLengthUTF8(char ch) noexcept;
/** /**
* @return the number of the first sequence in the given string, or 0 * @return the number of the first sequence in the given string, or 0
...@@ -56,7 +56,7 @@ SequenceLengthUTF8(char ch); ...@@ -56,7 +56,7 @@ SequenceLengthUTF8(char ch);
*/ */
gcc_pure gcc_pure
size_t size_t
SequenceLengthUTF8(const char *p); SequenceLengthUTF8(const char *p) noexcept;
/** /**
* Convert the specified string from ISO-8859-1 to UTF-8. * Convert the specified string from ISO-8859-1 to UTF-8.
...@@ -67,7 +67,7 @@ SequenceLengthUTF8(const char *p); ...@@ -67,7 +67,7 @@ SequenceLengthUTF8(const char *p);
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
const char * const char *
Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size); Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size) noexcept;
/** /**
* Convert the specified Unicode character to UTF-8 and write it to * Convert the specified Unicode character to UTF-8 and write it to
...@@ -77,7 +77,7 @@ Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size); ...@@ -77,7 +77,7 @@ Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size);
*/ */
gcc_nonnull_all gcc_nonnull_all
char * char *
UnicodeToUTF8(unsigned ch, char *buffer); UnicodeToUTF8(unsigned ch, char *buffer) noexcept;
/** /**
* Returns the number of characters in the string. This is different * Returns the number of characters in the string. This is different
...@@ -85,6 +85,6 @@ UnicodeToUTF8(unsigned ch, char *buffer); ...@@ -85,6 +85,6 @@ UnicodeToUTF8(unsigned ch, char *buffer);
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
size_t size_t
LengthUTF8(const char *p); LengthUTF8(const char *p) noexcept;
#endif #endif
...@@ -39,7 +39,7 @@ IsValidSchemeChar(char ch) ...@@ -39,7 +39,7 @@ IsValidSchemeChar(char ch)
gcc_pure gcc_pure
static bool static bool
IsValidScheme(StringView p) IsValidScheme(StringView p) noexcept
{ {
if (p.IsEmpty() || !IsValidSchemeStart(p.front())) if (p.IsEmpty() || !IsValidSchemeStart(p.front()))
return false; return false;
...@@ -57,7 +57,7 @@ IsValidScheme(StringView p) ...@@ -57,7 +57,7 @@ IsValidScheme(StringView p)
*/ */
gcc_pure gcc_pure
static const char * static const char *
uri_after_scheme(const char *uri) uri_after_scheme(const char *uri) noexcept
{ {
if (uri[0] == '/' && uri[1] == '/' && uri[2] != '/') if (uri[0] == '/' && uri[1] == '/' && uri[2] != '/')
return uri + 2; return uri + 2;
...@@ -70,13 +70,14 @@ uri_after_scheme(const char *uri) ...@@ -70,13 +70,14 @@ uri_after_scheme(const char *uri)
: nullptr; : nullptr;
} }
bool uri_has_scheme(const char *uri) bool
uri_has_scheme(const char *uri) noexcept
{ {
return strstr(uri, "://") != nullptr; return strstr(uri, "://") != nullptr;
} }
std::string std::string
uri_get_scheme(const char *uri) uri_get_scheme(const char *uri) noexcept
{ {
const char *end = strstr(uri, "://"); const char *end = strstr(uri, "://");
if (end == nullptr) if (end == nullptr)
...@@ -86,7 +87,7 @@ uri_get_scheme(const char *uri) ...@@ -86,7 +87,7 @@ uri_get_scheme(const char *uri)
} }
const char * const char *
uri_get_path(const char *uri) uri_get_path(const char *uri) noexcept
{ {
const char *ap = uri_after_scheme(uri); const char *ap = uri_after_scheme(uri);
if (ap != nullptr) if (ap != nullptr)
...@@ -97,7 +98,7 @@ uri_get_path(const char *uri) ...@@ -97,7 +98,7 @@ uri_get_path(const char *uri)
/* suffixes should be ascii only characters */ /* suffixes should be ascii only characters */
const char * const char *
uri_get_suffix(const char *uri) uri_get_suffix(const char *uri) noexcept
{ {
const char *suffix = strrchr(uri, '.'); const char *suffix = strrchr(uri, '.');
if (suffix == nullptr || suffix == uri || if (suffix == nullptr || suffix == uri ||
...@@ -113,7 +114,7 @@ uri_get_suffix(const char *uri) ...@@ -113,7 +114,7 @@ uri_get_suffix(const char *uri)
} }
const char * const char *
uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) noexcept
{ {
const char *suffix = uri_get_suffix(uri); const char *suffix = uri_get_suffix(uri);
if (suffix == nullptr) if (suffix == nullptr)
...@@ -130,7 +131,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) ...@@ -130,7 +131,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer)
} }
static const char * static const char *
verify_uri_segment(const char *p) verify_uri_segment(const char *p) noexcept
{ {
unsigned dots = 0; unsigned dots = 0;
while (*p == '.') { while (*p == '.') {
...@@ -146,7 +147,7 @@ verify_uri_segment(const char *p) ...@@ -146,7 +147,7 @@ verify_uri_segment(const char *p)
} }
bool bool
uri_safe_local(const char *uri) uri_safe_local(const char *uri) noexcept
{ {
while (true) { while (true) {
uri = verify_uri_segment(uri); uri = verify_uri_segment(uri);
...@@ -164,7 +165,7 @@ uri_safe_local(const char *uri) ...@@ -164,7 +165,7 @@ uri_safe_local(const char *uri)
gcc_pure gcc_pure
static const char * static const char *
SkipUriScheme(const char *uri) SkipUriScheme(const char *uri) noexcept
{ {
const char *const schemes[] = { "http://", "https://", "ftp://" }; const char *const schemes[] = { "http://", "https://", "ftp://" };
for (auto scheme : schemes) { for (auto scheme : schemes) {
...@@ -177,7 +178,7 @@ SkipUriScheme(const char *uri) ...@@ -177,7 +178,7 @@ SkipUriScheme(const char *uri)
} }
std::string std::string
uri_remove_auth(const char *uri) uri_remove_auth(const char *uri) noexcept
{ {
const char *auth = SkipUriScheme(uri); const char *auth = SkipUriScheme(uri);
if (auth == nullptr) if (auth == nullptr)
...@@ -201,7 +202,7 @@ uri_remove_auth(const char *uri) ...@@ -201,7 +202,7 @@ uri_remove_auth(const char *uri)
} }
bool bool
uri_is_child(const char *parent, const char *child) uri_is_child(const char *parent, const char *child) noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
...@@ -216,13 +217,13 @@ uri_is_child(const char *parent, const char *child) ...@@ -216,13 +217,13 @@ uri_is_child(const char *parent, const char *child)
bool bool
uri_is_child_or_same(const char *parent, const char *child) uri_is_child_or_same(const char *parent, const char *child) noexcept
{ {
return strcmp(parent, child) == 0 || uri_is_child(parent, child); return strcmp(parent, child) == 0 || uri_is_child(parent, child);
} }
std::string std::string
uri_apply_base(const std::string &uri, const std::string &base) uri_apply_base(const std::string &uri, const std::string &base) noexcept
{ {
if (uri.front() == '/') { if (uri.front() == '/') {
/* absolute path: replace the whole URI path in base */ /* absolute path: replace the whole URI path in base */
......
...@@ -29,14 +29,15 @@ ...@@ -29,14 +29,15 @@
* "scheme://". * "scheme://".
*/ */
gcc_pure gcc_pure
bool uri_has_scheme(const char *uri); bool
uri_has_scheme(const char *uri) noexcept;
/** /**
* Returns the scheme name of the specified URI, or an empty string. * Returns the scheme name of the specified URI, or an empty string.
*/ */
gcc_pure gcc_pure
std::string std::string
uri_get_scheme(const char *uri); uri_get_scheme(const char *uri) noexcept;
/** /**
* Returns the URI path (including the query string) or nullptr if the * Returns the URI path (including the query string) or nullptr if the
...@@ -44,11 +45,11 @@ uri_get_scheme(const char *uri); ...@@ -44,11 +45,11 @@ uri_get_scheme(const char *uri);
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
const char * const char *
uri_get_path(const char *uri); uri_get_path(const char *uri) noexcept;
gcc_pure gcc_pure
const char * const char *
uri_get_suffix(const char *uri); uri_get_suffix(const char *uri) noexcept;
struct UriSuffixBuffer { struct UriSuffixBuffer {
char data[8]; char data[8];
...@@ -59,7 +60,7 @@ struct UriSuffixBuffer { ...@@ -59,7 +60,7 @@ struct UriSuffixBuffer {
*/ */
gcc_pure gcc_pure
const char * const char *
uri_get_suffix(const char *uri, UriSuffixBuffer &buffer); uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) noexcept;
/** /**
* Returns true if this is a safe "local" URI: * Returns true if this is a safe "local" URI:
...@@ -71,7 +72,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer); ...@@ -71,7 +72,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer);
*/ */
gcc_pure gcc_pure
bool bool
uri_safe_local(const char *uri); uri_safe_local(const char *uri) noexcept;
/** /**
* Removes HTTP username and password from the URI. This may be * Removes HTTP username and password from the URI. This may be
...@@ -81,7 +82,7 @@ uri_safe_local(const char *uri); ...@@ -81,7 +82,7 @@ uri_safe_local(const char *uri);
*/ */
gcc_pure gcc_pure
std::string std::string
uri_remove_auth(const char *uri); uri_remove_auth(const char *uri) noexcept;
/** /**
* Check whether #child specifies a resource "inside" the directory * Check whether #child specifies a resource "inside" the directory
...@@ -90,11 +91,11 @@ uri_remove_auth(const char *uri); ...@@ -90,11 +91,11 @@ uri_remove_auth(const char *uri);
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
bool bool
uri_is_child(const char *parent, const char *child); uri_is_child(const char *parent, const char *child) noexcept;
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
bool bool
uri_is_child_or_same(const char *parent, const char *child); uri_is_child_or_same(const char *parent, const char *child) noexcept;
/** /**
* Translate the given URI in the context of #base. For example, * Translate the given URI in the context of #base. For example,
...@@ -102,6 +103,6 @@ uri_is_child_or_same(const char *parent, const char *child); ...@@ -102,6 +103,6 @@ uri_is_child_or_same(const char *parent, const char *child);
*/ */
gcc_pure gcc_pure
std::string std::string
uri_apply_base(const std::string &uri, const std::string &base); uri_apply_base(const std::string &uri, const std::string &base) noexcept;
#endif #endif
/* /*
* Copyright (C) 2010-2015 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2010-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -36,70 +36,70 @@ ...@@ -36,70 +36,70 @@
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline size_t static inline size_t
StringLength(const wchar_t *p) StringLength(const wchar_t *p) noexcept
{ {
return wcslen(p); return wcslen(p);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const wchar_t * static inline const wchar_t *
StringFind(const wchar_t *haystack, const wchar_t *needle) StringFind(const wchar_t *haystack, const wchar_t *needle) noexcept
{ {
return wcsstr(haystack, needle); return wcsstr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const wchar_t * static inline const wchar_t *
StringFind(const wchar_t *haystack, wchar_t needle, size_t size) StringFind(const wchar_t *haystack, wchar_t needle, size_t size) noexcept
{ {
return wmemchr(haystack, needle, size); return wmemchr(haystack, needle, size);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline wchar_t * static inline wchar_t *
StringFind(wchar_t *haystack, wchar_t needle, size_t size) StringFind(wchar_t *haystack, wchar_t needle, size_t size) noexcept
{ {
return wmemchr(haystack, needle, size); return wmemchr(haystack, needle, size);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const wchar_t * static inline const wchar_t *
StringFind(const wchar_t *haystack, wchar_t needle) StringFind(const wchar_t *haystack, wchar_t needle) noexcept
{ {
return wcschr(haystack, needle); return wcschr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline wchar_t * static inline wchar_t *
StringFind(wchar_t *haystack, wchar_t needle) StringFind(wchar_t *haystack, wchar_t needle) noexcept
{ {
return wcschr(haystack, needle); return wcschr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline const wchar_t * static inline const wchar_t *
StringFindLast(const wchar_t *haystack, wchar_t needle) StringFindLast(const wchar_t *haystack, wchar_t needle) noexcept
{ {
return wcsrchr(haystack, needle); return wcsrchr(haystack, needle);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline wchar_t * static inline wchar_t *
StringFindLast(wchar_t *haystack, wchar_t needle) StringFindLast(wchar_t *haystack, wchar_t needle) noexcept
{ {
return wcsrchr(haystack, needle); return wcsrchr(haystack, needle);
} }
gcc_nonnull_all gcc_nonnull_all
static inline void static inline void
UnsafeCopyString(wchar_t *dest, const wchar_t *src) UnsafeCopyString(wchar_t *dest, const wchar_t *src) noexcept
{ {
wcscpy(dest, src); wcscpy(dest, src);
} }
gcc_nonnull_all gcc_nonnull_all
static inline wchar_t * static inline wchar_t *
UnsafeCopyStringP(wchar_t *dest, const wchar_t *src) UnsafeCopyStringP(wchar_t *dest, const wchar_t *src) noexcept
{ {
#if defined(WIN32) || defined(__BIONIC__) || defined(__OpenBSD__) || \ #if defined(WIN32) || defined(__BIONIC__) || defined(__OpenBSD__) || \
defined(__NetBSD__) defined(__NetBSD__)
...@@ -119,7 +119,7 @@ UnsafeCopyStringP(wchar_t *dest, const wchar_t *src) ...@@ -119,7 +119,7 @@ UnsafeCopyStringP(wchar_t *dest, const wchar_t *src)
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringIsEqual(const wchar_t *str1, const wchar_t *str2) StringIsEqual(const wchar_t *str1, const wchar_t *str2) noexcept
{ {
return wcscmp(str1, str2) == 0; return wcscmp(str1, str2) == 0;
} }
...@@ -129,7 +129,7 @@ StringIsEqual(const wchar_t *str1, const wchar_t *str2) ...@@ -129,7 +129,7 @@ StringIsEqual(const wchar_t *str1, const wchar_t *str2)
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringIsEqual(const wchar_t *a, const wchar_t *b, size_t length) StringIsEqual(const wchar_t *a, const wchar_t *b, size_t length) noexcept
{ {
return wcsncmp(a, b, length) == 0; return wcsncmp(a, b, length) == 0;
} }
......
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
#include <string.h> #include <string.h>
bool bool
StringStartsWith(const wchar_t *haystack, const wchar_t *needle) StringStartsWith(const wchar_t *haystack, const wchar_t *needle) noexcept
{ {
const size_t length = StringLength(needle); const size_t length = StringLength(needle);
return StringIsEqual(haystack, needle, length); return StringIsEqual(haystack, needle, length);
} }
bool bool
StringEndsWith(const wchar_t *haystack, const wchar_t *needle) StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept
{ {
const size_t haystack_length = StringLength(haystack); const size_t haystack_length = StringLength(haystack);
const size_t needle_length = StringLength(needle); const size_t needle_length = StringLength(needle);
...@@ -41,7 +41,7 @@ StringEndsWith(const wchar_t *haystack, const wchar_t *needle) ...@@ -41,7 +41,7 @@ StringEndsWith(const wchar_t *haystack, const wchar_t *needle)
} }
const wchar_t * const wchar_t *
StringAfterPrefix(const wchar_t *string, const wchar_t *prefix) StringAfterPrefix(const wchar_t *string, const wchar_t *prefix) noexcept
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
...@@ -56,7 +56,7 @@ StringAfterPrefix(const wchar_t *string, const wchar_t *prefix) ...@@ -56,7 +56,7 @@ StringAfterPrefix(const wchar_t *string, const wchar_t *prefix)
} }
const wchar_t * const wchar_t *
FindStringSuffix(const wchar_t *p, const wchar_t *suffix) FindStringSuffix(const wchar_t *p, const wchar_t *suffix) noexcept
{ {
const size_t p_length = StringLength(p); const size_t p_length = StringLength(p);
const size_t suffix_length = StringLength(suffix); const size_t suffix_length = StringLength(suffix);
......
...@@ -42,20 +42,20 @@ StringIsEmpty(const wchar_t *string) ...@@ -42,20 +42,20 @@ StringIsEmpty(const wchar_t *string)
gcc_pure gcc_pure
bool bool
StringStartsWith(const wchar_t *haystack, const wchar_t *needle); StringStartsWith(const wchar_t *haystack, const wchar_t *needle) noexcept;
gcc_pure gcc_pure
bool bool
StringEndsWith(const wchar_t *haystack, const wchar_t *needle); StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept;
/** /**
* Returns the portion of the string after a prefix. If the string * Returns the portion of the string after a prefix. If the string
* does not begin with the specified prefix, this function returns * does not begin with the specified prefix, this function returns
* nullptr. * nullptr.
*/ */
gcc_nonnull_all gcc_pure gcc_nonnull_all
const wchar_t * const wchar_t *
StringAfterPrefix(const wchar_t *string, const wchar_t *prefix); StringAfterPrefix(const wchar_t *string, const wchar_t *prefix) noexcept;
/** /**
* Check if the given string ends with the specified suffix. If yes, * Check if the given string ends with the specified suffix. If yes,
...@@ -63,6 +63,6 @@ StringAfterPrefix(const wchar_t *string, const wchar_t *prefix); ...@@ -63,6 +63,6 @@ StringAfterPrefix(const wchar_t *string, const wchar_t *prefix);
*/ */
gcc_pure gcc_pure
const wchar_t * const wchar_t *
FindStringSuffix(const wchar_t *p, const wchar_t *suffix); FindStringSuffix(const wchar_t *p, const wchar_t *suffix) noexcept;
#endif #endif
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
const char * const char *
config_get_string(gcc_unused enum ConfigOption option, config_get_string(gcc_unused enum ConfigOption option,
const char *default_value) const char *default_value) noexcept
{ {
return default_value; return default_value;
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <stdlib.h> #include <stdlib.h>
const FilterPlugin * const FilterPlugin *
filter_plugin_by_name(gcc_unused const char *name) filter_plugin_by_name(gcc_unused const char *name) noexcept
{ {
assert(false); assert(false);
return NULL; return NULL;
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
}; };
const FilterPlugin * const FilterPlugin *
filter_plugin_by_name(gcc_unused const char *name) filter_plugin_by_name(gcc_unused const char *name) noexcept
{ {
assert(false); assert(false);
return NULL; return NULL;
......
...@@ -32,7 +32,7 @@ public: ...@@ -32,7 +32,7 @@ public:
} }
/* virtual methods from InputStream */ /* virtual methods from InputStream */
bool IsEOF() override { bool IsEOF() noexcept override {
return remaining == 0; return remaining == 0;
} }
......
...@@ -32,7 +32,7 @@ Log(const Domain &domain, gcc_unused LogLevel level, const char *msg) ...@@ -32,7 +32,7 @@ Log(const Domain &domain, gcc_unused LogLevel level, const char *msg)
} }
bool bool
uri_supported_scheme(const char *uri) uri_supported_scheme(const char *uri) noexcept
{ {
return strncmp(uri, "http://", 7) == 0; return strncmp(uri, "http://", 7) == 0;
} }
...@@ -130,13 +130,13 @@ DetachedSong::LoadFile(Path path) ...@@ -130,13 +130,13 @@ DetachedSong::LoadFile(Path path)
} }
const Database * const Database *
Client::GetDatabase() const Client::GetDatabase() const noexcept
{ {
return reinterpret_cast<const Database *>(this); return reinterpret_cast<const Database *>(this);
} }
const Storage * const Storage *
Client::GetStorage() const Client::GetStorage() const noexcept
{ {
return ::storage; return ::storage;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment