From 220d2bf0261c32fdf2ecd7c5b5239336200bd8ee Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 30 May 2021 22:46:50 -0700 Subject: [PATCH] clang-tidy: add explicit deleted constructors Found with cppcoreguidelines-special-member-functions Signed-off-by: Rosen Penev --- src/archive/plugins/Bzip2ArchivePlugin.cxx | 3 +++ src/archive/plugins/ZzipArchivePlugin.cxx | 3 +++ src/db/plugins/ProxyDatabasePlugin.cxx | 3 +++ src/decoder/plugins/MadDecoderPlugin.cxx | 3 +++ src/decoder/plugins/OpusDecoderPlugin.cxx | 3 +++ src/decoder/plugins/VorbisDecoderPlugin.cxx | 3 +++ src/encoder/plugins/FlacEncoderPlugin.cxx | 3 +++ src/encoder/plugins/LameEncoderPlugin.cxx | 3 +++ src/encoder/plugins/OpusEncoderPlugin.cxx | 3 +++ src/encoder/plugins/TwolameEncoderPlugin.cxx | 3 +++ src/encoder/plugins/VorbisEncoderPlugin.cxx | 3 +++ src/filter/Observer.cxx | 6 ++++++ src/filter/plugins/NormalizeFilterPlugin.cxx | 4 ++++ src/input/InputStream.hxx | 3 +++ src/input/plugins/AlsaInputPlugin.cxx | 3 +++ src/input/plugins/CdioParanoiaInputPlugin.cxx | 3 +++ src/input/plugins/MmsInputPlugin.cxx | 3 +++ src/input/plugins/NfsInputPlugin.cxx | 3 +++ src/input/plugins/QobuzInputPlugin.cxx | 3 +++ src/input/plugins/TidalInputPlugin.cxx | 3 +++ src/lib/curl/Global.cxx | 3 +++ src/mixer/plugins/AlsaMixerPlugin.cxx | 6 ++++++ src/mixer/plugins/PulseMixerPlugin.cxx | 3 +++ src/neighbor/plugins/UpnpNeighborPlugin.cxx | 1 + src/output/plugins/AlsaOutputPlugin.cxx | 3 +++ src/output/plugins/AoOutputPlugin.cxx | 6 ++++++ src/output/plugins/FifoOutputPlugin.cxx | 3 +++ src/output/plugins/ShoutOutputPlugin.cxx | 3 +++ src/storage/plugins/NfsStorage.cxx | 3 +++ src/storage/plugins/UdisksStorage.cxx | 3 +++ 30 files changed, 98 insertions(+) diff --git a/src/archive/plugins/Bzip2ArchivePlugin.cxx b/src/archive/plugins/Bzip2ArchivePlugin.cxx index 4692d1409..e440007d3 100644 --- a/src/archive/plugins/Bzip2ArchivePlugin.cxx +++ b/src/archive/plugins/Bzip2ArchivePlugin.cxx @@ -71,6 +71,9 @@ public: Mutex &mutex); ~Bzip2InputStream() noexcept override; + Bzip2InputStream(const Bzip2InputStream &) = delete; + Bzip2InputStream &operator=(const Bzip2InputStream &) = delete; + /* virtual methods from InputStream */ [[nodiscard]] bool IsEOF() const noexcept override; size_t Read(std::unique_lock &lock, diff --git a/src/archive/plugins/ZzipArchivePlugin.cxx b/src/archive/plugins/ZzipArchivePlugin.cxx index 3d7d5dabd..dc6050d70 100644 --- a/src/archive/plugins/ZzipArchivePlugin.cxx +++ b/src/archive/plugins/ZzipArchivePlugin.cxx @@ -116,6 +116,9 @@ public: zzip_file_close(file); } + ZzipInputStream(const ZzipInputStream &) = delete; + ZzipInputStream &operator=(const ZzipInputStream &) = delete; + /* virtual methods from InputStream */ [[nodiscard]] bool IsEOF() const noexcept override; size_t Read(std::unique_lock &lock, diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 83f29f38f..6f8aaeca2 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -83,6 +83,9 @@ public: ~AllocatedProxySong() { mpd_song_free(song); } + + AllocatedProxySong(const AllocatedProxySong &) = delete; + AllocatedProxySong &operator=(const AllocatedProxySong &) = delete; }; class ProxyDatabase final : public Database { diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 7b6c98eec..557efdfd4 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -138,6 +138,9 @@ public: MadDecoder(DecoderClient *client, InputStream &input_stream) noexcept; ~MadDecoder() noexcept; + MadDecoder(const MadDecoder &) = delete; + MadDecoder &operator=(const MadDecoder &) = delete; + void RunDecoder() noexcept; bool RunScan(TagHandler &handler) noexcept; diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx index 96d5febc6..18216ed31 100644 --- a/src/decoder/plugins/OpusDecoderPlugin.cxx +++ b/src/decoder/plugins/OpusDecoderPlugin.cxx @@ -137,6 +137,9 @@ public: ~MPDOpusDecoder(); + MPDOpusDecoder(const MPDOpusDecoder &) = delete; + MPDOpusDecoder &operator=(const MPDOpusDecoder &) = delete; + /** * Has DecoderClient::Ready() been called yet? */ diff --git a/src/decoder/plugins/VorbisDecoderPlugin.cxx b/src/decoder/plugins/VorbisDecoderPlugin.cxx index 96d4e315a..9ed642cb1 100644 --- a/src/decoder/plugins/VorbisDecoderPlugin.cxx +++ b/src/decoder/plugins/VorbisDecoderPlugin.cxx @@ -80,6 +80,9 @@ public: DeinitVorbis(); } + VorbisDecoder(const VorbisDecoder &) = delete; + VorbisDecoder &operator=(const VorbisDecoder &) = delete; + bool Seek(uint64_t where_frame); static AudioFormat CheckAudioFormat(const vorbis_info &vi) { diff --git a/src/encoder/plugins/FlacEncoderPlugin.cxx b/src/encoder/plugins/FlacEncoderPlugin.cxx index 352434f41..d55715db5 100644 --- a/src/encoder/plugins/FlacEncoderPlugin.cxx +++ b/src/encoder/plugins/FlacEncoderPlugin.cxx @@ -54,6 +54,9 @@ public: FLAC__stream_encoder_delete(fse); } + FlacEncoder(const FlacEncoder &) = delete; + FlacEncoder &operator=(const FlacEncoder &) = delete; + /* virtual methods from class Encoder */ void End() override { (void) FLAC__stream_encoder_finish(fse); diff --git a/src/encoder/plugins/LameEncoderPlugin.cxx b/src/encoder/plugins/LameEncoderPlugin.cxx index d579e92ed..7bfd87801 100644 --- a/src/encoder/plugins/LameEncoderPlugin.cxx +++ b/src/encoder/plugins/LameEncoderPlugin.cxx @@ -47,6 +47,9 @@ public: ~LameEncoder() noexcept override; + LameEncoder(const LameEncoder &) = delete; + LameEncoder &operator=(const LameEncoder &) = delete; + /* virtual methods from class Encoder */ void Write(const void *data, size_t length) override; size_t Read(void *dest, size_t length) noexcept override; diff --git a/src/encoder/plugins/OpusEncoderPlugin.cxx b/src/encoder/plugins/OpusEncoderPlugin.cxx index 717e5f998..3df05c9f9 100644 --- a/src/encoder/plugins/OpusEncoderPlugin.cxx +++ b/src/encoder/plugins/OpusEncoderPlugin.cxx @@ -56,6 +56,9 @@ public: OpusEncoder(AudioFormat &_audio_format, ::OpusEncoder *_enc, bool _chaining); ~OpusEncoder() noexcept override; + OpusEncoder(const OpusEncoder &) = delete; + OpusEncoder &operator=(const OpusEncoder &) = delete; + /* virtual methods from class Encoder */ void End() override; void Write(const void *data, size_t length) override; diff --git a/src/encoder/plugins/TwolameEncoderPlugin.cxx b/src/encoder/plugins/TwolameEncoderPlugin.cxx index 664fec7d0..c8e43de33 100644 --- a/src/encoder/plugins/TwolameEncoderPlugin.cxx +++ b/src/encoder/plugins/TwolameEncoderPlugin.cxx @@ -54,6 +54,9 @@ public: audio_format(_audio_format), options(_options) {} ~TwolameEncoder() noexcept override; + TwolameEncoder(const TwolameEncoder &) = delete; + TwolameEncoder &operator=(const TwolameEncoder &) = delete; + /* virtual methods from class Encoder */ void End() override { diff --git a/src/encoder/plugins/VorbisEncoderPlugin.cxx b/src/encoder/plugins/VorbisEncoderPlugin.cxx index c460ab94e..906fd473e 100644 --- a/src/encoder/plugins/VorbisEncoderPlugin.cxx +++ b/src/encoder/plugins/VorbisEncoderPlugin.cxx @@ -44,6 +44,9 @@ public: vorbis_info_clear(&vi); } + VorbisEncoder(const VorbisEncoder &) = delete; + VorbisEncoder &operator=(const VorbisEncoder &) = delete; + /* virtual methods from class Encoder */ void End() override { PreTag(); diff --git a/src/filter/Observer.cxx b/src/filter/Observer.cxx index eb32c31c7..53fac21d2 100644 --- a/src/filter/Observer.cxx +++ b/src/filter/Observer.cxx @@ -43,6 +43,9 @@ public: observer.proxy = nullptr; } + PreparedProxy(const PreparedProxy &) = delete; + PreparedProxy &operator=(const PreparedProxy &) = delete; + void Clear([[maybe_unused]] Proxy *_child) noexcept { assert(child == _child); child = nullptr; @@ -67,6 +70,9 @@ public: parent.Clear(this); } + Proxy(const Proxy &) = delete; + Proxy &operator=(const Proxy &) = delete; + Filter *Get() noexcept { return filter.get(); } diff --git a/src/filter/plugins/NormalizeFilterPlugin.cxx b/src/filter/plugins/NormalizeFilterPlugin.cxx index 268f233ba..15ffb4353 100644 --- a/src/filter/plugins/NormalizeFilterPlugin.cxx +++ b/src/filter/plugins/NormalizeFilterPlugin.cxx @@ -42,6 +42,10 @@ public: Compressor_delete(compressor); } + + NormalizeFilter(const NormalizeFilter &) = delete; + NormalizeFilter &operator=(const NormalizeFilter &) = delete; + /* virtual methods from class Filter */ ConstBuffer FilterPCM(ConstBuffer src) override; }; diff --git a/src/input/InputStream.hxx b/src/input/InputStream.hxx index 041e037ee..e8a13dfc1 100644 --- a/src/input/InputStream.hxx +++ b/src/input/InputStream.hxx @@ -107,6 +107,9 @@ public: */ virtual ~InputStream() noexcept; + InputStream(const InputStream &) = delete; + InputStream &operator=(const InputStream &) = delete; + /** * Opens a new input stream. You may not access it until the "ready" * flag is set. diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx index ea680afd9..2c49d0d6e 100644 --- a/src/input/plugins/AlsaInputPlugin.cxx +++ b/src/input/plugins/AlsaInputPlugin.cxx @@ -99,6 +99,9 @@ public: snd_pcm_close(capture_handle); } + AlsaInputStream(const AlsaInputStream &) = delete; + AlsaInputStream &operator=(const AlsaInputStream &) = delete; + static InputStreamPtr Create(EventLoop &event_loop, const char *uri, Mutex &mutex); diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index be7448fab..63b3a0286 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -88,6 +88,9 @@ class CdioParanoiaInputStream final : public InputStream { cdio_destroy(cdio); } + CdioParanoiaInputStream(const CdioParanoiaInputStream &) = delete; + CdioParanoiaInputStream &operator=(const CdioParanoiaInputStream &) = delete; + /* virtual methods from InputStream */ [[nodiscard]] bool IsEOF() const noexcept override; size_t Read(std::unique_lock &lock, diff --git a/src/input/plugins/MmsInputPlugin.cxx b/src/input/plugins/MmsInputPlugin.cxx index 62bc72745..56304ce23 100644 --- a/src/input/plugins/MmsInputPlugin.cxx +++ b/src/input/plugins/MmsInputPlugin.cxx @@ -41,6 +41,9 @@ public: Stop(); } + MmsInputStream(const MmsInputStream &) = delete; + MmsInputStream &operator=(const MmsInputStream &) = delete; + protected: void Open() override; size_t ThreadRead(void *ptr, size_t size) override; diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx index 8412460fb..591f62b51 100644 --- a/src/input/plugins/NfsInputPlugin.cxx +++ b/src/input/plugins/NfsInputPlugin.cxx @@ -51,6 +51,9 @@ public: DeferClose(); } + NfsInputStream(const NfsInputStream &) = delete; + NfsInputStream &operator=(const NfsInputStream &) = delete; + void Open() { assert(!IsReady()); diff --git a/src/input/plugins/QobuzInputPlugin.cxx b/src/input/plugins/QobuzInputPlugin.cxx index 5d3183a55..d3f43adc3 100644 --- a/src/input/plugins/QobuzInputPlugin.cxx +++ b/src/input/plugins/QobuzInputPlugin.cxx @@ -57,6 +57,9 @@ public: qobuz_client->RemoveLoginHandler(*this); } + QobuzInputStream(const QobuzInputStream &) = delete; + QobuzInputStream &operator=(const QobuzInputStream &) = delete; + /* virtual methods from InputStream */ void Check() override { diff --git a/src/input/plugins/TidalInputPlugin.cxx b/src/input/plugins/TidalInputPlugin.cxx index 1781d16ae..7f9c27cf1 100644 --- a/src/input/plugins/TidalInputPlugin.cxx +++ b/src/input/plugins/TidalInputPlugin.cxx @@ -70,6 +70,9 @@ public: tidal_session->RemoveLoginHandler(*this); } + TidalInputStream(const TidalInputStream &) = delete; + TidalInputStream &operator=(const TidalInputStream &) = delete; + /* virtual methods from InputStream */ void Check() override { diff --git a/src/lib/curl/Global.cxx b/src/lib/curl/Global.cxx index a43699f57..94c4def59 100644 --- a/src/lib/curl/Global.cxx +++ b/src/lib/curl/Global.cxx @@ -57,6 +57,9 @@ public: better solution? */ } + CurlSocket(const CurlSocket &) = delete; + CurlSocket &operator=(const CurlSocket &) = delete; + auto &GetEventLoop() const noexcept { return socket_event.GetEventLoop(); } diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index 1562e6112..0ed09f281 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -63,6 +63,9 @@ public: }); } + AlsaMixerMonitor(const AlsaMixerMonitor &) = delete; + AlsaMixerMonitor &operator=(const AlsaMixerMonitor &) = delete; + private: Event::Duration PrepareSockets() noexcept override; void DispatchSockets() noexcept override; @@ -87,6 +90,9 @@ public: ~AlsaMixer() override; + AlsaMixer(const AlsaMixer &) = delete; + AlsaMixer &operator=(const AlsaMixer &) = delete; + void Configure(const ConfigBlock &block); void Setup(); diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx index 6154e434d..bf54efa1e 100644 --- a/src/mixer/plugins/PulseMixerPlugin.cxx +++ b/src/mixer/plugins/PulseMixerPlugin.cxx @@ -55,6 +55,9 @@ public: ~PulseMixer() override; + PulseMixer(const PulseMixer &) = delete; + PulseMixer &operator=(const PulseMixer &) = delete; + void Offline(); void VolumeCallback(const pa_sink_input_info *i, int eol); void Update(pa_context *context, pa_stream *stream); diff --git a/src/neighbor/plugins/UpnpNeighborPlugin.cxx b/src/neighbor/plugins/UpnpNeighborPlugin.cxx index 331076517..821ece602 100644 --- a/src/neighbor/plugins/UpnpNeighborPlugin.cxx +++ b/src/neighbor/plugins/UpnpNeighborPlugin.cxx @@ -38,6 +38,7 @@ class UpnpNeighborExplorer final :name(std::move(_name)), comment(std::move(_comment)), alive(true) {} Server(const Server &) = delete; + Server &operator=(const Server &) = delete; gcc_pure bool operator==(const Server &other) const noexcept { diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index af3c48716..ee7454964 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -226,6 +226,9 @@ public: snd_config_update_free_global(); } + AlsaOutput(const AlsaOutput &) = delete; + AlsaOutput &operator=(const AlsaOutput &) = delete; + using MultiSocketMonitor::GetEventLoop; gcc_pure diff --git a/src/output/plugins/AoOutputPlugin.cxx b/src/output/plugins/AoOutputPlugin.cxx index 17ae1382c..bf86bb4c4 100644 --- a/src/output/plugins/AoOutputPlugin.cxx +++ b/src/output/plugins/AoOutputPlugin.cxx @@ -42,6 +42,9 @@ public: ~AoInit() noexcept { ao_shutdown(); } + + AoInit(const AoInit &) = delete; + AoInit &operator=(const AoInit &) = delete; }; class AoOutput final : AudioOutput, SafeSingleton { @@ -55,6 +58,9 @@ class AoOutput final : AudioOutput, SafeSingleton { explicit AoOutput(const ConfigBlock &block); ~AoOutput() override; + AoOutput(const AoOutput &) = delete; + AoOutput &operator=(const AoOutput &) = delete; + public: static AudioOutput *Create(EventLoop &, const ConfigBlock &block) { return new AoOutput(block); diff --git a/src/output/plugins/FifoOutputPlugin.cxx b/src/output/plugins/FifoOutputPlugin.cxx index bbf7e0c16..8727cb4e1 100644 --- a/src/output/plugins/FifoOutputPlugin.cxx +++ b/src/output/plugins/FifoOutputPlugin.cxx @@ -49,6 +49,9 @@ public: CloseFifo(); } + FifoOutput(const FifoOutput &) = delete; + FifoOutput &operator=(const FifoOutput &) = delete; + static AudioOutput *Create(EventLoop &, const ConfigBlock &block) { return new FifoOutput(block); diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 3496739da..4900172b5 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -51,6 +51,9 @@ struct ShoutOutput final : AudioOutput { explicit ShoutOutput(const ConfigBlock &block); ~ShoutOutput() override; + ShoutOutput(const ShoutOutput &) = delete; + ShoutOutput &operator=(const ShoutOutput &) = delete; + static AudioOutput *Create(EventLoop &event_loop, const ConfigBlock &block); diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx index e8470b3ef..67b7ed856 100644 --- a/src/storage/plugins/NfsStorage.cxx +++ b/src/storage/plugins/NfsStorage.cxx @@ -85,6 +85,9 @@ public: nfs_finish(); } + NfsStorage(const NfsStorage &) = delete; + NfsStorage &operator=(const NfsStorage &) = delete; + /* virtual methods from class Storage */ StorageFileInfo GetInfo(std::string_view uri_utf8, bool follow) override; diff --git a/src/storage/plugins/UdisksStorage.cxx b/src/storage/plugins/UdisksStorage.cxx index 946a8d1f1..97a3265d6 100644 --- a/src/storage/plugins/UdisksStorage.cxx +++ b/src/storage/plugins/UdisksStorage.cxx @@ -93,6 +93,9 @@ public: } } + UdisksStorage(const UdisksStorage &) = delete; + UdisksStorage &operator=(const UdisksStorage &) = delete; + EventLoop &GetEventLoop() const noexcept { return defer_mount.GetEventLoop(); }