Skip to content

Commit 7b05673

Browse files
mhartmayhoeppnerj
authored andcommitted
rust/pv: some cargo clippy fixes
Found and fixed by the command `cargo clippy --fix -- -Dwarnings`. Reviewed-by: Jan Höppner <[email protected]> Signed-off-by: Marc Hartmayer <[email protected]> Signed-off-by: Jan Höppner <[email protected]>
1 parent 33fde99 commit 7b05673

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

rust/pv/src/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,15 @@ mod tests {
527527
fn parse_hex() {
528528
let s = "123456acbef0";
529529
let exp = vec![0x12, 0x34, 0x56, 0xac, 0xbe, 0xf0];
530-
assert_eq!(super::parse_hex(&s), exp);
530+
assert_eq!(super::parse_hex(s), exp);
531531

532532
let s = "00123456acbef0";
533533
let exp = vec![0, 0x12, 0x34, 0x56, 0xac, 0xbe, 0xf0];
534-
assert_eq!(super::parse_hex(&s), exp);
534+
assert_eq!(super::parse_hex(s), exp);
535535

536536
let s = "00123456acbef0ii90";
537537
let exp = vec![0, 0x12, 0x34, 0x56, 0xac, 0xbe, 0xf0];
538-
assert_eq!(super::parse_hex(&s), exp);
538+
assert_eq!(super::parse_hex(s), exp);
539539
}
540540

541541
#[test]
@@ -653,6 +653,6 @@ mod tests {
653653
assert!(super::memeq(&a, &a.clone()));
654654
assert!(!super::memeq(&b, &a));
655655
assert!(!super::memeq(&b, &c));
656-
assert!(!super::memeq(&b, &vec![]));
656+
assert!(!super::memeq(&b, &[]));
657657
}
658658
}

rust/pv/src/uvdevice/test.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ impl IoctlCtx {
6161

6262
pub mod mock_libc {
6363
use super::*;
64-
use std::mem::transmute;
6564

6665
pub unsafe fn ioctl(
6766
fd: ::libc::c_int,
@@ -75,7 +74,7 @@ pub mod mock_libc {
7574
assert_eq!(cmd, ctx.exp_cmd, "IOCTL cmd mismatch");
7675
assert_eq!(fd, 17, "IOCTL fd mismatch");
7776

78-
let data_ref: &mut ffi::uvio_ioctl_cb = transmute(data);
77+
let data_ref: &mut ffi::uvio_ioctl_cb = &mut *data;
7978

8079
(ctx.modify)(data_ref)
8180
}
@@ -194,11 +193,7 @@ fn ioctl_write_data() {
194193
get_lock(&IOCTL_MTX).exp_cmd(TEST_CMD).set_mdfy(move |cb| {
195194
cb.set_rc(1).addr_eq(data_addr).size_eq(32);
196195
unsafe {
197-
::libc::memset(
198-
(*cb).argument_addr as *mut ::libc::c_void,
199-
0x42,
200-
cmd_data_len,
201-
);
196+
::libc::memset(cb.argument_addr as *mut ::libc::c_void, 0x42, cmd_data_len);
202197
}
203198
0
204199
});
@@ -223,7 +218,7 @@ fn ioctl_read_data() {
223218
get_lock(&IOCTL_MTX).exp_cmd(TEST_CMD).set_mdfy(move |cb| {
224219
cb.set_rc(1).addr_eq(data_addr).size_eq(32);
225220
unsafe {
226-
let data = std::slice::from_raw_parts((*cb).argument_addr as *const u8, cmd_data_len);
221+
let data = std::slice::from_raw_parts(cb.argument_addr as *const u8, cmd_data_len);
227222
assert_eq!(data, data_exp);
228223
}
229224
0

0 commit comments

Comments
 (0)