[clang-tidy] use nodiscard
Introduced in C++17. It replaces gcc's warn_unused_result. Found with modernize-use-nodiscard. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
2229e86673
commit
f00f8b002a
@ -72,7 +72,7 @@ public:
|
||||
~Bzip2InputStream() override;
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
bool IsEOF() const noexcept override;
|
||||
[[nodiscard]] bool IsEOF() const noexcept override;
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
|
||||
|
@ -167,7 +167,7 @@ public:
|
||||
}
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
bool IsEOF() const noexcept override;
|
||||
[[nodiscard]] bool IsEOF() const noexcept override;
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
|
||||
|
@ -111,7 +111,7 @@ public:
|
||||
}
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
bool IsEOF() const noexcept override;
|
||||
[[nodiscard]] bool IsEOF() const noexcept override;
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
LibmpdclientError(enum mpd_error _code, const char *_msg)
|
||||
:std::runtime_error(_msg), code(_code) {}
|
||||
|
||||
enum mpd_error GetCode() const {
|
||||
[[nodiscard]] enum mpd_error GetCode() const {
|
||||
return code;
|
||||
}
|
||||
};
|
||||
|
@ -95,12 +95,12 @@ public:
|
||||
VisitSong visit_song,
|
||||
VisitPlaylist visit_playlist) const override;
|
||||
|
||||
RecursiveMap<std::string> CollectUniqueTags(const DatabaseSelection &selection,
|
||||
[[nodiscard]] RecursiveMap<std::string> CollectUniqueTags(const DatabaseSelection &selection,
|
||||
ConstBuffer<TagType> tag_types) const override;
|
||||
|
||||
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
||||
[[nodiscard]] DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
||||
|
||||
std::chrono::system_clock::time_point GetUpdateStamp() const noexcept override {
|
||||
[[nodiscard]] std::chrono::system_clock::time_point GetUpdateStamp() const noexcept override {
|
||||
return std::chrono::system_clock::time_point::min();
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ private:
|
||||
* except easier cause our inodes have a parent id. Not used
|
||||
* any more actually (see comments in SearchSongs).
|
||||
*/
|
||||
std::string BuildPath(const ContentDirectoryService &server,
|
||||
[[nodiscard]] std::string BuildPath(const ContentDirectoryService &server,
|
||||
const UPnPDirObject& dirent) const;
|
||||
};
|
||||
|
||||
|
@ -61,10 +61,10 @@ struct WatchDirectory {
|
||||
WatchDirectory(const WatchDirectory &) = delete;
|
||||
WatchDirectory &operator=(const WatchDirectory &) = delete;
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
unsigned GetDepth() const noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
AllocatedPath GetUriFS() const noexcept;
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,7 @@ struct DsdiffChunkHeader {
|
||||
* Read the "size" attribute from the specified header, converting it
|
||||
* to the host byte order if needed.
|
||||
*/
|
||||
constexpr
|
||||
[[nodiscard]] constexpr
|
||||
uint64_t GetSize() const {
|
||||
return size.Read();
|
||||
}
|
||||
|
@ -146,10 +146,10 @@ private:
|
||||
void ParseId3(size_t tagsize, Tag *tag) noexcept;
|
||||
MadDecoderAction DecodeNextFrame(bool skip, Tag *tag) noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
offset_type ThisFrameOffset() const noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
offset_type RestIncludingThisFrame() const noexcept;
|
||||
|
||||
/**
|
||||
@ -168,7 +168,7 @@ private:
|
||||
times = new mad_timer_t[max_frames];
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
size_t TimeToFrame(SongTime t) const noexcept;
|
||||
|
||||
/**
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
/**
|
||||
* Has DecoderClient::Ready() been called yet?
|
||||
*/
|
||||
bool IsInitialized() const {
|
||||
[[nodiscard]] bool IsInitialized() const {
|
||||
return previous_channels != 0;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
return ::CheckAudioFormat(vi.rate, sample_format, vi.channels);
|
||||
}
|
||||
|
||||
AudioFormat CheckAudioFormat() const {
|
||||
[[nodiscard]] AudioFormat CheckAudioFormat() const {
|
||||
return CheckAudioFormat(vi);
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ struct WavpackInput {
|
||||
|
||||
int32_t ReadBytes(void *data, size_t bcount);
|
||||
|
||||
InputStream::offset_type GetPos() const {
|
||||
[[nodiscard]] InputStream::offset_type GetPos() const {
|
||||
return is.GetOffset();
|
||||
}
|
||||
|
||||
@ -337,14 +337,14 @@ struct WavpackInput {
|
||||
}
|
||||
}
|
||||
|
||||
InputStream::offset_type GetLength() const {
|
||||
[[nodiscard]] InputStream::offset_type GetLength() const {
|
||||
if (!is.KnownSize())
|
||||
return 0;
|
||||
|
||||
return is.GetSize();
|
||||
}
|
||||
|
||||
bool CanSeek() const {
|
||||
[[nodiscard]] bool CanSeek() const {
|
||||
return is.IsSeekable();
|
||||
}
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const noexcept override {
|
||||
[[nodiscard]] const char *GetMimeType() const noexcept override {
|
||||
return "audio/flac";
|
||||
}
|
||||
};
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const noexcept override {
|
||||
[[nodiscard]] const char *GetMimeType() const noexcept override {
|
||||
return "audio/mpeg";
|
||||
}
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const noexcept override {
|
||||
[[nodiscard]] const char *GetMimeType() const noexcept override {
|
||||
return "audio/ogg";
|
||||
}
|
||||
};
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const noexcept override {
|
||||
[[nodiscard]] const char *GetMimeType() const noexcept override {
|
||||
return "audio/mpeg";
|
||||
}
|
||||
};
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const noexcept override {
|
||||
[[nodiscard]] const char *GetMimeType() const noexcept override {
|
||||
return "audio/ogg";
|
||||
}
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ class PreparedWaveEncoder final : public PreparedEncoder {
|
||||
return new WaveEncoder(audio_format);
|
||||
}
|
||||
|
||||
const char *GetMimeType() const noexcept override {
|
||||
[[nodiscard]] const char *GetMimeType() const noexcept override {
|
||||
return "audio/wav";
|
||||
}
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
Close();
|
||||
}
|
||||
|
||||
unsigned GetSerial() const noexcept {
|
||||
[[nodiscard]] unsigned GetSerial() const noexcept {
|
||||
return serial;
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ public:
|
||||
using SocketMonitor::IsDefined;
|
||||
using SocketMonitor::Close;
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
std::string ToString() const noexcept {
|
||||
return ::ToString(address);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
true);
|
||||
}
|
||||
|
||||
unsigned GetVolume() const noexcept {
|
||||
[[nodiscard]] unsigned GetVolume() const noexcept {
|
||||
return pv.GetVolume();
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
ProxyInputStream::Update();
|
||||
}
|
||||
|
||||
bool IsEOF() const noexcept override {
|
||||
[[nodiscard]] bool IsEOF() const noexcept override {
|
||||
return !ReadingFromBuffer() && ProxyInputStream::IsEOF();
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ private:
|
||||
* Are we currently reading from the buffer, and does the
|
||||
* buffer contain more data for the next read operation?
|
||||
*/
|
||||
bool ReadingFromBuffer() const noexcept {
|
||||
[[nodiscard]] bool ReadingFromBuffer() const noexcept {
|
||||
return tail > 0 && offset < input->GetOffset();
|
||||
}
|
||||
};
|
||||
|
@ -160,22 +160,22 @@ public:
|
||||
audio_format = ParseAudioFormat(format_string, false);
|
||||
}
|
||||
}
|
||||
bool IsValidScheme() const noexcept {
|
||||
[[nodiscard]] bool IsValidScheme() const noexcept {
|
||||
return device_name != nullptr;
|
||||
}
|
||||
bool IsValid() const noexcept {
|
||||
[[nodiscard]] bool IsValid() const noexcept {
|
||||
return (device_name != nullptr) && (format_string != nullptr);
|
||||
}
|
||||
const char *GetURI() const noexcept {
|
||||
[[nodiscard]] const char *GetURI() const noexcept {
|
||||
return uri;
|
||||
}
|
||||
const char *GetDeviceName() const noexcept {
|
||||
[[nodiscard]] const char *GetDeviceName() const noexcept {
|
||||
return device_name;
|
||||
}
|
||||
const char *GetFormatString() const noexcept {
|
||||
[[nodiscard]] const char *GetFormatString() const noexcept {
|
||||
return format_string;
|
||||
}
|
||||
AudioFormat GetAudioFormat() const noexcept {
|
||||
[[nodiscard]] AudioFormat GetAudioFormat() const noexcept {
|
||||
return audio_format;
|
||||
}
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ class CdioParanoiaInputStream final : public InputStream {
|
||||
}
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
bool IsEOF() const noexcept override;
|
||||
[[nodiscard]] bool IsEOF() const noexcept override;
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
}
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
bool IsEOF() const noexcept override;
|
||||
[[nodiscard]] bool IsEOF() const noexcept override;
|
||||
size_t Read(std::unique_lock<Mutex> &lock,
|
||||
void *ptr, size_t size) override;
|
||||
void Seek(std::unique_lock<Mutex> &lock,
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
|
||||
bool IsEOF() const noexcept override {
|
||||
[[nodiscard]] bool IsEOF() const noexcept override {
|
||||
return GetOffset() >= GetSize();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
|
||||
bool IsEOF() const noexcept override {
|
||||
[[nodiscard]] bool IsEOF() const noexcept override {
|
||||
return offset >= size;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class SmbclientNeighborExplorer final : public NeighborExplorer {
|
||||
return name == other.name;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
NeighborInfo Export() const noexcept {
|
||||
return { "smb://" + name + "/", comment };
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class UpnpNeighborExplorer final
|
||||
return name == other.name;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
NeighborInfo Export() const noexcept {
|
||||
return { "smb://" + name + "/", comment };
|
||||
}
|
||||
@ -62,7 +62,7 @@ public:
|
||||
/* virtual methods from class NeighborExplorer */
|
||||
void Open() override;
|
||||
void Close() noexcept override;
|
||||
List GetList() const noexcept override;
|
||||
[[nodiscard]] List GetList() const noexcept override;
|
||||
|
||||
private:
|
||||
/* virtual methods from class UPnPDiscoveryListener */
|
||||
|
@ -64,7 +64,7 @@ private:
|
||||
void Open(AudioFormat &audio_format) override;
|
||||
void Close() noexcept override;
|
||||
|
||||
std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
[[nodiscard]] std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
size_t Play(const void *chunk, size_t size) override;
|
||||
void Cancel() noexcept override;
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
delete timer;
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::duration Delay() const noexcept override {
|
||||
[[nodiscard]] std::chrono::steady_clock::duration Delay() const noexcept override {
|
||||
return sync && timer->IsStarted()
|
||||
? timer->GetDelay()
|
||||
: std::chrono::steady_clock::duration::zero();
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
void Open(AudioFormat &audio_format) override;
|
||||
void Close() noexcept override;
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
std::chrono::steady_clock::duration Delay() const noexcept override {
|
||||
return filled < NUM_BUFFERS || HasProcessed()
|
||||
? std::chrono::steady_clock::duration::zero()
|
||||
@ -71,19 +71,19 @@ private:
|
||||
void Cancel() noexcept override;
|
||||
|
||||
private:
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
ALint GetSourceI(ALenum param) const noexcept {
|
||||
ALint value;
|
||||
alGetSourcei(source, param, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
bool HasProcessed() const noexcept {
|
||||
return GetSourceI(AL_BUFFERS_PROCESSED) > 0;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
bool IsPlaying() const noexcept {
|
||||
return GetSourceI(AL_SOURCE_STATE) == AL_PLAYING;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
void Open(AudioFormat &audio_format) override;
|
||||
void Close() noexcept override;
|
||||
|
||||
std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
[[nodiscard]] std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
size_t Play(const void *chunk, size_t size) override;
|
||||
void Cancel() noexcept override;
|
||||
bool Pause() override;
|
||||
|
@ -88,7 +88,7 @@ private:
|
||||
size_t Play(const void *chunk, size_t size) override;
|
||||
|
||||
private:
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
bool HasDynamicPath() const noexcept {
|
||||
return !format_path.empty();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ struct ShoutOutput final : AudioOutput {
|
||||
void Open(AudioFormat &audio_format) override;
|
||||
void Close() noexcept override;
|
||||
|
||||
std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
[[nodiscard]] std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
void SendTag(const Tag &tag) override;
|
||||
size_t Play(const void *chunk, size_t size) override;
|
||||
void Cancel() noexcept override;
|
||||
|
@ -44,7 +44,7 @@ class PcmDither;
|
||||
*
|
||||
* @return true on success, false if the format is not supported
|
||||
*/
|
||||
gcc_warn_unused_result
|
||||
[[nodiscard]]
|
||||
bool
|
||||
pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
|
||||
SampleFormat format, float portion1) noexcept;
|
||||
|
@ -252,7 +252,7 @@ private:
|
||||
* Note: this function does not check if the decoder is already
|
||||
* finished.
|
||||
*/
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
bool IsDecoderAtCurrentSong() const noexcept {
|
||||
assert(pipe != nullptr);
|
||||
|
||||
@ -264,7 +264,7 @@ private:
|
||||
* decoding it, or has finished doing it), and the player hasn't
|
||||
* switched to that song yet.
|
||||
*/
|
||||
gcc_pure
|
||||
[[nodiscard]] gcc_pure
|
||||
bool IsDecoderAtNextSong() const noexcept {
|
||||
return dc.pipe != nullptr && !IsDecoderAtCurrentSong();
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ struct DavResponse {
|
||||
std::chrono::system_clock::time_point::min();
|
||||
uint64_t length = 0;
|
||||
|
||||
bool Check() const {
|
||||
[[nodiscard]] bool Check() const {
|
||||
return !href.empty();
|
||||
}
|
||||
};
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
EventLoop &GetEventLoop() const noexcept {
|
||||
[[nodiscard]] EventLoop &GetEventLoop() const noexcept {
|
||||
return defer_connect.GetEventLoop();
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ public:
|
||||
:BlockingNfsOperation(_connection), path(_path),
|
||||
follow(_follow) {}
|
||||
|
||||
const StorageFileInfo &GetInfo() const {
|
||||
[[nodiscard]] const StorageFileInfo &GetInfo() const {
|
||||
return info;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user