diff --git a/libfdo-data/src/lib.rs b/libfdo-data/src/lib.rs index 8d5dcfb1f..5988f8555 100644 --- a/libfdo-data/src/lib.rs +++ b/libfdo-data/src/lib.rs @@ -1,4 +1,5 @@ use libc::c_char; +use std::ptr::addr_of; use std::{ffi::CString, ptr::null_mut}; #[cfg(test)] @@ -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(), + } } } diff --git a/owner-onboarding-server/src/handlers.rs b/owner-onboarding-server/src/handlers.rs index 87a12f0c8..7c4f4bf1c 100644 --- a/owner-onboarding-server/src/handlers.rs +++ b/owner-onboarding-server/src/handlers.rs @@ -664,6 +664,7 @@ pub(super) async fn done( } #[derive(Debug)] +#[allow(dead_code)] struct RtrFailure(anyhow::Error); impl warp::reject::Reject for RtrFailure {} diff --git a/serviceinfo-api-server/src/main.rs b/serviceinfo-api-server/src/main.rs index ec0dc6f64..450ee1861 100644 --- a/serviceinfo-api-server/src/main.rs +++ b/serviceinfo-api-server/src/main.rs @@ -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 {}