[ox/fs] Suppress unsafe buffer warnings

This commit is contained in:
2024-11-26 22:30:57 -06:00
parent 287d42f2b9
commit cd3eeeef14
10 changed files with 46 additions and 14 deletions

View File

@@ -11,6 +11,8 @@
#include <ox/std/trace.hpp>
#include "pathiterator.hpp"
OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage)
namespace ox {
PathIterator::PathIterator(const char *path, std::size_t maxSize, std::size_t iterator) {
@@ -30,7 +32,7 @@ PathIterator::PathIterator(StringViewCR path): PathIterator(path.data(), path.by
*/
Error PathIterator::dirPath(char *out, std::size_t outSize) {
const auto idx = ox::lastIndexOf(m_path, '/', m_maxSize);
const auto size = static_cast<std::size_t>(idx + 1);
const auto size = static_cast<std::size_t>(idx) + 1;
if (idx >= 0 && size < outSize) {
ox::memcpy(out, m_path, size);
out[size] = 0;
@@ -183,3 +185,5 @@ const char *PathIterator::fullPath() const {
}
}
OX_CLANG_NOWARN_END