Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed Jul 2, 2024
1 parent 0c78a48 commit 4dbee55
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/error_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ fn test_error_handler() {
}

fn use_error_handler() {
let errors: Arc<Mutex<Vec<(CplErrType, i32, String)>>> = Arc::new(Mutex::new(vec![]));
let errors: Arc<Mutex<Vec<(CplErrType, i32, String)>>> = Arc::new(Mutex::new(Vec::new()));

let errors_clone = errors.clone();

config::set_error_handler(move |a, b, c| {
errors_clone.lock().unwrap().push((a, b, c.to_string()));
});

let msg = CString::new("foo".as_bytes()).unwrap();
unsafe {
let msg = CString::new("foo".as_bytes()).unwrap();
CPLError(CPLErr::CE_Failure, 42, msg.as_ptr());
};

let msg = CString::new("bar".as_bytes()).unwrap();
unsafe {
let msg = CString::new("bar".as_bytes()).unwrap();
CPLError(std::mem::transmute(CplErrType::Warning), 1, msg.as_ptr());
CPLError(CPLErr::CE_Warning, 1, msg.as_ptr());
};

config::remove_error_handler();
Expand Down Expand Up @@ -63,14 +63,14 @@ fn error_handler_interleaved() {
// A thread that provokes potential race conditions
let join_handle = thread::spawn(move || {
for _ in 0..100 {
let msg = CString::new("foo".as_bytes()).unwrap();
unsafe {
let msg = CString::new("foo".as_bytes()).unwrap();
CPLError(CPLErr::CE_Failure, 42, msg.as_ptr());
};

let msg = CString::new("bar".as_bytes()).unwrap();
unsafe {
let msg = CString::new("bar".as_bytes()).unwrap();
CPLError(std::mem::transmute(CplErrType::Warning), 1, msg.as_ptr());
CPLError(CPLErr::CE_Warning, 1, msg.as_ptr());
};
}
});
Expand Down

0 comments on commit 4dbee55

Please sign in to comment.