mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
nak,nir: Stop using std::mem::zeroed()
We can replace all of these with safe alternatives if we ask bindgen for implementations of Default. Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35390>
This commit is contained in:
parent
d15b5fadbb
commit
5f0e4a7605
5 changed files with 8 additions and 6 deletions
|
|
@ -23,7 +23,7 @@ pub struct MemStream(Pin<Box<MemStreamImpl>>);
|
|||
impl MemStream {
|
||||
pub fn new() -> io::Result<Self> {
|
||||
let mut stream_impl = Box::pin(MemStreamImpl {
|
||||
stream: unsafe { std::mem::zeroed() },
|
||||
stream: Default::default(),
|
||||
buffer: std::ptr::null_mut(),
|
||||
buffer_size: 0,
|
||||
_pin: PhantomPinned,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ _compiler_bindgen_args = [
|
|||
'--allowlist-function', 'u_memstream.*',
|
||||
'--allowlist-type', 'u_memstream',
|
||||
'--no-prepend-enum-name',
|
||||
'--with-derive-default',
|
||||
]
|
||||
|
||||
foreach type : _compiler_binding_types
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ _nak_bindings_rs = rust.bindgen(
|
|||
'--allowlist-function', 'nak_.*',
|
||||
'--allowlist-function', 'nouveau_ws_.*',
|
||||
'--no-prepend-enum-name',
|
||||
'--with-derive-default',
|
||||
],
|
||||
dependencies : [
|
||||
dep_libdrm,
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ pub extern "C" fn nak_should_print_nir() -> bool {
|
|||
}
|
||||
|
||||
fn nir_options(dev: &nv_device_info) -> nir_shader_compiler_options {
|
||||
let mut op: nir_shader_compiler_options = unsafe { std::mem::zeroed() };
|
||||
let mut op: nir_shader_compiler_options = Default::default();
|
||||
|
||||
op.lower_fdiv = true;
|
||||
op.fuse_ffma16 = true;
|
||||
|
|
@ -319,11 +319,11 @@ impl ShaderBin {
|
|||
xfb: if let Some(xfb) = &io.xfb {
|
||||
**xfb
|
||||
} else {
|
||||
unsafe { std::mem::zeroed() }
|
||||
Default::default()
|
||||
},
|
||||
_pad: Default::default(),
|
||||
},
|
||||
_ => unsafe { std::mem::zeroed() },
|
||||
_ => Default::default(),
|
||||
},
|
||||
hdr: sph::encode_header(sm, info, fs_key),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct DrmDevices {
|
|||
impl DrmDevices {
|
||||
fn get() -> io::Result<Self> {
|
||||
unsafe {
|
||||
let mut devices: [drmDevicePtr; 16] = std::mem::zeroed();
|
||||
let mut devices: [drmDevicePtr; 16] = [std::ptr::null_mut(); 16];
|
||||
let num_devices = drmGetDevices(
|
||||
devices.as_mut_ptr(),
|
||||
devices.len().try_into().unwrap(),
|
||||
|
|
@ -465,7 +465,7 @@ impl<'a> Runner {
|
|||
);
|
||||
|
||||
// Populate and upload the QMD
|
||||
let mut qmd_cbufs: [nak_qmd_cbuf; 8] = unsafe { std::mem::zeroed() };
|
||||
let mut qmd_cbufs: [nak_qmd_cbuf; 8] = Default::default();
|
||||
qmd_cbufs[0] = nak_qmd_cbuf {
|
||||
index: 0,
|
||||
size: std::mem::size_of::<CB0>()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue