rust/pv: some cargo clippy fixes

Found and fixed by the command `cargo clippy --fix -- -Dwarnings`.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2023-08-04 11:25:02 +00:00
committed by Jan Höppner
parent 33fde99138
commit 7b056735ed
2 changed files with 7 additions and 12 deletions

View File

@@ -527,15 +527,15 @@ mod tests {
fn parse_hex() {
let s = "123456acbef0";
let exp = vec![0x12, 0x34, 0x56, 0xac, 0xbe, 0xf0];
assert_eq!(super::parse_hex(&s), exp);
assert_eq!(super::parse_hex(s), exp);
let s = "00123456acbef0";
let exp = vec![0, 0x12, 0x34, 0x56, 0xac, 0xbe, 0xf0];
assert_eq!(super::parse_hex(&s), exp);
assert_eq!(super::parse_hex(s), exp);
let s = "00123456acbef0ii90";
let exp = vec![0, 0x12, 0x34, 0x56, 0xac, 0xbe, 0xf0];
assert_eq!(super::parse_hex(&s), exp);
assert_eq!(super::parse_hex(s), exp);
}
#[test]
@@ -653,6 +653,6 @@ mod tests {
assert!(super::memeq(&a, &a.clone()));
assert!(!super::memeq(&b, &a));
assert!(!super::memeq(&b, &c));
assert!(!super::memeq(&b, &vec![]));
assert!(!super::memeq(&b, &[]));
}
}

View File

@@ -61,7 +61,6 @@ impl IoctlCtx {
pub mod mock_libc {
use super::*;
use std::mem::transmute;
pub unsafe fn ioctl(
fd: ::libc::c_int,
@@ -75,7 +74,7 @@ pub mod mock_libc {
assert_eq!(cmd, ctx.exp_cmd, "IOCTL cmd mismatch");
assert_eq!(fd, 17, "IOCTL fd mismatch");
let data_ref: &mut ffi::uvio_ioctl_cb = transmute(data);
let data_ref: &mut ffi::uvio_ioctl_cb = &mut *data;
(ctx.modify)(data_ref)
}
@@ -194,11 +193,7 @@ fn ioctl_write_data() {
get_lock(&IOCTL_MTX).exp_cmd(TEST_CMD).set_mdfy(move |cb| {
cb.set_rc(1).addr_eq(data_addr).size_eq(32);
unsafe {
::libc::memset(
(*cb).argument_addr as *mut ::libc::c_void,
0x42,
cmd_data_len,
);
::libc::memset(cb.argument_addr as *mut ::libc::c_void, 0x42, cmd_data_len);
}
0
});
@@ -223,7 +218,7 @@ fn ioctl_read_data() {
get_lock(&IOCTL_MTX).exp_cmd(TEST_CMD).set_mdfy(move |cb| {
cb.set_rc(1).addr_eq(data_addr).size_eq(32);
unsafe {
let data = std::slice::from_raw_parts((*cb).argument_addr as *const u8, cmd_data_len);
let data = std::slice::from_raw_parts(cb.argument_addr as *const u8, cmd_data_len);
assert_eq!(data, data_exp);
}
0