diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/fud_directory.cpp | 16 | ||||
-rw-r--r-- | source/fud_sqlite.cpp | 16 | ||||
-rw-r--r-- | source/fud_string.cpp | 6 | ||||
-rw-r--r-- | source/fud_utf8.cpp | 12 |
4 files changed, 28 insertions, 22 deletions
diff --git a/source/fud_directory.cpp b/source/fud_directory.cpp index 6851158..5772c95 100644 --- a/source/fud_directory.cpp +++ b/source/fud_directory.cpp @@ -137,15 +137,15 @@ Result<DirectoryEntry, FudStatus> Directory::info() return RetType::error(m_status); } - Stat statBuffer{}; - auto status = fstat(m_dirFd, &statBuffer); - if (status == -1) { + Stat sBuffer{}; + auto fStatus = fstat(m_dirFd, &sBuffer); + if (fStatus == -1) { m_errorCode = errno; m_status = FudStatus::Failure; return RetType::error(m_status); } - auto retValue = DirectoryEntry::fromStat(m_name, statBuffer); + auto retValue = DirectoryEntry::fromStat(m_name, sBuffer); if (retValue.isOkay()) { m_errorCode = 0; @@ -187,17 +187,17 @@ Result<std::optional<DirectoryEntry>, FudStatus> Directory::getNextEntry() m_errorCode = 0; - Stat statBuffer{}; + Stat sBuffer{}; auto flags = 0; - auto status = fstatat(m_dirFd, entryNameCString, &statBuffer, flags); - if (status == -1) { + auto fStatus = fstatat(m_dirFd, entryNameCString, &sBuffer, flags); + if (fStatus == -1) { m_errorCode = errno; m_status = FudStatus::Failure; return RetType::error(m_status); } auto entryName = String{entryNameCString}; - auto retValue = DirectoryEntry::fromStat(entryName, statBuffer); + auto retValue = DirectoryEntry::fromStat(entryName, sBuffer); if (retValue.isOkay()) { m_errorCode = 0; diff --git a/source/fud_sqlite.cpp b/source/fud_sqlite.cpp index f573f1c..e07523d 100644 --- a/source/fud_sqlite.cpp +++ b/source/fud_sqlite.cpp @@ -58,6 +58,8 @@ SqliteDb& SqliteDb::operator=(SqliteDb&& rhs) 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; rhs.m_nameValid = false; rhs.m_dbHandle = nullptr; @@ -94,9 +96,9 @@ FudStatus SqliteDb::exec( } char* errorMsgPtr = nullptr; - char** errorMsgPtrAddress = &errorMsgPtr; - if (errorMessage == nullptr) { - errorMsgPtrAddress = nullptr; + char** errorMsgPtrAddress = nullptr; + if (errorMessage != nullptr) { + errorMsgPtrAddress = &errorMsgPtr; } m_errorCode = sqlite3_exec( @@ -106,6 +108,10 @@ FudStatus SqliteDb::exec( context, errorMsgPtrAddress); + if (errorMessage != nullptr) { + *errorMessage = String{errorMsgPtr}; + } + return m_errorCode == SQLITE_OK ? FudStatus::Success : FudStatus::Failure; } @@ -126,10 +132,10 @@ int SqliteDb::open() return sqlite3_open_v2(m_name.c_str(), &m_dbHandle, static_cast<int>(m_mode) | m_extraFlags, nullptr); } -Result<SqliteStatement, FudStatus> SqliteDb::prepare(const String& dql) +Result<SqliteStatement, FudStatus> SqliteDb::prepare(const String& sql) { using RetType = Result<SqliteStatement, FudStatus>; - SqliteStatement preparedStatement{*this, dql}; + SqliteStatement preparedStatement{*this, sql}; if (!preparedStatement.valid() || preparedStatement.status() != FudStatus::Success) { m_errorCode = preparedStatement.errorCode(); diff --git a/source/fud_string.cpp b/source/fud_string.cpp index 10352ad..4cffb60 100644 --- a/source/fud_string.cpp +++ b/source/fud_string.cpp @@ -357,12 +357,12 @@ FudStatus String::append(StringView source) return FudStatus::Aliased; } - const auto newLength = length() + source.length(); + const size_t newLength = length() + source.length(); if (newLength < length()) { return FudStatus::OperationInvalid; } - const auto newSize = newLength + 1; - if (newSize < newLength) { + const size_t newSize = newLength + 1; // cppcheck-suppress knownConditionTrueFalse + if (newSize < newLength) { // cppcheck-suppress knownConditionTrueFalse return FudStatus::OperationInvalid; } if (newSize >= m_capacity) { diff --git a/source/fud_utf8.cpp b/source/fud_utf8.cpp index 1c23581..50b5d31 100644 --- a/source/fud_utf8.cpp +++ b/source/fud_utf8.cpp @@ -41,32 +41,32 @@ FudUtf8 FudUtf8::fromStringView(const StringView& view, size_t index) noexcept FudUtf8 FudUtf8::fromStringView(StringView&& view, size_t index) noexcept { auto len = view.length(); - const auto* data = view.data(); - if (data == nullptr) { + const auto* vData = view.data(); + if (vData == nullptr) { return invalidAscii(); } - FudUtf8 localChar{Ascii{data[index]}}; + FudUtf8 localChar{Ascii{vData[index]}}; if (localChar.valid()) { return localChar; } if (index + 1 < len) { - localChar.m_variant = Utf82Byte{data[index], data[index + 1]}; + localChar.m_variant = Utf82Byte{vData[index], vData[index + 1]}; } if (localChar.valid()) { return localChar; } if (index + 2 < len) { - localChar.m_variant = Utf83Byte{data[index], data[index + 1], data[index + 2]}; + localChar.m_variant = Utf83Byte{vData[index], vData[index + 1], vData[index + 2]}; } if (localChar.valid()) { return localChar; } if (index + 3 < len) { - localChar.m_variant = Utf84Byte{data[index], data[index + 1], data[index + 2], data[index + 3]}; + localChar.m_variant = Utf84Byte{vData[index], vData[index + 1], vData[index + 2], vData[index + 3]}; } if (localChar.valid()) { return localChar; |