Add cstr! macro
cstr!("X") is a shorthand for CStr::from_bytes_with_nul(b"X\0").unwrap()
Bug: 249054080
Test: TH
Change-Id: Iefdaa07179fe3b556fc9bc17595919ac93b7e569
diff --git a/pvmfw/src/helpers.rs b/pvmfw/src/helpers.rs
index e6e3406..fddd8c3 100644
--- a/pvmfw/src/helpers.rs
+++ b/pvmfw/src/helpers.rs
@@ -113,3 +113,11 @@
reg.zeroize();
flush(reg)
}
+
+/// Create &CStr out of &str literal
+#[macro_export]
+macro_rules! cstr {
+ ($str:literal) => {{
+ CStr::from_bytes_with_nul(concat!($str, "\0").as_bytes()).unwrap()
+ }};
+}