From 8a56720b0f591ffc8307c98efb6f08459b49905b Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 19 Oct 2021 15:01:42 +0100 Subject: [PATCH] virtio-devices: Use assert!() rather than if+panic As identified by the new beta clippy. Signed-off-by: Rob Bradford --- virtio-devices/src/vsock/device.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/virtio-devices/src/vsock/device.rs b/virtio-devices/src/vsock/device.rs index ee90b3bf3..55e522897 100644 --- a/virtio-devices/src/vsock/device.rs +++ b/virtio-devices/src/vsock/device.rs @@ -684,9 +684,10 @@ mod tests { let mut epoll_helper = EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap(); - if !ctx.handler.handle_event(&mut epoll_helper, &event) { - panic!("handle_event() should have failed"); - } + assert!( + ctx.handler.handle_event(&mut epoll_helper, &event), + "handle_event() should have failed" + ); } } @@ -752,9 +753,10 @@ mod tests { let mut epoll_helper = EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap(); - if !ctx.handler.handle_event(&mut epoll_helper, &event) { - panic!("handle_event() should have failed"); - } + assert!( + ctx.handler.handle_event(&mut epoll_helper, &event), + "handle_event() should have failed" + ); } } @@ -771,9 +773,10 @@ mod tests { let mut epoll_helper = EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap(); - if !ctx.handler.handle_event(&mut epoll_helper, &event) { - panic!("handle_event() should have failed"); - } + assert!( + ctx.handler.handle_event(&mut epoll_helper, &event), + "handle_event() should have failed" + ); } } @@ -842,8 +845,9 @@ mod tests { let mut epoll_helper = EpollHelper::new(&ctx.handler.kill_evt, &ctx.handler.pause_evt).unwrap(); - if !ctx.handler.handle_event(&mut epoll_helper, &event) { - panic!("handle_event() should have failed"); - } + assert!( + ctx.handler.handle_event(&mut epoll_helper, &event), + "handle_event() should have failed" + ); } }