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/android/virtmgr/src/aidl.rs b/android/virtmgr/src/aidl.rs
index c71b5c5..5ad7ee1 100644
--- a/android/virtmgr/src/aidl.rs
+++ b/android/virtmgr/src/aidl.rs
@@ -68,7 +68,6 @@
self, wait_for_interface, Accessor, BinderFeatures, ConnectionInfo, ExceptionCode, Interface, ParcelFileDescriptor,
SpIBinder, Status, StatusCode, Strong, IntoBinderResult,
};
-use cstr::cstr;
use glob::glob;
use libc::{AF_VSOCK, sa_family_t, sockaddr_vm};
use log::{debug, error, info, warn};
@@ -976,7 +975,7 @@
"Passing vendor hashtree digest to pvmfw. This will be rejected if it doesn't \
match the trusted digest in the pvmfw config, causing the VM to fail to start."
);
- vec![(cstr!("vendor_hashtree_descriptor_root_digest"), vendor_hashtree_digest.as_slice())]
+ vec![(c"vendor_hashtree_descriptor_root_digest", vendor_hashtree_digest.as_slice())]
} else {
vec![]
};
@@ -984,18 +983,18 @@
let key_material;
let mut untrusted_props = Vec::with_capacity(2);
if cfg!(llpvm_changes) {
- untrusted_props.push((cstr!("instance-id"), &instance_id[..]));
+ untrusted_props.push((c"instance-id", &instance_id[..]));
let want_updatable = extract_want_updatable(config);
if want_updatable && is_secretkeeper_supported() {
// Let guest know that it can defer rollback protection to Secretkeeper by setting
// an empty property in untrusted node in DT. This enables Updatable VMs.
- untrusted_props.push((cstr!("defer-rollback-protection"), &[]));
+ untrusted_props.push((c"defer-rollback-protection", &[]));
let sk: Strong<dyn ISecretkeeper> =
binder::wait_for_interface(SECRETKEEPER_IDENTIFIER)?;
if sk.getInterfaceVersion()? >= 2 {
let PublicKey { keyMaterial } = sk.getSecretkeeperIdentity()?;
key_material = keyMaterial;
- trusted_props.push((cstr!("secretkeeper_public_key"), key_material.as_slice()));
+ trusted_props.push((c"secretkeeper_public_key", key_material.as_slice()));
}
}
}