From 1d9050dbe3c97c644453632081c15ccd58886bce Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 16 Nov 2022 17:14:33 +0000 Subject: [PATCH] acpi_tables: add a safety comment for the write function Signed-off-by: Wei Liu --- acpi_tables/src/sdt.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/acpi_tables/src/sdt.rs b/acpi_tables/src/sdt.rs index 1e80a4aee..7efbf95c3 100644 --- a/acpi_tables/src/sdt.rs +++ b/acpi_tables/src/sdt.rs @@ -98,6 +98,7 @@ impl Sdt { /// Write a value at the given offset pub fn write(&mut self, offset: usize, value: T) { assert!((offset + (std::mem::size_of::() - 1)) < self.data.len()); + // SAFETY: The assertion above makes sure we don't do out of bounds write. unsafe { *(((self.data.as_mut_ptr() as usize) + offset) as *mut T) = value; }