Skip to content

Commit

Permalink
Updates static assert of cache hash data Header size (anza-xyz#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Jul 8, 2024
1 parent f7f7092 commit 8c53bc5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions accounts-db/src/cache_hash_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ pub struct Header {
// In order to safely guarantee Header is Pod, it cannot have any padding
// This is obvious by inspection, but this will also catch any inadvertent
// changes in the future (i.e. it is a test).
// Additionally, we compare the header size with `u64` instead of `usize`
// to ensure binary compatibility doesn't break.
const _: () = assert!(
std::mem::size_of::<Header>() == std::mem::size_of::<usize>(),
"Header cannot have any padding"
std::mem::size_of::<Header>() == std::mem::size_of::<u64>(),
"Header cannot have any padding and must be the same size as u64",
);

/// cache hash data file to be mmapped later
Expand Down

0 comments on commit 8c53bc5

Please sign in to comment.