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/libfdt/Android.bp b/libs/libfdt/Android.bp
index 09f288d..829b30f 100644
--- a/libs/libfdt/Android.bp
+++ b/libs/libfdt/Android.bp
@@ -35,7 +35,6 @@
],
edition: "2021",
rustlibs: [
- "libcstr",
"liblibfdt_bindgen",
"libstatic_assertions",
"libzerocopy_nostd",
@@ -79,7 +78,6 @@
],
prefer_rlib: true,
rustlibs: [
- "libcstr",
"liblibfdt",
],
}
diff --git a/libs/libfdt/src/lib.rs b/libs/libfdt/src/lib.rs
index c969749..0dcd31a 100644
--- a/libs/libfdt/src/lib.rs
+++ b/libs/libfdt/src/lib.rs
@@ -31,7 +31,6 @@
use core::ffi::{c_void, CStr};
use core::ops::Range;
-use cstr::cstr;
use libfdt::get_slice_at_ptr;
use zerocopy::IntoBytes as _;
@@ -167,12 +166,12 @@
/// Returns the standard (deprecated) device_type <string> property.
pub fn device_type(&self) -> Result<Option<&CStr>> {
- self.getprop_str(cstr!("device_type"))
+ self.getprop_str(c"device_type")
}
/// Returns the standard reg <prop-encoded-array> property.
pub fn reg(&self) -> Result<Option<RegIterator<'a>>> {
- if let Some(cells) = self.getprop_cells(cstr!("reg"))? {
+ if let Some(cells) = self.getprop_cells(c"reg")? {
let parent = self.parent()?;
let addr_cells = parent.address_cells()?;
@@ -186,7 +185,7 @@
/// Returns the standard ranges property.
pub fn ranges<A, P, S>(&self) -> Result<Option<RangesIterator<'a, A, P, S>>> {
- if let Some(cells) = self.getprop_cells(cstr!("ranges"))? {
+ if let Some(cells) = self.getprop_cells(c"ranges")? {
let parent = self.parent()?;
let addr_cells = self.address_cells()?;
let parent_addr_cells = parent.address_cells()?;
@@ -320,9 +319,9 @@
/// Returns the phandle
pub fn get_phandle(&self) -> Result<Option<Phandle>> {
// This rewrites the fdt_get_phandle() because it doesn't return error code.
- if let Some(prop) = self.getprop_u32(cstr!("phandle"))? {
+ if let Some(prop) = self.getprop_u32(c"phandle")? {
Ok(Some(prop.try_into()?))
- } else if let Some(prop) = self.getprop_u32(cstr!("linux,phandle"))? {
+ } else if let Some(prop) = self.getprop_u32(c"linux,phandle")? {
Ok(Some(prop.try_into()?))
} else {
Ok(None)
@@ -693,8 +692,8 @@
///
/// NOTE: This does not support individual "/memory@XXXX" banks.
pub fn memory(&self) -> Result<MemRegIterator> {
- let node = self.root().subnode(cstr!("memory"))?.ok_or(FdtError::NotFound)?;
- if node.device_type()? != Some(cstr!("memory")) {
+ let node = self.root().subnode(c"memory")?.ok_or(FdtError::NotFound)?;
+ if node.device_type()? != Some(c"memory") {
return Err(FdtError::BadValue);
}
node.reg()?.ok_or(FdtError::BadValue).map(MemRegIterator::new)
@@ -707,12 +706,12 @@
/// Returns the standard /chosen node.
pub fn chosen(&self) -> Result<Option<FdtNode>> {
- self.root().subnode(cstr!("chosen"))
+ self.root().subnode(c"chosen")
}
/// Returns the standard /chosen node as mutable.
pub fn chosen_mut(&mut self) -> Result<Option<FdtNodeMut>> {
- self.node_mut(cstr!("/chosen"))
+ self.node_mut(c"/chosen")
}
/// Returns the root node of the tree.
@@ -722,12 +721,12 @@
/// Returns the standard /__symbols__ node.
pub fn symbols(&self) -> Result<Option<FdtNode>> {
- self.root().subnode(cstr!("__symbols__"))
+ self.root().subnode(c"__symbols__")
}
/// Returns the standard /__symbols__ node as mutable
pub fn symbols_mut(&mut self) -> Result<Option<FdtNodeMut>> {
- self.node_mut(cstr!("/__symbols__"))
+ self.node_mut(c"/__symbols__")
}
/// Returns a tree node by its full path.
diff --git a/libs/libfdt/tests/api_test.rs b/libs/libfdt/tests/api_test.rs
index f521a00..e027164 100644
--- a/libs/libfdt/tests/api_test.rs
+++ b/libs/libfdt/tests/api_test.rs
@@ -17,7 +17,6 @@
//! Integration tests of the library libfdt.
use core::ffi::CStr;
-use cstr::cstr;
use libfdt::{Fdt, FdtError, FdtNodeMut, Phandle};
use std::collections::HashSet;
use std::ffi::CString;
@@ -82,14 +81,14 @@
let fdt = Fdt::from_slice(&data).unwrap();
let root = fdt.root();
- assert_eq!(root.name(), Ok(cstr!("")));
+ assert_eq!(root.name(), Ok(c""));
let chosen = fdt.chosen().unwrap().unwrap();
- assert_eq!(chosen.name(), Ok(cstr!("chosen")));
+ assert_eq!(chosen.name(), Ok(c"chosen"));
- let nested_node_path = cstr!("/cpus/PowerPC,970@0");
+ let nested_node_path = c"/cpus/PowerPC,970@0";
let nested_node = fdt.node(nested_node_path).unwrap().unwrap();
- assert_eq!(nested_node.name(), Ok(cstr!("PowerPC,970@0")));
+ assert_eq!(nested_node.name(), Ok(c"PowerPC,970@0"));
}
#[test]
@@ -97,7 +96,7 @@
let data = fs::read(TEST_TREE_WITH_NO_MEMORY_NODE_PATH).unwrap();
let fdt = Fdt::from_slice(&data).unwrap();
let root = fdt.root();
- let expected = [Ok(cstr!("cpus")), Ok(cstr!("randomnode")), Ok(cstr!("chosen"))];
+ let expected = [Ok(c"cpus"), Ok(c"randomnode"), Ok(c"chosen")];
let root_subnodes = root.subnodes().unwrap();
let subnode_names: Vec<_> = root_subnodes.map(|node| node.name()).collect();
@@ -112,11 +111,11 @@
let one_be = 0x1_u32.to_be_bytes();
type Result<T> = core::result::Result<T, FdtError>;
let expected: Vec<(Result<&CStr>, Result<&[u8]>)> = vec![
- (Ok(cstr!("model")), Ok(b"MyBoardName\0".as_ref())),
- (Ok(cstr!("compatible")), Ok(b"MyBoardName\0MyBoardFamilyName\0".as_ref())),
- (Ok(cstr!("#address-cells")), Ok(&one_be)),
- (Ok(cstr!("#size-cells")), Ok(&one_be)),
- (Ok(cstr!("empty_prop")), Ok(&[])),
+ (Ok(c"model"), Ok(b"MyBoardName\0".as_ref())),
+ (Ok(c"compatible"), Ok(b"MyBoardName\0MyBoardFamilyName\0".as_ref())),
+ (Ok(c"#address-cells"), Ok(&one_be)),
+ (Ok(c"#size-cells"), Ok(&one_be)),
+ (Ok(c"empty_prop"), Ok(&[])),
];
let properties = root.properties().unwrap();
@@ -129,8 +128,8 @@
fn node_supernode_at_depth() {
let data = fs::read(TEST_TREE_WITH_NO_MEMORY_NODE_PATH).unwrap();
let fdt = Fdt::from_slice(&data).unwrap();
- let node = fdt.node(cstr!("/cpus/PowerPC,970@1")).unwrap().unwrap();
- let expected = vec![Ok(cstr!("")), Ok(cstr!("cpus")), Ok(cstr!("PowerPC,970@1"))];
+ let node = fdt.node(c"/cpus/PowerPC,970@1").unwrap().unwrap();
+ let expected = vec![Ok(c""), Ok(c"cpus"), Ok(c"PowerPC,970@1")];
let mut supernode_names = vec![];
let mut depth = 0;
@@ -187,12 +186,12 @@
// Test linux,phandle
let phandle = Phandle::new(0xFF).unwrap();
let node = fdt.node_with_phandle(phandle).unwrap().unwrap();
- assert_eq!(node.name(), Ok(cstr!("node_zz")));
+ assert_eq!(node.name(), Ok(c"node_zz"));
// Test phandle
let phandle = Phandle::new(0x22).unwrap();
let node = fdt.node_with_phandle(phandle).unwrap().unwrap();
- assert_eq!(node.name(), Ok(cstr!("node_abc")));
+ assert_eq!(node.name(), Ok(c"node_abc"));
}
#[test]
@@ -203,12 +202,12 @@
// Test linux,phandle
let phandle = Phandle::new(0xFF).unwrap();
let node: FdtNodeMut = fdt.node_mut_with_phandle(phandle).unwrap().unwrap();
- assert_eq!(node.as_node().name(), Ok(cstr!("node_zz")));
+ assert_eq!(node.as_node().name(), Ok(c"node_zz"));
// Test phandle
let phandle = Phandle::new(0x22).unwrap();
let node: FdtNodeMut = fdt.node_mut_with_phandle(phandle).unwrap().unwrap();
- assert_eq!(node.as_node().name(), Ok(cstr!("node_abc")));
+ assert_eq!(node.as_node().name(), Ok(c"node_abc"));
}
#[test]
@@ -217,15 +216,15 @@
let fdt = Fdt::from_slice(&data).unwrap();
// Test linux,phandle
- let node = fdt.node(cstr!("/node_z/node_zz")).unwrap().unwrap();
+ let node = fdt.node(c"/node_z/node_zz").unwrap().unwrap();
assert_eq!(node.get_phandle(), Ok(Phandle::new(0xFF)));
// Test phandle
- let node = fdt.node(cstr!("/node_a/node_ab/node_abc")).unwrap().unwrap();
+ let node = fdt.node(c"/node_a/node_ab/node_abc").unwrap().unwrap();
assert_eq!(node.get_phandle(), Ok(Phandle::new(0x22)));
// Test no phandle
- let node = fdt.node(cstr!("/node_b")).unwrap().unwrap();
+ let node = fdt.node(c"/node_b").unwrap().unwrap();
assert_eq!(node.get_phandle(), Ok(None));
}
@@ -234,7 +233,7 @@
let mut data = fs::read(TEST_TREE_PHANDLE_PATH).unwrap();
let fdt = Fdt::from_mut_slice(&mut data).unwrap();
let phandle = Phandle::new(0xFF).unwrap();
- let path = cstr!("/node_z/node_zz");
+ let path = c"/node_z/node_zz";
fdt.node_with_phandle(phandle).unwrap().unwrap();
let node = fdt.node_mut(path).unwrap().unwrap();
@@ -259,8 +258,8 @@
let fdt = Fdt::from_mut_slice(&mut data).unwrap();
fdt.unpack().unwrap();
- let node_path = cstr!("/node_z/node_zz");
- let subnode_name = cstr!("123456789");
+ let node_path = c"/node_z/node_zz";
+ let subnode_name = c"123456789";
for len in 0..subnode_name.to_bytes().len() {
let name = &subnode_name.to_bytes()[0..len];
@@ -289,7 +288,7 @@
let data = fs::read(TEST_TREE_PHANDLE_PATH).unwrap();
let fdt = Fdt::from_slice(&data).unwrap();
- let name = cstr!("node_a");
+ let name = c"node_a";
let root = fdt.root();
let node = root.subnode(name).unwrap();
assert_ne!(None, node);
@@ -309,7 +308,7 @@
assert_ne!(None, node);
let node = node.unwrap();
- assert_eq!(Ok(cstr!("node_a")), node.name());
+ assert_eq!(Ok(c"node_a"), node.name());
}
#[test]
@@ -317,7 +316,7 @@
let data = fs::read(TEST_TREE_PHANDLE_PATH).unwrap();
let fdt = Fdt::from_slice(&data).unwrap();
- let name = cstr!("node_a");
+ let name = c"node_a";
let node = {
let root = fdt.root();
root.subnode(name).unwrap().unwrap()
@@ -332,7 +331,7 @@
let fdt = Fdt::from_mut_slice(&mut data).unwrap();
let symbols = fdt.symbols().unwrap().unwrap();
- assert_eq!(symbols.name(), Ok(cstr!("__symbols__")));
+ assert_eq!(symbols.name(), Ok(c"__symbols__"));
// Validates type.
let _symbols: FdtNodeMut = fdt.symbols_mut().unwrap().unwrap();
@@ -343,14 +342,14 @@
let mut data = fs::read(TEST_TREE_WITH_ONE_MEMORY_RANGE_PATH).unwrap();
let fdt = Fdt::from_mut_slice(&mut data).unwrap();
- let mut memory = fdt.node_mut(cstr!("/memory")).unwrap().unwrap();
+ let mut memory = fdt.node_mut(c"/memory").unwrap().unwrap();
{
let memory = memory.as_node();
- assert_eq!(memory.name(), Ok(cstr!("memory")));
+ assert_eq!(memory.name(), Ok(c"memory"));
}
// Just check whether borrow checker doesn't complain this.
- memory.setprop_inplace(cstr!("device_type"), b"MEMORY\0").unwrap();
+ memory.setprop_inplace(c"device_type", b"MEMORY\0").unwrap();
}
#[test]
@@ -358,18 +357,13 @@
let mut data = fs::read(TEST_TREE_PHANDLE_PATH).unwrap();
let fdt = Fdt::from_mut_slice(&mut data).unwrap();
- let node_z = fdt.node(cstr!("/node_z")).unwrap().unwrap();
+ let node_z = fdt.node(c"/node_z").unwrap().unwrap();
let descendants: Vec<_> =
node_z.descendants().map(|(node, depth)| (node.name().unwrap(), depth)).collect();
assert_eq!(
descendants,
- vec![
- (cstr!("node_za"), 1),
- (cstr!("node_zb"), 1),
- (cstr!("node_zz"), 1),
- (cstr!("node_zzz"), 2)
- ]
+ vec![(c"node_za", 1), (c"node_zb", 1), (c"node_zz", 1), (c"node_zzz", 2)]
);
}
@@ -382,7 +376,7 @@
let mut subnode_iter = root.first_subnode().unwrap();
while let Some(subnode) = subnode_iter {
- if subnode.as_node().name() == Ok(cstr!("node_z")) {
+ if subnode.as_node().name() == Ok(c"node_z") {
subnode_iter = subnode.delete_and_next_subnode().unwrap();
} else {
subnode_iter = subnode.next_subnode().unwrap();
@@ -390,12 +384,7 @@
}
let root = fdt.root();
- let expected_names = vec![
- Ok(cstr!("node_a")),
- Ok(cstr!("node_b")),
- Ok(cstr!("node_c")),
- Ok(cstr!("__symbols__")),
- ];
+ let expected_names = vec![Ok(c"node_a"), Ok(c"node_b"), Ok(c"node_c"), Ok(c"__symbols__")];
let subnode_names: Vec<_> = root.subnodes().unwrap().map(|node| node.name()).collect();
assert_eq!(expected_names, subnode_names);
@@ -407,19 +396,19 @@
let fdt = Fdt::from_mut_slice(&mut data).unwrap();
let expected_nodes = vec![
- (Ok(cstr!("node_b")), 1),
- (Ok(cstr!("node_c")), 1),
- (Ok(cstr!("node_z")), 1),
- (Ok(cstr!("node_za")), 2),
- (Ok(cstr!("node_zb")), 2),
- (Ok(cstr!("__symbols__")), 1),
+ (Ok(c"node_b"), 1),
+ (Ok(c"node_c"), 1),
+ (Ok(c"node_z"), 1),
+ (Ok(c"node_za"), 2),
+ (Ok(c"node_zb"), 2),
+ (Ok(c"__symbols__"), 1),
];
let mut expected_nodes_iter = expected_nodes.iter();
let mut iter = fdt.root_mut().next_node(0).unwrap();
while let Some((node, depth)) = iter {
let node_name = node.as_node().name();
- if node_name == Ok(cstr!("node_a")) || node_name == Ok(cstr!("node_zz")) {
+ if node_name == Ok(c"node_a") || node_name == Ok(c"node_zz") {
iter = node.delete_and_next_node(depth).unwrap();
} else {
// Note: Checking name here is easier than collecting names and assert_eq!(),
@@ -464,7 +453,7 @@
root.name()
// Make root to be dropped
};
- assert_eq!(Ok(cstr!("")), name);
+ assert_eq!(Ok(c""), name);
}
#[test]
@@ -473,7 +462,7 @@
let fdt = Fdt::create_empty_tree(&mut data).unwrap();
let root = fdt.root_mut();
- let names = [cstr!("a"), cstr!("b")];
+ let names = [c"a", c"b"];
root.add_subnodes(&names).unwrap();
let expected: HashSet<_> = names.into_iter().collect();
@@ -492,14 +481,14 @@
let name = {
let node_a = {
let root = fdt.root();
- root.subnode(cstr!("node_a")).unwrap()
+ root.subnode(c"node_a").unwrap()
// Make root to be dropped
};
assert_ne!(None, node_a);
node_a.unwrap().name()
// Make node_a to be dropped
};
- assert_eq!(Ok(cstr!("node_a")), name);
+ assert_eq!(Ok(c"node_a"), name);
}
#[test]
@@ -521,7 +510,7 @@
first_subnode.name()
// Make first_subnode to be dropped
};
- assert_eq!(Ok(cstr!("node_a")), first_subnode_name);
+ assert_eq!(Ok(c"node_a"), first_subnode_name);
}
#[test]
@@ -543,5 +532,5 @@
first_descendant.name()
// Make first_descendant to be dropped
};
- assert_eq!(Ok(cstr!("node_a")), first_descendant_name);
+ assert_eq!(Ok(c"node_a"), first_descendant_name);
}
diff --git a/libs/libservice_vm_fake_chain/Android.bp b/libs/libservice_vm_fake_chain/Android.bp
index 56fb22a..65eddf8 100644
--- a/libs/libservice_vm_fake_chain/Android.bp
+++ b/libs/libservice_vm_fake_chain/Android.bp
@@ -26,9 +26,6 @@
"//packages/modules/Virtualization/guest/rialto:__subpackages__",
],
prefer_rlib: true,
- rustlibs: [
- "libcstr",
- ],
}
rust_library {
diff --git a/libs/libservice_vm_fake_chain/src/client_vm.rs b/libs/libservice_vm_fake_chain/src/client_vm.rs
index dc499e0..fa72739 100644
--- a/libs/libservice_vm_fake_chain/src/client_vm.rs
+++ b/libs/libservice_vm_fake_chain/src/client_vm.rs
@@ -22,7 +22,6 @@
use ciborium::{cbor, value::Value};
use core::result;
use coset::CborSerializable;
-use cstr::cstr;
use diced_open_dice::{
hash, retry_bcc_format_config_descriptor, retry_bcc_main_flow, Config, DiceArtifacts,
DiceConfigValues, DiceError, DiceMode, InputValues, OwnedDiceArtifacts, Result, HASH_SIZE,
@@ -96,7 +95,7 @@
// Adds an entry describing the Microdroid kernel.
let config_values = DiceConfigValues {
- component_name: Some(cstr!("vm_entry")),
+ component_name: Some(c"vm_entry"),
component_version: Some(12),
resettable: true,
security_version: Some(13),
diff --git a/libs/libservice_vm_fake_chain/src/service_vm.rs b/libs/libservice_vm_fake_chain/src/service_vm.rs
index 04297e4..5064ff8 100644
--- a/libs/libservice_vm_fake_chain/src/service_vm.rs
+++ b/libs/libservice_vm_fake_chain/src/service_vm.rs
@@ -24,7 +24,6 @@
iana::{self, EnumI64},
Algorithm, AsCborValue, CborSerializable, CoseKey, KeyOperation, KeyType, Label,
};
-use cstr::cstr;
use diced_open_dice::{
derive_cdi_private_key_seed, keypair_from_seed, retry_bcc_format_config_descriptor,
retry_bcc_main_flow, retry_dice_main_flow, CdiValues, Config, DiceConfigValues, DiceError,
@@ -113,7 +112,7 @@
// Gets the pvmfw certificate to as the root certificate of DICE chain.
let config_values = DiceConfigValues {
- component_name: Some(cstr!("Protected VM firmware")),
+ component_name: Some(c"Protected VM firmware"),
component_version: Some(1),
resettable: true,
rkp_vm_marker: true,
@@ -156,7 +155,7 @@
pub fn fake_service_vm_dice_artifacts() -> Result<OwnedDiceArtifacts> {
let (cdi_values, dice_chain) = fake_dice_artifacts_up_to_pvmfw()?;
let config_values = DiceConfigValues {
- component_name: Some(cstr!("vm_entry")),
+ component_name: Some(c"vm_entry"),
component_version: Some(12),
resettable: true,
rkp_vm_marker: true,
diff --git a/libs/libvmbase/Android.bp b/libs/libvmbase/Android.bp
index 3088633..de347c7 100644
--- a/libs/libvmbase/Android.bp
+++ b/libs/libvmbase/Android.bp
@@ -80,7 +80,6 @@
"libaarch64_paging",
"libbuddy_system_allocator",
"libcfg_if",
- "libcstr",
"libhypervisor_backends",
"liblibfdt_nostd",
"liblog_rust_nostd",
diff --git a/libs/libvmbase/src/bionic.rs b/libs/libvmbase/src/bionic.rs
index 3c0cd6f..37b6e45 100644
--- a/libs/libvmbase/src/bionic.rs
+++ b/libs/libvmbase/src/bionic.rs
@@ -24,7 +24,6 @@
use core::slice;
use core::str;
-use cstr::cstr;
use log::error;
use log::info;
@@ -230,138 +229,138 @@
fn cstr_error(n: c_int) -> &'static CStr {
// Messages taken from errno(1).
match n {
- 0 => cstr!("Success"),
- 1 => cstr!("Operation not permitted"),
- 2 => cstr!("No such file or directory"),
- 3 => cstr!("No such process"),
- 4 => cstr!("Interrupted system call"),
- 5 => cstr!("Input/output error"),
- 6 => cstr!("No such device or address"),
- 7 => cstr!("Argument list too long"),
- 8 => cstr!("Exec format error"),
- 9 => cstr!("Bad file descriptor"),
- 10 => cstr!("No child processes"),
- 11 => cstr!("Resource temporarily unavailable"),
- 12 => cstr!("Cannot allocate memory"),
- 13 => cstr!("Permission denied"),
- 14 => cstr!("Bad address"),
- 15 => cstr!("Block device required"),
- 16 => cstr!("Device or resource busy"),
- 17 => cstr!("File exists"),
- 18 => cstr!("Invalid cross-device link"),
- 19 => cstr!("No such device"),
- 20 => cstr!("Not a directory"),
- 21 => cstr!("Is a directory"),
- 22 => cstr!("Invalid argument"),
- 23 => cstr!("Too many open files in system"),
- 24 => cstr!("Too many open files"),
- 25 => cstr!("Inappropriate ioctl for device"),
- 26 => cstr!("Text file busy"),
- 27 => cstr!("File too large"),
- 28 => cstr!("No space left on device"),
- 29 => cstr!("Illegal seek"),
- 30 => cstr!("Read-only file system"),
- 31 => cstr!("Too many links"),
- 32 => cstr!("Broken pipe"),
- 33 => cstr!("Numerical argument out of domain"),
- 34 => cstr!("Numerical result out of range"),
- 35 => cstr!("Resource deadlock avoided"),
- 36 => cstr!("File name too long"),
- 37 => cstr!("No locks available"),
- 38 => cstr!("Function not implemented"),
- 39 => cstr!("Directory not empty"),
- 40 => cstr!("Too many levels of symbolic links"),
- 42 => cstr!("No message of desired type"),
- 43 => cstr!("Identifier removed"),
- 44 => cstr!("Channel number out of range"),
- 45 => cstr!("Level 2 not synchronized"),
- 46 => cstr!("Level 3 halted"),
- 47 => cstr!("Level 3 reset"),
- 48 => cstr!("Link number out of range"),
- 49 => cstr!("Protocol driver not attached"),
- 50 => cstr!("No CSI structure available"),
- 51 => cstr!("Level 2 halted"),
- 52 => cstr!("Invalid exchange"),
- 53 => cstr!("Invalid request descriptor"),
- 54 => cstr!("Exchange full"),
- 55 => cstr!("No anode"),
- 56 => cstr!("Invalid request code"),
- 57 => cstr!("Invalid slot"),
- 59 => cstr!("Bad font file format"),
- 60 => cstr!("Device not a stream"),
- 61 => cstr!("No data available"),
- 62 => cstr!("Timer expired"),
- 63 => cstr!("Out of streams resources"),
- 64 => cstr!("Machine is not on the network"),
- 65 => cstr!("Package not installed"),
- 66 => cstr!("Object is remote"),
- 67 => cstr!("Link has been severed"),
- 68 => cstr!("Advertise error"),
- 69 => cstr!("Srmount error"),
- 70 => cstr!("Communication error on send"),
- 71 => cstr!("Protocol error"),
- 72 => cstr!("Multihop attempted"),
- 73 => cstr!("RFS specific error"),
- 74 => cstr!("Bad message"),
- 75 => cstr!("Value too large for defined data type"),
- 76 => cstr!("Name not unique on network"),
- 77 => cstr!("File descriptor in bad state"),
- 78 => cstr!("Remote address changed"),
- 79 => cstr!("Can not access a needed shared library"),
- 80 => cstr!("Accessing a corrupted shared library"),
- 81 => cstr!(".lib section in a.out corrupted"),
- 82 => cstr!("Attempting to link in too many shared libraries"),
- 83 => cstr!("Cannot exec a shared library directly"),
- 84 => cstr!("Invalid or incomplete multibyte or wide character"),
- 85 => cstr!("Interrupted system call should be restarted"),
- 86 => cstr!("Streams pipe error"),
- 87 => cstr!("Too many users"),
- 88 => cstr!("Socket operation on non-socket"),
- 89 => cstr!("Destination address required"),
- 90 => cstr!("Message too long"),
- 91 => cstr!("Protocol wrong type for socket"),
- 92 => cstr!("Protocol not available"),
- 93 => cstr!("Protocol not supported"),
- 94 => cstr!("Socket type not supported"),
- 95 => cstr!("Operation not supported"),
- 96 => cstr!("Protocol family not supported"),
- 97 => cstr!("Address family not supported by protocol"),
- 98 => cstr!("Address already in use"),
- 99 => cstr!("Cannot assign requested address"),
- 100 => cstr!("Network is down"),
- 101 => cstr!("Network is unreachable"),
- 102 => cstr!("Network dropped connection on reset"),
- 103 => cstr!("Software caused connection abort"),
- 104 => cstr!("Connection reset by peer"),
- 105 => cstr!("No buffer space available"),
- 106 => cstr!("Transport endpoint is already connected"),
- 107 => cstr!("Transport endpoint is not connected"),
- 108 => cstr!("Cannot send after transport endpoint shutdown"),
- 109 => cstr!("Too many references: cannot splice"),
- 110 => cstr!("Connection timed out"),
- 111 => cstr!("Connection refused"),
- 112 => cstr!("Host is down"),
- 113 => cstr!("No route to host"),
- 114 => cstr!("Operation already in progress"),
- 115 => cstr!("Operation now in progress"),
- 116 => cstr!("Stale file handle"),
- 117 => cstr!("Structure needs cleaning"),
- 118 => cstr!("Not a XENIX named type file"),
- 119 => cstr!("No XENIX semaphores available"),
- 120 => cstr!("Is a named type file"),
- 121 => cstr!("Remote I/O error"),
- 122 => cstr!("Disk quota exceeded"),
- 123 => cstr!("No medium found"),
- 124 => cstr!("Wrong medium type"),
- 125 => cstr!("Operation canceled"),
- 126 => cstr!("Required key not available"),
- 127 => cstr!("Key has expired"),
- 128 => cstr!("Key has been revoked"),
- 129 => cstr!("Key was rejected by service"),
- 130 => cstr!("Owner died"),
- 131 => cstr!("State not recoverable"),
- 132 => cstr!("Operation not possible due to RF-kill"),
- 133 => cstr!("Memory page has hardware error"),
- _ => cstr!("Unknown errno value"),
+ 0 => c"Success",
+ 1 => c"Operation not permitted",
+ 2 => c"No such file or directory",
+ 3 => c"No such process",
+ 4 => c"Interrupted system call",
+ 5 => c"Input/output error",
+ 6 => c"No such device or address",
+ 7 => c"Argument list too long",
+ 8 => c"Exec format error",
+ 9 => c"Bad file descriptor",
+ 10 => c"No child processes",
+ 11 => c"Resource temporarily unavailable",
+ 12 => c"Cannot allocate memory",
+ 13 => c"Permission denied",
+ 14 => c"Bad address",
+ 15 => c"Block device required",
+ 16 => c"Device or resource busy",
+ 17 => c"File exists",
+ 18 => c"Invalid cross-device link",
+ 19 => c"No such device",
+ 20 => c"Not a directory",
+ 21 => c"Is a directory",
+ 22 => c"Invalid argument",
+ 23 => c"Too many open files in system",
+ 24 => c"Too many open files",
+ 25 => c"Inappropriate ioctl for device",
+ 26 => c"Text file busy",
+ 27 => c"File too large",
+ 28 => c"No space left on device",
+ 29 => c"Illegal seek",
+ 30 => c"Read-only file system",
+ 31 => c"Too many links",
+ 32 => c"Broken pipe",
+ 33 => c"Numerical argument out of domain",
+ 34 => c"Numerical result out of range",
+ 35 => c"Resource deadlock avoided",
+ 36 => c"File name too long",
+ 37 => c"No locks available",
+ 38 => c"Function not implemented",
+ 39 => c"Directory not empty",
+ 40 => c"Too many levels of symbolic links",
+ 42 => c"No message of desired type",
+ 43 => c"Identifier removed",
+ 44 => c"Channel number out of range",
+ 45 => c"Level 2 not synchronized",
+ 46 => c"Level 3 halted",
+ 47 => c"Level 3 reset",
+ 48 => c"Link number out of range",
+ 49 => c"Protocol driver not attached",
+ 50 => c"No CSI structure available",
+ 51 => c"Level 2 halted",
+ 52 => c"Invalid exchange",
+ 53 => c"Invalid request descriptor",
+ 54 => c"Exchange full",
+ 55 => c"No anode",
+ 56 => c"Invalid request code",
+ 57 => c"Invalid slot",
+ 59 => c"Bad font file format",
+ 60 => c"Device not a stream",
+ 61 => c"No data available",
+ 62 => c"Timer expired",
+ 63 => c"Out of streams resources",
+ 64 => c"Machine is not on the network",
+ 65 => c"Package not installed",
+ 66 => c"Object is remote",
+ 67 => c"Link has been severed",
+ 68 => c"Advertise error",
+ 69 => c"Srmount error",
+ 70 => c"Communication error on send",
+ 71 => c"Protocol error",
+ 72 => c"Multihop attempted",
+ 73 => c"RFS specific error",
+ 74 => c"Bad message",
+ 75 => c"Value too large for defined data type",
+ 76 => c"Name not unique on network",
+ 77 => c"File descriptor in bad state",
+ 78 => c"Remote address changed",
+ 79 => c"Can not access a needed shared library",
+ 80 => c"Accessing a corrupted shared library",
+ 81 => c".lib section in a.out corrupted",
+ 82 => c"Attempting to link in too many shared libraries",
+ 83 => c"Cannot exec a shared library directly",
+ 84 => c"Invalid or incomplete multibyte or wide character",
+ 85 => c"Interrupted system call should be restarted",
+ 86 => c"Streams pipe error",
+ 87 => c"Too many users",
+ 88 => c"Socket operation on non-socket",
+ 89 => c"Destination address required",
+ 90 => c"Message too long",
+ 91 => c"Protocol wrong type for socket",
+ 92 => c"Protocol not available",
+ 93 => c"Protocol not supported",
+ 94 => c"Socket type not supported",
+ 95 => c"Operation not supported",
+ 96 => c"Protocol family not supported",
+ 97 => c"Address family not supported by protocol",
+ 98 => c"Address already in use",
+ 99 => c"Cannot assign requested address",
+ 100 => c"Network is down",
+ 101 => c"Network is unreachable",
+ 102 => c"Network dropped connection on reset",
+ 103 => c"Software caused connection abort",
+ 104 => c"Connection reset by peer",
+ 105 => c"No buffer space available",
+ 106 => c"Transport endpoint is already connected",
+ 107 => c"Transport endpoint is not connected",
+ 108 => c"Cannot send after transport endpoint shutdown",
+ 109 => c"Too many references: cannot splice",
+ 110 => c"Connection timed out",
+ 111 => c"Connection refused",
+ 112 => c"Host is down",
+ 113 => c"No route to host",
+ 114 => c"Operation already in progress",
+ 115 => c"Operation now in progress",
+ 116 => c"Stale file handle",
+ 117 => c"Structure needs cleaning",
+ 118 => c"Not a XENIX named type file",
+ 119 => c"No XENIX semaphores available",
+ 120 => c"Is a named type file",
+ 121 => c"Remote I/O error",
+ 122 => c"Disk quota exceeded",
+ 123 => c"No medium found",
+ 124 => c"Wrong medium type",
+ 125 => c"Operation canceled",
+ 126 => c"Required key not available",
+ 127 => c"Key has expired",
+ 128 => c"Key has been revoked",
+ 129 => c"Key was rejected by service",
+ 130 => c"Owner died",
+ 131 => c"State not recoverable",
+ 132 => c"Operation not possible due to RF-kill",
+ 133 => c"Memory page has hardware error",
+ _ => c"Unknown errno value",
}
}
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 }))