From 074b3547de2754279a7df9de3b13a8757c9272ef Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 10 Jun 2020 16:46:22 +0200 Subject: [PATCH] sdio: fix unsound MaybeUninit usage --- libboard_zynq/src/sdio/adma.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libboard_zynq/src/sdio/adma.rs b/libboard_zynq/src/sdio/adma.rs index 9669f42..7543981 100644 --- a/libboard_zynq/src/sdio/adma.rs +++ b/libboard_zynq/src/sdio/adma.rs @@ -22,16 +22,18 @@ register_bit!(desc32_attribute, int, 2); register_bit!(desc32_attribute, end, 1); register_bit!(desc32_attribute, valid, 0); -pub struct Adma2DescTable(MaybeUninit<[Adma2Desc32; 32]>); +pub struct Adma2DescTable([Adma2Desc32; 32]); impl Adma2DescTable { pub fn new() -> Self { - Adma2DescTable(MaybeUninit::uninit()) + let table = MaybeUninit::zeroed(); + let table = unsafe { table.assume_init() }; + Adma2DescTable(table) } /// Initialize the table and setup `adma_system_address` pub fn setup(&mut self, sdio: &mut SDIO, blk_cnt: u32, buffer: &[u8]) { - let descr_table = unsafe { &mut *self.0.as_mut_ptr() }; + let descr_table = &mut self.0; let blk_size = sdio .regs .block_size_block_count