Use C string literals not cstr!
Since Rust 1.77.0 the language has supported C string literals, so the
`cstr!` macro is no longer needed. Replace existing usages with the
equivalent literal.
See https://doc.rust-lang.org/reference/tokens.html#c-string-literals.
I believe that the two are equivalent:
- Escapes are handled the same way;
- Both allow arbitrary Unicode, which is mapped to UTF-8 (I don't
think we made any use of this);
- Both treat any embedded NUL character as a compile time error.
This is of no significance whatsoever, but it does make the code a
tiny bit simpler. It should not change the compiled code at all, so
no flagging should be needed.
I'm not deleting the macro in this CL; I'll do a follow-up for that,
since there may be usages I can't see, and it has greater chance of
accidental conflict.
Test: TH
Change-Id: I4354b3b0a0c53fbec0c2d78b4182786e4e2d0ce8
diff --git a/guest/rialto/src/fdt.rs b/guest/rialto/src/fdt.rs
index e97a262..06879d0 100644
--- a/guest/rialto/src/fdt.rs
+++ b/guest/rialto/src/fdt.rs
@@ -15,24 +15,23 @@
//! High-level FDT functions.
use core::ops::Range;
-use cstr::cstr;
use libfdt::{Fdt, FdtError};
/// Reads the DICE data range from the given `fdt`.
pub fn read_dice_range_from(fdt: &Fdt) -> libfdt::Result<Range<usize>> {
- let node = fdt.node(cstr!("/reserved-memory"))?.ok_or(FdtError::NotFound)?;
- let node = node.next_compatible(cstr!("google,open-dice"))?.ok_or(FdtError::NotFound)?;
+ let node = fdt.node(c"/reserved-memory")?.ok_or(FdtError::NotFound)?;
+ let node = node.next_compatible(c"google,open-dice")?.ok_or(FdtError::NotFound)?;
node.first_reg()?.try_into()
}
pub(crate) fn read_vendor_hashtree_root_digest(fdt: &Fdt) -> libfdt::Result<Option<&[u8]>> {
- let node = fdt.node(cstr!("/avf"))?.ok_or(FdtError::NotFound)?;
- node.getprop(cstr!("vendor_hashtree_descriptor_root_digest"))
+ let node = fdt.node(c"/avf")?.ok_or(FdtError::NotFound)?;
+ node.getprop(c"vendor_hashtree_descriptor_root_digest")
}
pub(crate) fn read_is_strict_boot(fdt: &Fdt) -> libfdt::Result<bool> {
match fdt.chosen()? {
- Some(node) => Ok(node.getprop(cstr!("avf,strict-boot"))?.is_some()),
+ Some(node) => Ok(node.getprop(c"avf,strict-boot")?.is_some()),
None => Ok(false),
}
}