mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
acpi_tables: add a safety comment for the write function
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -98,6 +98,7 @@ impl Sdt {
|
|||||||
/// Write a value at the given offset
|
/// Write a value at the given offset
|
||||||
pub fn write<T>(&mut self, offset: usize, value: T) {
|
pub fn write<T>(&mut self, offset: usize, value: T) {
|
||||||
assert!((offset + (std::mem::size_of::<T>() - 1)) < self.data.len());
|
assert!((offset + (std::mem::size_of::<T>() - 1)) < self.data.len());
|
||||||
|
// SAFETY: The assertion above makes sure we don't do out of bounds write.
|
||||||
unsafe {
|
unsafe {
|
||||||
*(((self.data.as_mut_ptr() as usize) + offset) as *mut T) = value;
|
*(((self.data.as_mut_ptr() as usize) + offset) as *mut T) = value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user