From 77a8271bf2a3fca15a02be2c08419a7940a34ba9 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sun, 9 Oct 2022 22:09:23 -0700 Subject: [PATCH] Replaced `0 as *{const,mut} _` with `std::ptr::null{,_mut}()` for strict provenance. --- analysis/test/src/pointers.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/analysis/test/src/pointers.rs b/analysis/test/src/pointers.rs index fe0b88374f..85d66299d1 100644 --- a/analysis/test/src/pointers.rs +++ b/analysis/test/src/pointers.rs @@ -75,7 +75,7 @@ pub struct S { pub field4: T, } #[no_mangle] -pub static mut global: *mut S = 0 as *const S as *mut S; +pub static mut global: *mut S = std::ptr::null_mut(); #[no_mangle] pub unsafe extern "C" fn malloc_wrapper(mut size: size_t) -> *mut libc::c_void { return malloc(size); @@ -105,7 +105,7 @@ pub unsafe extern "C" fn simple() { (*y).field4 = T { field: 0i32, field2: 0u64, - field3: 0 as *const S, + field3: std::ptr::null(), field4: 0i32, }; let s = *y; @@ -232,7 +232,7 @@ pub unsafe extern "C" fn fdevent_unregister(mut ev: *mut fdevents, mut fd: libc: return; } let ref mut fresh1 = *((*ev).fdarray).offset(fd as isize); - *fresh1 = 0 as *mut fdnode; + *fresh1 = std::ptr::null_mut(); fdnode_free(fdn); } unsafe extern "C" fn fdnode_free(mut fdn: *mut fdnode) { @@ -345,7 +345,7 @@ pub unsafe extern "C" fn invalid() { b"%i\n\x00" as *const u8 as *const libc::c_char, (*global).field, ); - global = 0 as *mut S; + global = std::ptr::null_mut(); free(s as *mut libc::c_void); } pub unsafe extern "C" fn testing() { @@ -416,14 +416,14 @@ pub unsafe extern "C" fn test_ref_field() { let t = T { field: 0i32, field2: 0u64, - field3: 0 as *const S, + field3: std::ptr::null(), field4: 0i32, }; let ref mut s = S { field: 0i32, field2: 0u64, - field3: 0 as *const S, + field3: std::ptr::null(), field4: t, }; s.field4.field4 = s.field4.field4;