diff --git a/system-configuration/src/network_reachability.rs b/system-configuration/src/network_reachability.rs index 081a757..60a65a5 100644 --- a/system-configuration/src/network_reachability.rs +++ b/system-configuration/src/network_reachability.rs @@ -393,14 +393,19 @@ mod test { addr ); reachability.set_callback(|_| {}).unwrap(); - reachability - .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { kCFRunLoopCommonModes }) - .unwrap(); - reachability - .unschedule_from_runloop(&CFRunLoop::get_current(), unsafe { - kCFRunLoopCommonModes - }) - .unwrap(); + // SAFETY: We use the Apple provided run_loop_mode kCFRunLoopCommonModes + unsafe { + reachability + .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { + kCFRunLoopCommonModes + }) + .unwrap(); + reachability + .unschedule_from_runloop(&CFRunLoop::get_current(), unsafe { + kCFRunLoopCommonModes + }) + .unwrap(); + } } } @@ -424,14 +429,19 @@ mod test { remote ); reachability.set_callback(|_| {}).unwrap(); - reachability - .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { kCFRunLoopCommonModes }) - .unwrap(); - reachability - .unschedule_from_runloop(&CFRunLoop::get_current(), unsafe { - kCFRunLoopCommonModes - }) - .unwrap(); + // SAFETY: We use the Apple provided run_loop_mode kCFRunLoopCommonModes + unsafe { + reachability + .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { + kCFRunLoopCommonModes + }) + .unwrap(); + reachability + .unschedule_from_runloop(&CFRunLoop::get_current(), unsafe { + kCFRunLoopCommonModes + }) + .unwrap(); + } } } @@ -445,16 +455,19 @@ mod test { match SCNetworkReachability::from_host(&input) { Some(mut reachability) => { reachability.set_callback(|_| {}).unwrap(); - reachability - .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { - kCFRunLoopCommonModes - }) - .unwrap(); - reachability - .unschedule_from_runloop(&CFRunLoop::get_current(), unsafe { - kCFRunLoopCommonModes - }) - .unwrap(); + // SAFETY: We use the Apple provided run_loop_mode kCFRunLoopCommonModes + unsafe { + reachability + .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { + kCFRunLoopCommonModes + }) + .unwrap(); + reachability + .unschedule_from_runloop(&CFRunLoop::get_current(), unsafe { + kCFRunLoopCommonModes + }) + .unwrap(); + } } None => { panic!( @@ -481,9 +494,14 @@ mod test { let mut reachability = SCNetworkReachability::from("0.0.0.0:0".parse::().unwrap()); reachability.set_callback(|_| {}).unwrap(); - reachability - .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { kCFRunLoopCommonModes }) - .unwrap(); + // SAFETY: We use the Apple provided run_loop_mode kCFRunLoopCommonModes + unsafe { + reachability + .schedule_with_runloop(&CFRunLoop::get_current(), unsafe { + kCFRunLoopCommonModes + }) + .unwrap(); + } reachability.set_callback(|_| {}).unwrap(); let _ = tx.send(reachability); CFRunLoop::run_current();