Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d4234cb authored by Andrew Walbran's avatar Andrew Walbran
Browse files

Allow unsafe operations in unsafe functions in generated code.

This will soon be denied by default, but we trust that what cxx does is
correct. Also added a missing safety comment.

Bug: 290018030
Test: m rust
Change-Id: I55e3cad8cdfcd2053d01adfb7eb1e60858b813fd
parent d6e6a504
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ use log::debug;
const LOG_TAG: &str = "inputflinger_bootstrap";

#[cxx::bridge]
#[allow(unsafe_op_in_unsafe_fn)]
mod ffi {
    extern "C++" {
        include!("InputFlingerBootstrap.h");
@@ -67,7 +68,9 @@ unsafe fn create_inputflinger_rust(callback: *mut ffi::IInputFlingerRustBootstra
        panic!("create_inputflinger_rust cannot be called with a null callback");
    }

    let Some(callback) = new_spibinder(callback) else {
    // SAFETY: Our caller guaranteed that `callback` is a valid pointer to an `AIBinder` and its
    // reference count has been incremented..
    let Some(callback) = (unsafe { new_spibinder(callback) }) else {
            panic!("Failed to get SpAIBinder from raw callback pointer");
        };