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/libs/libvmbase/src/fdt.rs b/libs/libvmbase/src/fdt.rs
index aaf354e..2113787 100644
--- a/libs/libvmbase/src/fdt.rs
+++ b/libs/libvmbase/src/fdt.rs
@@ -17,7 +17,6 @@
pub mod pci;
use core::ops::Range;
-use cstr::cstr;
use libfdt::{self, Fdt, FdtError};
/// Represents information about a SWIOTLB buffer.
@@ -34,7 +33,7 @@
impl SwiotlbInfo {
/// Creates a `SwiotlbInfo` struct from the given device tree.
pub fn new_from_fdt(fdt: &Fdt) -> libfdt::Result<Option<SwiotlbInfo>> {
- let Some(node) = fdt.compatible_nodes(cstr!("restricted-dma-pool"))?.next() else {
+ let Some(node) = fdt.compatible_nodes(c"restricted-dma-pool")?.next() else {
return Ok(None);
};
let (addr, size, align) = if let Some(mut reg) = node.reg()? {
@@ -42,8 +41,8 @@
let size = reg.size.ok_or(FdtError::BadValue)?;
(Some(reg.addr.try_into().unwrap()), size.try_into().unwrap(), None)
} else {
- let size = node.getprop_u64(cstr!("size"))?.ok_or(FdtError::NotFound)?;
- let align = node.getprop_u64(cstr!("alignment"))?.ok_or(FdtError::NotFound)?;
+ let size = node.getprop_u64(c"size")?.ok_or(FdtError::NotFound)?;
+ let align = node.getprop_u64(c"alignment")?.ok_or(FdtError::NotFound)?;
(None, size.try_into().unwrap(), Some(align.try_into().unwrap()))
};
Ok(Some(Self { addr, size, align }))