Message ID | 20241108180139.117112-8-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | rust: improved integration with cargo | expand |
Paolo Bonzini <pbonzini@redhat.com> writes: > These are reported as clippy::semicolon_inside_block and clippy::as_ptr_cast_mut. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> One minor question below. > --- > rust/hw/char/pl011/src/device.rs | 6 ++++-- > rust/hw/char/pl011/src/memory_ops.rs | 4 +++- > rust/qemu-api/tests/tests.rs | 2 +- > 3 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs > index 2a85960b81f..7f40e7f71fa 100644 > --- a/rust/hw/char/pl011/src/device.rs > +++ b/rust/hw/char/pl011/src/device.rs > @@ -499,7 +499,9 @@ pub fn update(&self) { > let flags = self.int_level & self.int_enabled; > for (irq, i) in self.interrupts.iter().zip(IRQMASK) { > // SAFETY: self.interrupts have been initialized in init(). > - unsafe { qemu_set_irq(*irq, i32::from(flags & i != 0)) }; > + unsafe { > + qemu_set_irq(*irq, i32::from(flags & i != 0)); > + } clippy::semicolon_inside_block can be configured not to lint single-line blocks [1]. I don't have any preference among different styles. Just want to ask how others think. [1] https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_inside_block -- Best Regards Junjie Mao
diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs index 2a85960b81f..7f40e7f71fa 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -499,7 +499,9 @@ pub fn update(&self) { let flags = self.int_level & self.int_enabled; for (irq, i) in self.interrupts.iter().zip(IRQMASK) { // SAFETY: self.interrupts have been initialized in init(). - unsafe { qemu_set_irq(*irq, i32::from(flags & i != 0)) }; + unsafe { + qemu_set_irq(*irq, i32::from(flags & i != 0)); + } } } @@ -601,7 +603,7 @@ pub fn post_load(&mut self, _version_id: u32) -> Result<(), ()> { let sysbus: *mut SysBusDevice = dev.cast::<SysBusDevice>(); qdev_prop_set_chr(dev, c_str!("chardev").as_ptr(), chr); - sysbus_realize_and_unref(sysbus, addr_of!(error_fatal) as *mut *mut Error); + sysbus_realize_and_unref(sysbus, addr_of!(error_fatal).cast_mut()); sysbus_mmio_map(sysbus, 0, addr); sysbus_connect_irq(sysbus, 0, irq); dev diff --git a/rust/hw/char/pl011/src/memory_ops.rs b/rust/hw/char/pl011/src/memory_ops.rs index 169d485a4d2..c4e8599ba43 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -33,7 +33,9 @@ // SAFETY: self.char_backend is a valid CharBackend instance after it's been // initialized in realize(). let cb_ptr = unsafe { core::ptr::addr_of_mut!(state.as_mut().char_backend) }; - unsafe { qemu_chr_fe_accept_input(cb_ptr) }; + unsafe { + qemu_chr_fe_accept_input(cb_ptr); + } val } diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 43a4827de12..925f5a3c77b 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -74,6 +74,6 @@ impl Class for DummyClass { unsafe { module_call_init(module_init_type::MODULE_INIT_QOM); - object_unref(object_new(DummyState::TYPE_NAME.as_ptr()) as *mut _); + object_unref(object_new(DummyState::TYPE_NAME.as_ptr()).cast()); } }
These are reported as clippy::semicolon_inside_block and clippy::as_ptr_cast_mut. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- rust/hw/char/pl011/src/device.rs | 6 ++++-- rust/hw/char/pl011/src/memory_ops.rs | 4 +++- rust/qemu-api/tests/tests.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-)