Skip to content

Commit 453c58d

Browse files
committed
Remove an unsafe code
1 parent edb4a65 commit 453c58d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

zircon-object/src/dev/pci/nodes.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,21 @@ pub struct PcieUpstream {
3333

3434
struct PcieUpstreamInner {
3535
weak_super: Weak<dyn IPciNode>,
36-
downstream: [Option<Arc<dyn IPciNode>>; PCI_MAX_FUNCTIONS_PER_BUS],
36+
downstream: Box<[Option<Arc<dyn IPciNode>>]>,
3737
}
3838

3939
impl PcieUpstream {
40-
#[allow(unsafe_code)]
4140
pub fn create(managed_bus_id: usize) -> Arc<Self> {
4241
Arc::new(PcieUpstream {
4342
managed_bus_id,
4443
inner: Mutex::new(PcieUpstreamInner {
4544
weak_super: Weak::<PciRoot>::new(),
46-
downstream: unsafe {
47-
core::mem::transmute(
48-
[0u8; core::mem::size_of::<Option<Arc<dyn IPciNode>>>()
49-
* PCI_MAX_FUNCTIONS_PER_BUS],
50-
)
45+
downstream: {
46+
let mut vec =
47+
Vec::<Option<Arc<dyn IPciNode>>>::with_capacity(PCI_MAX_FUNCTIONS_PER_BUS);
48+
vec.resize(PCI_MAX_FUNCTIONS_PER_BUS, None);
49+
vec.into_boxed_slice()
5150
},
52-
// [None; PCI_MAX_FUNCTIONS_PER_BUS],
5351
}),
5452
})
5553
}

0 commit comments

Comments
 (0)