Skip to content

Commit

Permalink
Merge pull request #651 from 7flying/fix-clippy-warnings
Browse files Browse the repository at this point in the history
fix: static-mut-refs warning
  • Loading branch information
mergify[bot] committed Mar 21, 2024
2 parents 657fefb + ce0892a commit b5d415e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libfdo-data/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use libc::c_char;
use std::ptr::addr_of;
use std::{ffi::CString, ptr::null_mut};

#[cfg(test)]
Expand Down Expand Up @@ -41,8 +42,15 @@ pub unsafe extern "C" fn fdo_free_string(s: *mut c_char) {
/// be freed with `fdo_free_string`
#[no_mangle]
pub extern "C" fn fdo_get_last_error() -> *mut c_char {
match unsafe { &LAST_ERROR } {
None => null_mut(),
Some(e) => CString::new(e.as_bytes()).unwrap().into_raw(),
let result = unsafe { addr_of!(LAST_ERROR) };
if result.is_null() {
null_mut()
} else {
match unsafe { result.as_ref() } {
None => null_mut(),
Some(e) => CString::new(e.clone().unwrap().as_bytes())
.unwrap()
.into_raw(),
}
}
}
1 change: 1 addition & 0 deletions owner-onboarding-server/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ pub(super) async fn done(
}

#[derive(Debug)]
#[allow(dead_code)]
struct RtrFailure(anyhow::Error);
impl warp::reject::Reject for RtrFailure {}

Expand Down
1 change: 1 addition & 0 deletions serviceinfo-api-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tokio::signal::unix::{signal, SignalKind};
use warp::Filter;

#[derive(Debug)]
#[allow(dead_code)]
struct ServiceInfoFailure(anyhow::Error);
impl warp::reject::Reject for ServiceInfoFailure {}

Expand Down

0 comments on commit b5d415e

Please sign in to comment.