Skip to content

Commit

Permalink
GCMemcard: Assert struct requirements in header.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiralCurtiss committed Jun 16, 2020
1 parent 07bd200 commit cc52558
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/Core/Core/HW/GCMemcard/GCMemcard.h
Expand Up @@ -166,6 +166,8 @@ struct GCMBlock
void Erase();
std::array<u8, BLOCK_SIZE> m_block;
};
static_assert(sizeof(GCMBlock) == BLOCK_SIZE);
static_assert(std::is_trivially_copyable_v<GCMBlock>);

#pragma pack(push, 1)
struct Header
Expand Down Expand Up @@ -229,6 +231,7 @@ struct Header
GCMemcardErrorCode CheckForErrors(u16 card_size_mbits) const;
};
static_assert(sizeof(Header) == BLOCK_SIZE);
static_assert(std::is_trivially_copyable_v<Header>);

struct DEntry
{
Expand Down Expand Up @@ -306,6 +309,7 @@ struct DEntry
Common::BigEndianValue<u32> m_comments_address;
};
static_assert(sizeof(DEntry) == DENTRY_SIZE);
static_assert(std::is_trivially_copyable_v<DEntry>);

struct BlockAlloc;

Expand Down Expand Up @@ -341,6 +345,7 @@ struct Directory
GCMemcardErrorCode CheckForErrorsWithBat(const BlockAlloc& bat) const;
};
static_assert(sizeof(Directory) == BLOCK_SIZE);
static_assert(std::is_trivially_copyable_v<Directory>);

struct BlockAlloc
{
Expand Down Expand Up @@ -375,6 +380,7 @@ struct BlockAlloc
GCMemcardErrorCode CheckForErrors(u16 size_mbits) const;
};
static_assert(sizeof(BlockAlloc) == BLOCK_SIZE);
static_assert(std::is_trivially_copyable_v<BlockAlloc>);
#pragma pack(pop)

class GCMemcard
Expand Down

0 comments on commit cc52558

Please sign in to comment.