From d5a174a6d4f8be5e7cffe7c2adbb8db23b578f56 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Thu, 2 Jan 2025 18:49:56 -0600 Subject: Fixing errors in Vector. --- test/test_common.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'test/test_common.cpp') diff --git a/test/test_common.cpp b/test/test_common.cpp index f272dad..03c5dff 100644 --- a/test/test_common.cpp +++ b/test/test_common.cpp @@ -27,28 +27,35 @@ namespace fud { std::byte* MockFudAlloc::operator()(size_t size) { + // NOLINTNEXTLINE(cppcoreguidelines-no-malloc) return static_cast(malloc(size)); } void MockFudDealloc::operator()(std::byte* pointer) { + // NOLINTNEXTLINE(cppcoreguidelines-no-malloc) free(pointer); } +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) MockFudAlloc globalDefaultMockAlloc{}; +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) MockFudDealloc globalDefaultMockDealloc{}; +// NOLINTNEXTLINE(readability-make-member-function-const) std::byte* MockFudAllocator::allocate(size_t size) { return (*m_allocator)(size); } +// NOLINTNEXTLINE(readability-make-member-function-const) void MockFudAllocator::deallocate(std::byte* pointer) { - return (*m_deallocator)(pointer); + (*m_deallocator)(pointer); } +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) MockFudAllocator globalMockFudAlloc{}; std::byte* fudAlloc(size_t size) @@ -58,7 +65,7 @@ std::byte* fudAlloc(size_t size) void fudFree(std::byte* ptr) { - return globalMockFudAlloc.deallocate(ptr); + globalMockFudAlloc.deallocate(ptr); } int unlink_cb(const char* fpath, const struct stat* sb_unused, int typeflag, struct FTW* ftwbuf) @@ -79,7 +86,9 @@ FudStatus removeRecursive(StringView path) if (!path.utf8Valid()) { return FudStatus::Utf8Invalid; } - if (path.length() < 5) { + + constexpr const size_t minPathLength = 5; + if (path.length() < minPathLength) { return FudStatus::ArgumentInvalid; } if (not path.nullTerminated()) { @@ -96,6 +105,7 @@ FudStatus removeRecursive(StringView path) } constexpr int maxOpenFd = 64; + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) auto status = nftw(reinterpret_cast(path.data()), unlink_cb, maxOpenFd, FTW_DEPTH | FTW_PHYS); if (status == 0) { return FudStatus::Success; -- cgit v1.2.3