datastore: avoid unsafe transmute, use to_ne_bytes

which is stable since rustc 1.32 but wasn't available in out
toolchain when this was originally written in commit 7bc1d7277

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-25 18:02:00 +02:00
parent bc001e12e2
commit b8858d5186
1 changed files with 3 additions and 3 deletions

View File

@ -373,14 +373,14 @@ impl DynamicIndexWriter {
);
}
let offset_le: &[u8; 8] = unsafe { &std::mem::transmute::<u64, [u8; 8]>(offset.to_le()) };
let offset_le: [u8; 8] = offset.to_le().to_ne_bytes();
if let Some(ref mut csum) = self.csum {
csum.update(offset_le);
csum.update(&offset_le);
csum.update(digest);
}
self.writer.write_all(offset_le)?;
self.writer.write_all(&offset_le)?;
self.writer.write_all(digest)?;
Ok(())
}