backup: use static assertion in fixed index reader

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-09-11 14:43:25 +02:00
parent 34a3845b01
commit ccdf3ad1ec
1 changed files with 1 additions and 3 deletions

View File

@ -30,6 +30,7 @@ pub struct FixedIndexHeader {
pub chunk_size: u64,
reserved: [u8; 4016], // overall size is one page (4096 bytes)
}
proxmox::tools::static_assert_size!(FixedIndexHeader, 4096);
// split image into fixed size chunks
@ -77,9 +78,6 @@ impl FixedIndexReader {
let header_size = std::mem::size_of::<FixedIndexHeader>();
// todo: use static assertion when available in rust
if header_size != 4096 { bail!("got unexpected header size"); }
let mut buffer = vec![0u8; header_size];
file.read_exact(&mut buffer)?;