diff --git a/deps/ox/src/ox/fs/test/tests.cpp b/deps/ox/src/ox/fs/test/tests.cpp index cd5b0388..a8bae421 100644 --- a/deps/ox/src/ox/fs/test/tests.cpp +++ b/deps/ox/src/ox/fs/test/tests.cpp @@ -175,8 +175,8 @@ const std::map> tests = auto list = new (ox_alloca(buffLen)) ox::ptrarith::NodeBuffer>(buffLen); oxAssert(ox::FileStore32::format(list, buffLen), "FileStore::format failed."); ox::FileStore32 fileStore(list, buffLen); - oxAssert(fileStore.write(4, const_cast(str1), str1Len, 1), "FileStore::write 1 failed."); - oxAssert(fileStore.write(5, const_cast(str2), str2Len, 1), "FileStore::write 2 failed."); + oxAssert(fileStore.write(4, str1, str1Len, 1), "FileStore::write 1 failed."); + oxAssert(fileStore.write(5, str2, str2Len, 1), "FileStore::write 2 failed."); char str1Read[str1Len]; size_t str1ReadSize = 0; diff --git a/deps/ox/src/ox/std/strops.cpp b/deps/ox/src/ox/std/strops.cpp index a6b7f756..3d96457b 100644 --- a/deps/ox/src/ox/std/strops.cpp +++ b/deps/ox/src/ox/std/strops.cpp @@ -7,9 +7,9 @@ */ #include "def.hpp" +#include "span.hpp" #include "strops.hpp" -OX_ALLOW_UNSAFE_BUFFERS_BEGIN static_assert(ox::strcmp("asdf", "hijk") < 0, "asdf < hijk"); static_assert(ox::strcmp("hijk", "asdf") > 0, "hijk > asdf"); @@ -19,30 +19,25 @@ static_assert(ox::strcmp("resize", "resize") == 0, "resize == resize"); static_assert(ox::strcmp("", "") == 0, "\"\" == \"\""); static_assert([] { - auto testStr = "asdf"; -OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage) - return ox::strchr(testStr, 0, 4) == &testStr[4]; -OX_CLANG_NOWARN_END + auto constexpr testStr = ox::Span{"asdf"}; + return ox::strchr(testStr.data(), 0, 4) == &testStr[4]; }(), "ox::strchr 0"); static_assert([] { - int retval = 0; - auto testStr = "aaaa"; + auto constexpr testStr = "aaaa"; // test the const and non-const versions of ox::lastIndexOf - retval |= !(ox::lastIndexOf(const_cast(testStr), 'a', ox::strlen(testStr)) == 3); - retval |= !(ox::lastIndexOf(testStr, 'a', ox::strlen(testStr)) == 3); - return retval == 0; + return ox::lastIndexOf(testStr, 'a', ox::strlen(testStr)) == 3; }(), "ox::lastIndexOf aaaa a"); #ifndef OX_USE_STDLIB extern "C" -std::size_t strlen(const char *str) { - std::size_t len = 0; - for (; str[len]; len++); +size_t strlen(const char *str) { + size_t len{}; +OX_ALLOW_UNSAFE_BUFFERS_BEGIN + while (str[len]) { ++len; } +OX_ALLOW_UNSAFE_BUFFERS_END return len; } #endif - -OX_ALLOW_UNSAFE_BUFFERS_END \ No newline at end of file