rust: introduce a c_str macro

This allows CStr constants to be defined easily on Rust 1.63.0, while
checking that there are no embedded NULs.  c"" literals were only
stabilized in Rust 1.77.0.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2024-10-25 08:23:53 +02:00
parent 9f7d4520d6
commit 718e255f0a
8 changed files with 78 additions and 19 deletions

View file

@ -15,7 +15,7 @@
macro_rules! vmstate_unused_buffer {
($field_exists_fn:expr, $version_id:expr, $size:expr) => {{
$crate::bindings::VMStateField {
name: c"unused".as_ptr(),
name: c_str!("unused").as_ptr(),
err_hint: ::core::ptr::null(),
offset: 0,
size: $size,