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

Commit 91d42e48 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libbinder_rs: Modify asserts to propagate failure to C++" am: f867ed2f am: 4fb0f925

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1588098

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie47a34351cdfc3a9e8eccf82766ca9b1c2fbaf95
parents 32901861 4fb0f925
Loading
Loading
Loading
Loading
+36 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,41 @@ mod bindings {
    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
}


macro_rules! assert_eq {
    ($left:expr, $right:expr $(,)?) => {
        match (&$left, &$right) {
            (left, right) => {
                if *left != *right {
                    eprintln!(
                        "assertion failed: `{:?}` == `{:?}`, {}:{}:{}",
                        &*left,
                        &*right,
                        file!(),
                        line!(),
                        column!()
                    );
                    return Err(StatusCode::FAILED_TRANSACTION);
                }
            }
        }
    };
}

macro_rules! assert {
    ($expr:expr) => {
        if !$expr {
            eprintln!(
                "assertion failed: `{:?}`, {}:{}:{}",
                $expr,
                file!(),
                line!(),
                column!()
            );
            return Err(StatusCode::FAILED_TRANSACTION);
        }
    };
}

static SERVICE_ONCE: Once = Once::new();
static SERVICE_ONCE: Once = Once::new();
static mut SERVICE: Option<SpIBinder> = None;
static mut SERVICE: Option<SpIBinder> = None;


@@ -282,7 +317,7 @@ fn on_transact(_service: &dyn ReadParcelTest, code: TransactionCode,
            ))?;
            ))?;
        }
        }
        bindings::Transaction_TEST_FAIL => {
        bindings::Transaction_TEST_FAIL => {
            return Err(StatusCode::FAILED_TRANSACTION)
            assert!(false);
        }
        }
        _ => return Err(StatusCode::UNKNOWN_TRANSACTION),
        _ => return Err(StatusCode::UNKNOWN_TRANSACTION),
    }
    }