From e420eca2b244c303af51534ab09632045a186b21 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Thu, 3 Oct 2024 08:07:05 -0500 Subject: Cleanup from clang-tidy. --- source/fud_directory.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source/fud_directory.cpp') 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::fromStat(const String& name, c size_t size{0}; if (statBuffer.st_size < 0) { return RetType::error(FudStatus::Failure); - } else { - size = static_cast(statBuffer.st_size); } + size = static_cast(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::fromStat(const String& name, c break; } - return RetType::okay( - DirectoryEntry{name, statBuffer.st_ino, size, static_cast(statBuffer.st_nlink), statBuffer.st_mtime, entryType}); + return RetType::okay(DirectoryEntry{ + name, + statBuffer.st_ino, + size, + static_cast(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, 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, 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(); -- cgit v1.2.3