Message ID | 20241021163538.136941-5-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | rust: miscellaneous cleanups + QOM integration tests | expand |
Paolo Bonzini <pbonzini@redhat.com> writes: > This not necessary and makes it harder to write code that This *is* not ... > is portable between 32- and 64-bit systems: it adds extra casts even > though size_of, align_of or offset_of already return the right type. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> -- Best Regards Junjie Mao
On Mon, Oct 21, 2024 at 06:35:29PM +0200, Paolo Bonzini wrote: > Date: Mon, 21 Oct 2024 18:35:29 +0200 > From: Paolo Bonzini <pbonzini@redhat.com> > Subject: [PATCH v2 04/13] rust: do not use --no-size_t-is-usize > X-Mailer: git-send-email 2.46.2 > > This not necessary and makes it harder to write code that > is portable between 32- and 64-bit systems: it adds extra casts even > though size_of, align_of or offset_of already return the right type. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > meson.build | 1 - > rust/qemu-api/src/definitions.rs | 6 +++--- > 2 files changed, 3 insertions(+), 4 deletions(-) Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
diff --git a/meson.build b/meson.build index 63c07a5b660..6739165908e 100644 --- a/meson.build +++ b/meson.build @@ -3934,7 +3934,6 @@ if have_rust and have_system '--no-doc-comments', '--use-core', '--with-derive-default', - '--no-size_t-is-usize', '--no-layout-tests', '--no-prepend-enum-name', '--allowlist-file', meson.project_source_root() + '/include/.*', diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitions.rs index 60bd3f8aaa6..0b681c593f2 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -81,13 +81,13 @@ macro_rules! type_info { } else { ::core::ptr::null_mut() }, - instance_size: ::core::mem::size_of::<$t>() as $crate::bindings::size_t, - instance_align: ::core::mem::align_of::<$t>() as $crate::bindings::size_t, + instance_size: ::core::mem::size_of::<$t>(), + instance_align: ::core::mem::align_of::<$t>(), instance_init: <$t as $crate::definitions::ObjectImpl>::INSTANCE_INIT, instance_post_init: <$t as $crate::definitions::ObjectImpl>::INSTANCE_POST_INIT, instance_finalize: <$t as $crate::definitions::ObjectImpl>::INSTANCE_FINALIZE, abstract_: <$t as $crate::definitions::ObjectImpl>::ABSTRACT, - class_size: ::core::mem::size_of::<<$t as $crate::definitions::ObjectImpl>::Class>() as $crate::bindings::size_t, + class_size: ::core::mem::size_of::<<$t as $crate::definitions::ObjectImpl>::Class>(), class_init: <<$t as $crate::definitions::ObjectImpl>::Class as $crate::definitions::Class>::CLASS_INIT, class_base_init: <<$t as $crate::definitions::ObjectImpl>::Class as $crate::definitions::Class>::CLASS_BASE_INIT, class_data: ::core::ptr::null_mut(),
This not necessary and makes it harder to write code that is portable between 32- and 64-bit systems: it adds extra casts even though size_of, align_of or offset_of already return the right type. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- meson.build | 1 - rust/qemu-api/src/definitions.rs | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-)