[PATCH nbdkit] rust: Drop box ptr
This isn't a complete fix. There's still this error when running the tests. I don't understand which expect function it's complaining about. One generated by the MockServer? ---------------------------------------------------------------------- warning: the cargo feature `resolver` has been stabilized in the 1.51 release and is no longer necessary to be listed in the manifest See https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions for more information about using this feature. Compiling nbdkit v0.2.0 (/home/rjones/d/nbdkit/plugins/rust) error: associated function `expect` is never used --> tests/common/mod.rs:49:1 | 49 | / mock!{ 50 | | pub Server {} 51 | | impl Server for Server { 52 | | fn cache(&self, count: u32, offset: u64) -> Result<()>; ... | 86 | | } 87 | | } | |_^ | = note: `-D dead-code` implied by `-D warnings` error: could not compile `nbdkit` due to previous error warning: build failed, waiting for other jobs to finish... error: could not compile `nbdkit` due to previous error FAIL test.sh (exit status: 101) ---------------------------------------------------------------------- Rich.
Because of this recent change to rust, our close function warned that we calculate Box::from_raw but never use it. I added the suggested call to drop() around the function. https://github.com/rust-lang/rust/pull/99270 --- plugins/rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/rust/src/lib.rs b/plugins/rust/src/lib.rs index 69be36fb2..128334ef2 100644 --- a/plugins/rust/src/lib.rs +++ b/plugins/rust/src/lib.rs @@ -368,7 +368,7 @@ mod ffi { pub(super) extern fn close(selfp: *mut c_void) { unsafe { - Box::from_raw(selfp as *mut Box<dyn Server>); + drop(Box::from_raw(selfp as *mut Box<dyn Server>)); } } -- 2.37.0.rc2
This change is correct. You can consider it reviewed by me and commit it. As for the warning from Mockall, that's a bug in Mockall. I'll fix it. On Thu, Sep 29, 2022 at 8:21 AM Richard W.M. Jones <rjones@redhat.com> wrote:
Because of this recent change to rust, our close function warned that we calculate Box::from_raw but never use it. I added the suggested call to drop() around the function.
https://github.com/rust-lang/rust/pull/99270 --- plugins/rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/rust/src/lib.rs b/plugins/rust/src/lib.rs index 69be36fb2..128334ef2 100644 --- a/plugins/rust/src/lib.rs +++ b/plugins/rust/src/lib.rs @@ -368,7 +368,7 @@ mod ffi {
pub(super) extern fn close(selfp: *mut c_void) { unsafe { - Box::from_raw(selfp as *mut Box<dyn Server>); + drop(Box::from_raw(selfp as *mut Box<dyn Server>)); } }
-- 2.37.0.rc2
Here's the bug https://github.com/asomers/mockall/issues/414 On Thu, Sep 29, 2022 at 9:56 AM alan somers <asomers@gmail.com> wrote:
This change is correct. You can consider it reviewed by me and commit it. As for the warning from Mockall, that's a bug in Mockall. I'll fix it.
On Thu, Sep 29, 2022 at 8:21 AM Richard W.M. Jones <rjones@redhat.com> wrote:
Because of this recent change to rust, our close function warned that we calculate Box::from_raw but never use it. I added the suggested call to drop() around the function.
https://github.com/rust-lang/rust/pull/99270 --- plugins/rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/rust/src/lib.rs b/plugins/rust/src/lib.rs index 69be36fb2..128334ef2 100644 --- a/plugins/rust/src/lib.rs +++ b/plugins/rust/src/lib.rs @@ -368,7 +368,7 @@ mod ffi {
pub(super) extern fn close(selfp: *mut c_void) { unsafe { - Box::from_raw(selfp as *mut Box<dyn Server>); + drop(Box::from_raw(selfp as *mut Box<dyn Server>)); } }
-- 2.37.0.rc2
On Thu, Sep 29, 2022 at 09:56:34AM -0600, alan somers wrote:
This change is correct. You can consider it reviewed by me and commit it. As for the warning from Mockall, that's a bug in Mockall. I'll fix it.
Thanks Alan - the drop() addition pushed as 6836e4c36. Rich.
On Thu, Sep 29, 2022 at 8:21 AM Richard W.M. Jones <rjones@redhat.com> wrote:
Because of this recent change to rust, our close function warned that we calculate Box::from_raw but never use it. I added the suggested call to drop() around the function.
https://github.com/rust-lang/rust/pull/99270 --- plugins/rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/rust/src/lib.rs b/plugins/rust/src/lib.rs index 69be36fb2..128334ef2 100644 --- a/plugins/rust/src/lib.rs +++ b/plugins/rust/src/lib.rs @@ -368,7 +368,7 @@ mod ffi {
pub(super) extern fn close(selfp: *mut c_void) { unsafe { - Box::from_raw(selfp as *mut Box<dyn Server>); + drop(Box::from_raw(selfp as *mut Box<dyn Server>)); } }
-- 2.37.0.rc2
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
participants (2)
-
alan somers -
Richard W.M. Jones