From 25acc3da2ff9cfc17b233f0560c0339dda54fd63 Mon Sep 17 00:00:00 2001 From: Mike Hilgendorf Date: Thu, 7 Nov 2019 21:59:20 -0800 Subject: [PATCH] replaced mem::uninitialized with mem::MaybeUninit, added (#112) \#[allow(clippy::suspicous_map)] for a suspicious use of map --- src/buffer.rs | 1 + src/host.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index d61b3fe7..167999ba 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -448,6 +448,7 @@ impl SendEventBuffer { #[inline(always)] fn store_events, U: WriteIntoPlaceholder>(&mut self, events: T) { + #[allow(clippy::suspicious_map)] let count = events .into_iter() .zip(self.api_events.iter_mut()) diff --git a/src/host.rs b/src/host.rs index ad298061..7835ab3a 100644 --- a/src/host.rs +++ b/src/host.rs @@ -2,15 +2,15 @@ use num_traits::Float; +use libloading::Library; use std::cell::UnsafeCell; use std::error::Error; use std::ffi::CString; +use std::mem::MaybeUninit; +use std::os::raw::c_void; use std::path::Path; use std::sync::{Arc, Mutex}; -use std::{fmt, mem, ptr, slice}; - -use libloading::Library; -use std::os::raw::c_void; +use std::{fmt, ptr, slice}; use api::consts::*; use api::{self, AEffect, PluginFlags, PluginMain, Supported, TimeInfo}; @@ -563,21 +563,21 @@ impl Plugin for PluginInstance { } fn get_input_info(&self, input: i32) -> ChannelInfo { - let mut props = unsafe { mem::uninitialized() }; - let ptr = &mut props as *mut api::ChannelProperties as *mut c_void; + let mut props: MaybeUninit = MaybeUninit::uninit(); + let ptr = props.as_mut_ptr() as *mut c_void; self.dispatch(plugin::OpCode::GetInputInfo, input, 0, ptr, 0.0); - ChannelInfo::from(props) + ChannelInfo::from(unsafe { props.assume_init() }) } fn get_output_info(&self, output: i32) -> ChannelInfo { - let mut props = unsafe { mem::uninitialized() }; - let ptr = &mut props as *mut api::ChannelProperties as *mut c_void; + let mut props: MaybeUninit = MaybeUninit::uninit(); + let ptr = props.as_mut_ptr() as *mut c_void; self.dispatch(plugin::OpCode::GetOutputInfo, output, 0, ptr, 0.0); - ChannelInfo::from(props) + ChannelInfo::from(unsafe { props.assume_init() }) } fn get_parameter_object(&mut self) -> Arc {