diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-10-03 08:07:05 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-10-03 08:07:05 -0500 |
commit | e420eca2b244c303af51534ab09632045a186b21 (patch) | |
tree | ba4ec2d6863b716672f35898266516b58c727aa9 /source | |
parent | 97bbafb762defc01abc38834b70a7e8f20d654f5 (diff) |
Cleanup from clang-tidy.
Diffstat (limited to 'source')
-rw-r--r-- | source/fud_c_file.cpp | 26 | ||||
-rw-r--r-- | source/fud_directory.cpp | 23 | ||||
-rw-r--r-- | source/fud_sqlite.cpp | 6 | ||||
-rw-r--r-- | source/fud_string.cpp | 12 | ||||
-rw-r--r-- | source/fud_utf8.cpp | 15 |
5 files changed, 41 insertions, 41 deletions
diff --git a/source/fud_c_file.cpp b/source/fud_c_file.cpp index e2e71bf..3961042 100644 --- a/source/fud_c_file.cpp +++ b/source/fud_c_file.cpp @@ -34,12 +34,9 @@ CBinaryFile::CBinaryFile(const String& filename, CFileMode mode, const String& e { } -CBinaryFile::CBinaryFile(CBinaryFile&& rhs) : - m_filename{std::move(rhs.m_filename)}, - m_extraFlags{std::move(rhs.m_extraFlags)}, - m_mode{std::move(rhs.m_mode)}, - m_modeFlags{std::move(rhs.m_modeFlags)}, - m_file{rhs.m_file} +CBinaryFile::CBinaryFile(CBinaryFile&& rhs) noexcept : + m_filename{std::move(rhs.m_filename)}, m_extraFlags{std::move(rhs.m_extraFlags)}, m_mode{std::move(rhs.m_mode)}, + m_modeFlags{rhs.m_modeFlags}, m_file{rhs.m_file} { } @@ -47,14 +44,14 @@ CBinaryFile::~CBinaryFile() { close(); } -CBinaryFile& CBinaryFile::operator=(CBinaryFile&& rhs) +CBinaryFile& CBinaryFile::operator=(CBinaryFile&& rhs) noexcept { close(); m_filename = std::move(rhs.m_filename); m_extraFlags = std::move(rhs.m_extraFlags); m_mode = std::move(rhs.m_mode); - m_modeFlags = std::move(rhs.m_modeFlags); + m_modeFlags = rhs.m_modeFlags; m_file = rhs.m_file; return *this; @@ -75,12 +72,9 @@ CTextFile::CTextFile(const String& filename, CFileMode mode, const String& extra { } -CTextFile::CTextFile(CTextFile&& rhs) : - m_filename{std::move(rhs.m_filename)}, - m_extraFlags{std::move(rhs.m_extraFlags)}, - m_mode{std::move(rhs.m_mode)}, - m_modeFlags{std::move(rhs.m_modeFlags)}, - m_file{rhs.m_file} +CTextFile::CTextFile(CTextFile&& rhs) noexcept : + m_filename{std::move(rhs.m_filename)}, m_extraFlags{std::move(rhs.m_extraFlags)}, m_mode{std::move(rhs.m_mode)}, + m_modeFlags{rhs.m_modeFlags}, m_file{rhs.m_file} { } @@ -88,14 +82,14 @@ CTextFile::~CTextFile() { close(); } -CTextFile& CTextFile::operator=(CTextFile&& rhs) +CTextFile& CTextFile::operator=(CTextFile&& rhs) noexcept { close(); m_filename = std::move(rhs.m_filename); m_extraFlags = std::move(rhs.m_extraFlags); m_mode = std::move(rhs.m_mode); - m_modeFlags = std::move(rhs.m_modeFlags); + m_modeFlags = rhs.m_modeFlags; m_file = rhs.m_file; return *this; diff --git a/source/fud_directory.cpp b/source/fud_directory.cpp index 5772c95..1fcebe1 100644 --- a/source/fud_directory.cpp +++ b/source/fud_directory.cpp @@ -41,11 +41,10 @@ Result<DirectoryEntry, FudStatus> DirectoryEntry::fromStat(const String& name, c size_t size{0}; if (statBuffer.st_size < 0) { return RetType::error(FudStatus::Failure); - } else { - size = static_cast<size_t>(statBuffer.st_size); } + size = static_cast<size_t>(statBuffer.st_size); - DirectoryEntryType entryType; + DirectoryEntryType entryType{}; switch (statBuffer.st_mode & S_IFMT) { case S_IFBLK: entryType = DirectoryEntryType::Block; @@ -73,11 +72,16 @@ Result<DirectoryEntry, FudStatus> DirectoryEntry::fromStat(const String& name, c break; } - return RetType::okay( - DirectoryEntry{name, statBuffer.st_ino, size, static_cast<size_t>(statBuffer.st_nlink), statBuffer.st_mtime, entryType}); + return RetType::okay(DirectoryEntry{ + name, + statBuffer.st_ino, + size, + static_cast<size_t>(statBuffer.st_nlink), + statBuffer.st_mtime, + entryType}); } -Directory::Directory(String name) : m_name{name} +Directory::Directory(const String& name) : m_name{name} { if (!m_name.valid()) { return; @@ -108,7 +112,7 @@ Directory::Directory(String name) : m_name{name} m_status = FudStatus::Success; } -Directory::Directory(Directory&& rhs) : +Directory::Directory(Directory&& rhs) noexcept : m_name{std::move(rhs.m_name)}, m_directory{rhs.m_directory}, m_dirFd{rhs.m_dirFd} { rhs.m_directory = nullptr; @@ -173,9 +177,8 @@ Result<std::optional<DirectoryEntry>, FudStatus> Directory::getNextEntry() m_errorCode = errno; m_status = FudStatus::Failure; return RetType::error(m_status); - } else { - return RetType::okay(std::nullopt); } + return RetType::okay(std::nullopt); } const char* entryNameCString = dirEntry->d_name; @@ -202,7 +205,7 @@ Result<std::optional<DirectoryEntry>, FudStatus> Directory::getNextEntry() if (retValue.isOkay()) { m_errorCode = 0; m_status = FudStatus::Success; - return RetType::okay(retValue.getOkay()); + return RetType::okay(std::move(retValue.getOkay())); } m_status = retValue.getError(); diff --git a/source/fud_sqlite.cpp b/source/fud_sqlite.cpp index e07523d..3e39474 100644 --- a/source/fud_sqlite.cpp +++ b/source/fud_sqlite.cpp @@ -31,7 +31,7 @@ SqliteDb::SqliteDb(const char* name, SqliteOpenMode mode, int extraFlags) : initialize(); } -SqliteDb::SqliteDb(SqliteDb&& rhs) : +SqliteDb::SqliteDb(SqliteDb&& rhs) noexcept : m_name{std::move(rhs.m_name)}, m_nameValid{rhs.m_nameValid}, m_dbHandle{rhs.m_dbHandle}, m_errorCode{rhs.m_errorCode}, m_mode{rhs.m_mode}, m_extraFlags{rhs.m_extraFlags} { @@ -47,7 +47,7 @@ SqliteDb::~SqliteDb() } } -SqliteDb& SqliteDb::operator=(SqliteDb&& rhs) +SqliteDb& SqliteDb::operator=(SqliteDb&& rhs) noexcept { if (m_dbHandle != nullptr) { sqlite3_close(m_dbHandle); @@ -164,7 +164,7 @@ SqliteStatement::SqliteStatement(const SqliteDb& sqliteDb, const String& input) } } -SqliteStatement::SqliteStatement(SqliteStatement&& rhs) : +SqliteStatement::SqliteStatement(SqliteStatement&& rhs) noexcept : m_input{std::move(rhs.m_input)}, m_tail{rhs.m_tail}, m_status{rhs.m_status}, m_errorCode{rhs.m_errorCode}, m_preparedStatement{rhs.m_preparedStatement} { diff --git a/source/fud_string.cpp b/source/fud_string.cpp index 4cffb60..3a9aca0 100644 --- a/source/fud_string.cpp +++ b/source/fud_string.cpp @@ -46,9 +46,11 @@ ssize_t cStringLength(const char* str, size_t maxLength) return size; } +// NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast) String::String(const utf8* cString) : String(reinterpret_cast<const char*>(cString)) { } +// NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) String::String(const char* cString) { @@ -82,7 +84,7 @@ String::String(const String& rhs) : m_length{rhs.m_length}, m_capacity{rhs.m_cap } } -String::String(String&& rhs) : m_length{rhs.m_length}, m_capacity{rhs.m_capacity} +String::String(String&& rhs) noexcept : m_length{rhs.m_length}, m_capacity{rhs.m_capacity} { if (isLarge()) { cleanup(); @@ -91,7 +93,7 @@ String::String(String&& rhs) : m_length{rhs.m_length}, m_capacity{rhs.m_capacity m_data = rhs.m_data; rhs.m_data = nullptr; } else { - m_buffer = std::move(rhs.m_buffer); + m_buffer = rhs.m_buffer; fudAssert(nullTerminate() == FudStatus::Success); } } @@ -122,7 +124,7 @@ String& String::operator=(const String& rhs) return *this; } -String& String::operator=(String&& rhs) +String& String::operator=(String&& rhs) noexcept { cleanup(); @@ -132,7 +134,7 @@ String& String::operator=(String&& rhs) m_data = rhs.m_data; rhs.m_data = nullptr; } else { - m_buffer = std::move(rhs.m_buffer); + m_buffer = rhs.m_buffer; fudAssert(nullTerminate() == FudStatus::Success); } return *this; @@ -172,7 +174,7 @@ FudStatus String::resize(size_t newCapacity) return FudStatus::Success; } - utf8* newData; + utf8* newData = nullptr; if (isLarge()) { newData = static_cast<utf8*>(fudRealloc(m_data, newCapacity)); if (newData == nullptr) { diff --git a/source/fud_utf8.cpp b/source/fud_utf8.cpp index 50b5d31..0804531 100644 --- a/source/fud_utf8.cpp +++ b/source/fud_utf8.cpp @@ -33,15 +33,16 @@ FudUtf8 FudUtf8::fromString(const String& fudString, size_t index) noexcept return fromStringView(StringView{fudString}, index); } -FudUtf8 FudUtf8::fromStringView(const StringView& view, size_t index) noexcept -{ - return fromStringView(StringView{view}, index); -} +// FudUtf8 FudUtf8::fromStringView(const StringView& view, size_t index) noexcept +// { +// return fromStringView(StringView{view}, index); +// } -FudUtf8 FudUtf8::fromStringView(StringView&& view, size_t index) noexcept +FudUtf8 FudUtf8::fromStringView(StringView view, size_t index) noexcept { - auto len = view.length(); - const auto* vData = view.data(); + auto viewLocal{view}; + auto len = viewLocal.length(); + const auto* vData = viewLocal.data(); if (vData == nullptr) { return invalidAscii(); } |