Skip to content

Commit 77a8271

Browse files
committed
Replaced 0 as *{const,mut} _ with std::ptr::null{,_mut}() for strict provenance.
1 parent e657818 commit 77a8271

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

analysis/test/src/pointers.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct S {
7575
pub field4: T,
7676
}
7777
#[no_mangle]
78-
pub static mut global: *mut S = 0 as *const S as *mut S;
78+
pub static mut global: *mut S = std::ptr::null_mut();
7979
#[no_mangle]
8080
pub unsafe extern "C" fn malloc_wrapper(mut size: size_t) -> *mut libc::c_void {
8181
return malloc(size);
@@ -105,7 +105,7 @@ pub unsafe extern "C" fn simple() {
105105
(*y).field4 = T {
106106
field: 0i32,
107107
field2: 0u64,
108-
field3: 0 as *const S,
108+
field3: std::ptr::null(),
109109
field4: 0i32,
110110
};
111111
let s = *y;
@@ -232,7 +232,7 @@ pub unsafe extern "C" fn fdevent_unregister(mut ev: *mut fdevents, mut fd: libc:
232232
return;
233233
}
234234
let ref mut fresh1 = *((*ev).fdarray).offset(fd as isize);
235-
*fresh1 = 0 as *mut fdnode;
235+
*fresh1 = std::ptr::null_mut();
236236
fdnode_free(fdn);
237237
}
238238
unsafe extern "C" fn fdnode_free(mut fdn: *mut fdnode) {
@@ -345,7 +345,7 @@ pub unsafe extern "C" fn invalid() {
345345
b"%i\n\x00" as *const u8 as *const libc::c_char,
346346
(*global).field,
347347
);
348-
global = 0 as *mut S;
348+
global = std::ptr::null_mut();
349349
free(s as *mut libc::c_void);
350350
}
351351
pub unsafe extern "C" fn testing() {
@@ -416,14 +416,14 @@ pub unsafe extern "C" fn test_ref_field() {
416416
let t = T {
417417
field: 0i32,
418418
field2: 0u64,
419-
field3: 0 as *const S,
419+
field3: std::ptr::null(),
420420
field4: 0i32,
421421
};
422422

423423
let ref mut s = S {
424424
field: 0i32,
425425
field2: 0u64,
426-
field3: 0 as *const S,
426+
field3: std::ptr::null(),
427427
field4: t,
428428
};
429429
s.field4.field4 = s.field4.field4;

0 commit comments

Comments
 (0)