[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 17/24] rust/qemu-api: Use device_class_set_props_n
From: |
Richard Henderson |
Subject: |
[PATCH 17/24] rust/qemu-api: Use device_class_set_props_n |
Date: |
Sun, 15 Dec 2024 21:51:02 -0600 |
This means we can update declare_properties to drop the
zero terminator at the end of the array as well.
Cc: qemu-rust@nongnu.org
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
rust/qemu-api/src/device_class.rs | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/rust/qemu-api/src/device_class.rs
b/rust/qemu-api/src/device_class.rs
index 03d03feee8..cca51fe1a9 100644
--- a/rust/qemu-api/src/device_class.rs
+++ b/rust/qemu-api/src/device_class.rs
@@ -7,7 +7,6 @@
use crate::{
bindings::{self, DeviceClass, DeviceState, Error, ObjectClass, Property,
VMStateDescription},
prelude::*,
- zeroable::Zeroable,
};
/// Trait providing the contents of [`DeviceClass`].
@@ -31,7 +30,7 @@ pub trait DeviceImpl {
/// device. Not a `const` because referencing statics in constants
/// is unstable until Rust 1.83.0.
fn properties() -> &'static [Property] {
- &[Zeroable::ZERO; 1]
+ &[]
}
/// A `VMStateDescription` providing the migration format for the device
@@ -87,7 +86,10 @@ fn vmsd() -> Option<&'static VMStateDescription> {
if let Some(vmsd) = <T as DeviceImpl>::vmsd() {
dc.vmsd = vmsd;
}
- bindings::device_class_set_props(dc, <T as
DeviceImpl>::properties().as_ptr());
+ let prop = <T as DeviceImpl>::properties();
+ if prop.len() != 0 {
+ bindings::device_class_set_props_n(dc, prop.as_ptr(), prop.len());
+ }
}
}
@@ -134,7 +136,7 @@ macro_rules! define_property {
macro_rules! declare_properties {
($ident:ident, $($prop:expr),*$(,)*) => {
pub static $ident: [$crate::bindings::Property; {
- let mut len = 1;
+ let mut len = 0;
$({
_ = stringify!($prop);
len += 1;
@@ -142,7 +144,6 @@ macro_rules! declare_properties {
len
}] = [
$($prop),*,
- $crate::zeroable::Zeroable::ZERO,
];
};
}
--
2.43.0
- Re: [PATCH 06/24] hw/ppc: Only register spapr_nvdimm_properties if CONFIG_LIBPMEM, (continued)
- [PATCH 10/24] hw/sparc: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 08/24] hw/s390x: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 09/24] hw/xen: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 12/24] include/hw/qdev-core: Detect most empty Property lists at compile time, Richard Henderson, 2024/12/15
- [PATCH 13/24] hw/core: Introduce device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 11/24] hw/virtio: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 15/24] hw/scsi/megasas: Use device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 16/24] hw/arm/armsse: Use device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 17/24] rust/qemu-api: Use device_class_set_props_n,
Richard Henderson <=
- [PATCH 14/24] migration: Use device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 19/24] target/riscv: Do not abuse DEFINE_PROP_END_OF_LIST, Richard Henderson, 2024/12/15
- [PATCH 18/24] hw/core: Replace device_class_set_props with a macro, Richard Henderson, 2024/12/15
- [PATCH 21/24] include/hw/qdev-properties: Shrink struct Property, Richard Henderson, 2024/12/15
- [PATCH 20/24] include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST, Richard Henderson, 2024/12/15
- [PATCH 22/24] hw/core/qdev-properties: Constify Property argument to object_field_prop_ptr, Richard Henderson, 2024/12/15
- [PATCH 23/24] hw/core/qdev-properties: Constify Property argument to PropertyInfo.print, Richard Henderson, 2024/12/15
- [PATCH 24/24] Constify all opaque Property pointers, Richard Henderson, 2024/12/15
- Re: [PATCH 00/24] More Property cleanups, Paolo Bonzini, 2024/12/18