From 7adcd48a410fe53572171dfcda7d25e8bd06504b Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 13 Nov 2021 22:30:12 +0200 Subject: [PATCH] COMMON: Use override Using clang-tidy modernize-use-override --- common/archive.h | 10 +++++----- common/file.h | 10 +++++----- common/fs.h | 10 +++++----- common/installshield_cab.cpp | 8 ++++---- common/lua/scummvm_file.h | 12 ++++++------ common/memstream.h | 30 +++++++++++++++--------------- common/osd_message_queue.h | 2 +- common/stream.cpp | 14 +++++++------- common/substream.h | 6 +++--- common/unarj.cpp | 8 ++++---- common/unzip.cpp | 8 ++++---- common/xmlparser.h | 2 +- common/zlib.cpp | 24 ++++++++++++------------ 13 files changed, 72 insertions(+), 72 deletions(-) diff --git a/common/archive.h b/common/archive.h index 02f5a81fbe3..883fcbb1471 100644 --- a/common/archive.h +++ b/common/archive.h @@ -252,17 +252,17 @@ public: */ void setPriority(const String& name, int priority); - virtual bool hasFile(const Path &path) const; - virtual int listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const; - virtual int listMembers(ArchiveMemberList &list) const; + bool hasFile(const Path &path) const override; + int listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const override; + int listMembers(ArchiveMemberList &list) const override; - virtual const ArchiveMemberPtr getMember(const Path &path) const; + const ArchiveMemberPtr getMember(const Path &path) const override; /** * Implement createReadStreamForMember from the Archive base class. The current policy is * opening the first file encountered that matches the name. */ - virtual SeekableReadStream *createReadStreamForMember(const Path &path) const; + SeekableReadStream *createReadStreamForMember(const Path &path) const override; /** * Ignore clashes when adding directories. For more details, see the corresponding parameter diff --git a/common/file.h b/common/file.h index be1c544cdd3..2792d7e983d 100644 --- a/common/file.h +++ b/common/file.h @@ -167,14 +167,14 @@ public: bool err() const override; void clearErr() override; - virtual uint32 write(const void *dataPtr, uint32 dataSize) override; + uint32 write(const void *dataPtr, uint32 dataSize) override; - virtual bool flush() override; + bool flush() override; - virtual int64 pos() const override; + int64 pos() const override; - virtual bool seek(int64 offset, int whence = SEEK_SET) override; - virtual int64 size() const override; + bool seek(int64 offset, int whence = SEEK_SET) override; + int64 size() const override; }; /** @} */ diff --git a/common/fs.h b/common/fs.h index dd15e8bfe26..3d47e2f982a 100644 --- a/common/fs.h +++ b/common/fs.h @@ -371,29 +371,29 @@ public: * Check for the existence of a file in the cache. A full match of relative path and file name * is needed for success. */ - virtual bool hasFile(const Path &path) const; + bool hasFile(const Path &path) const override; /** * Return a list of matching file names. Pattern can use GLOB wildcards. */ - virtual int listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const; + int listMatchingMembers(ArchiveMemberList &list, const Path &pattern) const override; /** * Return a list of all the files in the cache. */ - virtual int listMembers(ArchiveMemberList &list) const; + int listMembers(ArchiveMemberList &list) const override; /** * Get an ArchiveMember representation of the specified file. A full match of relative * path and file name is needed for success. */ - virtual const ArchiveMemberPtr getMember(const Path &path) const; + const ArchiveMemberPtr getMember(const Path &path) const override; /** * Open the specified file. A full match of relative path and file name is needed * for success. */ - virtual SeekableReadStream *createReadStreamForMember(const Path &path) const; + SeekableReadStream *createReadStreamForMember(const Path &path) const override; }; /** @} */ diff --git a/common/installshield_cab.cpp b/common/installshield_cab.cpp index eb09bd094db..efa93f66696 100644 --- a/common/installshield_cab.cpp +++ b/common/installshield_cab.cpp @@ -64,10 +64,10 @@ public: void close(); // Archive API implementation - virtual bool hasFile(const Path &path) const; - virtual int listMembers(ArchiveMemberList &list) const; - virtual const ArchiveMemberPtr getMember(const Path &path) const; - virtual SeekableReadStream *createReadStreamForMember(const Path &path) const; + bool hasFile(const Path &path) const override; + int listMembers(ArchiveMemberList &list) const override; + const ArchiveMemberPtr getMember(const Path &path) const override; + SeekableReadStream *createReadStreamForMember(const Path &path) const override; private: struct FileEntry { diff --git a/common/lua/scummvm_file.h b/common/lua/scummvm_file.h index 0c945ec35e8..2a51bdfef7b 100644 --- a/common/lua/scummvm_file.h +++ b/common/lua/scummvm_file.h @@ -60,9 +60,9 @@ private: public: virtual ~LuaFileConfig(); - virtual bool eof() const override { return _readPos >= _readData.size(); } - virtual size_t read(void *ptr, size_t size, size_t count) override; - virtual size_t write(const char *ptr, size_t count) override; + bool eof() const override { return _readPos >= _readData.size(); } + size_t read(void *ptr, size_t size, size_t count) override; + size_t write(const char *ptr, size_t count) override; }; class LuaFileRead : public LuaFileProxy { @@ -74,9 +74,9 @@ public: public: virtual ~LuaFileRead() {} - virtual bool eof() const override; - virtual size_t read(void *ptr, size_t size, size_t count) override; - virtual size_t write(const char *ptr, size_t count) override; + bool eof() const override; + size_t read(void *ptr, size_t size, size_t count) override; + size_t write(const char *ptr, size_t count) override; }; } // End of namespace Lua diff --git a/common/memstream.h b/common/memstream.h index d0555200f9d..dcba5cac7d7 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -126,13 +126,13 @@ public: return dataSize; } - virtual int64 pos() const override { return _pos; } - virtual int64 size() const override { return _bufSize; } + int64 pos() const override { return _pos; } + int64 size() const override { return _bufSize; } - virtual bool err() const override { return _err; } - virtual void clearErr() override { _err = false; } + bool err() const override { return _err; } + void clearErr() override { _err = false; } - virtual bool seek(int64 offset, int whence = SEEK_SET) override { return false; } + bool seek(int64 offset, int whence = SEEK_SET) override { return false; } }; /** @@ -144,7 +144,7 @@ private: public: SeekableMemoryWriteStream(byte *buf, uint32 len) : MemoryWriteStream(buf, len), _ptrOrig(buf) {} - virtual bool seek(int64 offset, int whence = SEEK_SET) override { + bool seek(int64 offset, int whence = SEEK_SET) override { switch (whence) { case SEEK_END: // SEEK_END works just like SEEK_SET, only 'reversed', @@ -232,12 +232,12 @@ public: return dataSize; } - virtual int64 pos() const override { return _pos; } - virtual int64 size() const override { return _size; } + int64 pos() const override { return _pos; } + int64 size() const override { return _size; } byte *getData() { return _data; } - virtual bool seek(int64 offs, int whence = SEEK_SET) override { + bool seek(int64 offs, int whence = SEEK_SET) override { // Pre-Condition assert(_pos <= _size); switch (whence) { @@ -325,7 +325,7 @@ public: return dataSize; } - virtual uint32 read(void *dataPtr, uint32 dataSize) override { + uint32 read(void *dataPtr, uint32 dataSize) override { if (_length < dataSize) { dataSize = _length; _eos = true; @@ -343,11 +343,11 @@ public: return dataSize; } - virtual int64 pos() const override { return _pos - _length; } - virtual int64 size() const override { return _size; } - virtual bool seek(int64, int) override { return false; } - virtual bool eos() const override { return _eos; } - virtual void clearErr() override { _eos = false; } + int64 pos() const override { return _pos - _length; } + int64 size() const override { return _size; } + bool seek(int64, int) override { return false; } + bool eos() const override { return _eos; } + void clearErr() override { _eos = false; } byte *getData() { return _data; } }; diff --git a/common/osd_message_queue.h b/common/osd_message_queue.h index 88dd89b1852..49b32e5128f 100644 --- a/common/osd_message_queue.h +++ b/common/osd_message_queue.h @@ -68,7 +68,7 @@ public: * * The periodical polling is used to update the OSD messages. */ - virtual bool pollEvent(Common::Event &event) override; + bool pollEvent(Common::Event &event) override; private: Mutex _mutex; diff --git a/common/stream.cpp b/common/stream.cpp index 2b013da8be6..f04e05f48ae 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -314,11 +314,11 @@ public: BufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream); virtual ~BufferedReadStream(); - virtual bool eos() const { return _eos; } - virtual bool err() const { return _parentStream->err(); } - virtual void clearErr() { _eos = false; _parentStream->clearErr(); } + bool eos() const override { return _eos; } + bool err() const override { return _parentStream->err(); } + void clearErr() override { _eos = false; _parentStream->clearErr(); } - virtual uint32 read(void *dataPtr, uint32 dataSize); + uint32 read(void *dataPtr, uint32 dataSize) override; }; BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) @@ -416,10 +416,10 @@ protected: public: BufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO); - virtual int64 pos() const { return _parentStream->pos() - (_bufSize - _pos); } - virtual int64 size() const { return _parentStream->size(); } + int64 pos() const override { return _parentStream->pos() - (_bufSize - _pos); } + int64 size() const override { return _parentStream->size(); } - virtual bool seek(int64 offset, int whence = SEEK_SET); + bool seek(int64 offset, int whence = SEEK_SET) override; }; BufferedSeekableReadStream::BufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) diff --git a/common/substream.h b/common/substream.h index 4a663d640c1..8aef1960830 100644 --- a/common/substream.h +++ b/common/substream.h @@ -103,10 +103,10 @@ public: ReadStreamEndian(bigEndian) { } - virtual int64 pos() const override { return SeekableSubReadStream::pos(); } - virtual int64 size() const override { return SeekableSubReadStream::size(); } + int64 pos() const override { return SeekableSubReadStream::pos(); } + int64 size() const override { return SeekableSubReadStream::size(); } - virtual bool seek(int64 offset, int whence = SEEK_SET) override { return SeekableSubReadStream::seek(offset, whence); } + bool seek(int64 offset, int whence = SEEK_SET) override { return SeekableSubReadStream::seek(offset, whence); } void hexdump(int len, int bytesPerLine = 16, int startOffset = 0) { SeekableSubReadStream::hexdump(len, bytesPerLine, startOffset); } bool skip(uint32 offset) override { return SeekableSubReadStream::seek(offset, SEEK_CUR); } }; diff --git a/common/unarj.cpp b/common/unarj.cpp index 34bfed21cc9..788d2d4a2d9 100644 --- a/common/unarj.cpp +++ b/common/unarj.cpp @@ -702,10 +702,10 @@ public: virtual ~ArjArchive(); // Archive implementation - virtual bool hasFile(const Path &path) const; - virtual int listMembers(ArchiveMemberList &list) const; - virtual const ArchiveMemberPtr getMember(const Path &path) const; - virtual SeekableReadStream *createReadStreamForMember(const Path &path) const; + bool hasFile(const Path &path) const override; + int listMembers(ArchiveMemberList &list) const override; + const ArchiveMemberPtr getMember(const Path &path) const override; + SeekableReadStream *createReadStreamForMember(const Path &path) const override; }; ArjArchive::ArjArchive(const String &filename) : _arjFilename(filename) { diff --git a/common/unzip.cpp b/common/unzip.cpp index a240fd6e6db..bbb3d571e5d 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -1429,10 +1429,10 @@ public: ~ZipArchive(); - virtual bool hasFile(const Path &path) const; - virtual int listMembers(ArchiveMemberList &list) const; - virtual const ArchiveMemberPtr getMember(const Path &path) const; - virtual SeekableReadStream *createReadStreamForMember(const Path &path) const; + bool hasFile(const Path &path) const override; + int listMembers(ArchiveMemberList &list) const override; + const ArchiveMemberPtr getMember(const Path &path) const override; + SeekableReadStream *createReadStreamForMember(const Path &path) const override; }; /* diff --git a/common/xmlparser.h b/common/xmlparser.h index 58b7bf40e88..969f15d364c 100644 --- a/common/xmlparser.h +++ b/common/xmlparser.h @@ -78,7 +78,7 @@ class SeekableReadStream; typedef bool (parserName::*ParserCallback)(ParserNode *node);\ ParserCallback callback;\ bool doCallback(XMLParser *parent, ParserNode *node) {return ((kLocalParserName *)parent->*callback)(node);} };\ - virtual void buildLayout() override { \ + void buildLayout() override { \ Common::Stack layout; \ CustomXMLKeyLayout *lay = 0; \ XMLKeyLayout::XMLKeyProperty prop; \ diff --git a/common/zlib.cpp b/common/zlib.cpp index e7f75293e9f..cf2dd4c2826 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -284,13 +284,13 @@ public: inflateEnd(&_stream); } - bool err() const { return (_zlibErr != Z_OK) && (_zlibErr != Z_STREAM_END); } - void clearErr() { + bool err() const override { return (_zlibErr != Z_OK) && (_zlibErr != Z_STREAM_END); } + void clearErr() override { // only reset _eos; I/O errors are not recoverable _eos = false; } - uint32 read(void *dataPtr, uint32 dataSize) { + uint32 read(void *dataPtr, uint32 dataSize) override { _stream.next_out = (byte *)dataPtr; _stream.avail_out = dataSize; @@ -313,16 +313,16 @@ public: return dataSize - _stream.avail_out; } - bool eos() const { + bool eos() const override { return _eos; } - int64 pos() const { + int64 pos() const override { return _pos; } - int64 size() const { + int64 size() const override { return _origSize; } - bool seek(int64 offset, int whence = SEEK_SET) { + bool seek(int64 offset, int whence = SEEK_SET) override { int32 newPos = 0; switch (whence) { default: @@ -439,18 +439,18 @@ public: deflateEnd(&_stream); } - bool err() const { + bool err() const override { // CHECKME: does Z_STREAM_END make sense here? return (_zlibErr != Z_OK && _zlibErr != Z_STREAM_END) || _wrapped->err(); } - void clearErr() { + void clearErr() override { // Note: we don't reset the _zlibErr here, as it is not // clear in general how _wrapped->clearErr(); } - void finalize() { + void finalize() override { if (_zlibErr != Z_OK) return; @@ -470,7 +470,7 @@ public: _wrapped->finalize(); } - uint32 write(const void *dataPtr, uint32 dataSize) { + uint32 write(const void *dataPtr, uint32 dataSize) override { if (err()) return 0; @@ -487,7 +487,7 @@ public: return dataSize - _stream.avail_in; } - virtual int64 pos() const { return _pos; } + int64 pos() const override { return _pos; } }; #endif // USE_ZLIB