Compare commits

...

2 Commits

Author SHA1 Message Date
bd665cfc35 [ox] GCC13 fix 2023-05-19 21:35:00 -05:00
fcf0a9be95 [ox] Fix for a broken new memory safety check in GCC13 2023-05-19 21:32:18 -05:00
2 changed files with 12 additions and 10 deletions

View File

@ -269,7 +269,7 @@ Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameB
for (auto i = buff->iterator(); i.valid(); i.next()) {
auto data = i->data();
if (data.valid()) {
if (data->name == name) {
if (name == data->name) {
oxReturnError(buff->free(i));
}
} else {
@ -319,7 +319,7 @@ Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::findEntry
auto data = i->data();
if (data.valid()) {
oxTracef("ox::fs::Directory::findEntry", "Comparing \"{}\" to \"{}\"", name, data->name);
if (data->name == name) {
if (name == data->name) {
oxTracef("ox::fs::Directory::findEntry", "\"{}\" match found.", name);
return static_cast<InodeId_t>(data->inode);
}

View File

@ -26,6 +26,8 @@ namespace detail {
template<typename T, typename Allocator, std::size_t Size = 1>
struct VectorAllocator {
static_assert(sizeof(AllocAlias<T>) == sizeof(T));
static_assert(alignof(AllocAlias<T>) == alignof(T));
private:
ox::Array<AllocAlias<T>, Size> m_data = {};
Allocator m_allocator;
@ -46,11 +48,11 @@ struct VectorAllocator {
constexpr void moveConstructItemsFrom(T **items, VectorAllocator *src, const std::size_t count, const std::size_t cap) noexcept {
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
// try removing it later
if (cap <= Size && count <= Size) {
const auto dstItems = reinterpret_cast<T*>(m_data.data());
const auto srcItems = reinterpret_cast<T*>(src->m_data.data());
if (cap <= m_data.size() && count <= m_data.size()) {
for (auto i = 0u; i < count; ++i) {
std::construct_at<T>(&dstItems[i], std::move(srcItems[i]));
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
std::construct_at<T>(dstItem, std::move(*srcItem));
}
*items = reinterpret_cast<T*>(m_data.data());
}
@ -59,11 +61,11 @@ struct VectorAllocator {
constexpr void moveItemsFrom(T **items, VectorAllocator *src, const std::size_t count, const std::size_t cap) noexcept {
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
// try removing it later
if (cap <= Size && count <= Size) {
const auto dstItems = reinterpret_cast<T*>(m_data.data());
const auto srcItems = reinterpret_cast<T*>(src->m_data.data());
if (cap <= m_data.size() && count <= m_data.size()) {
for (std::size_t i = 0; i < count; ++i) {
dstItems[i] = std::move(srcItems[i]);
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
*dstItem = std::move(*srcItem);
}
*items = reinterpret_cast<T*>(m_data.data());
}