From d6976ef66b9a772552c1b5b7c7059703a3a43a89 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 10 Sep 2024 14:46:04 -0700 Subject: [PATCH] Fix byte_char_slices clippy warnings BUG=b:365852007 Change-Id: I18bfdcc077cc871ea98e9d6deed5514a6e7d2aa5 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5852613 Reviewed-by: Chih-Yang Hsia Commit-Queue: Daniel Verkamp --- base/tests/syslog.rs | 2 +- devices/src/debugcon.rs | 8 ++++---- devices/src/serial.rs | 36 ++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/base/tests/syslog.rs b/base/tests/syslog.rs index e538bd2017..45fac262ef 100644 --- a/base/tests/syslog.rs +++ b/base/tests/syslog.rs @@ -109,7 +109,7 @@ fn syslogger_char() { } syslogger - .write_all(&[b'\n']) + .write_all(b"\n") .expect("error writing newline char"); std::mem::drop(syslogger); diff --git a/devices/src/debugcon.rs b/devices/src/debugcon.rs index a56e43e41e..dfc3b7a4d1 100644 --- a/devices/src/debugcon.rs +++ b/devices/src/debugcon.rs @@ -165,10 +165,10 @@ mod tests { Vec::new(), ); - debugcon.write(ADDR, &[b'a']); - debugcon.write(ADDR, &[b'b']); - debugcon.write(ADDR, &[b'c']); - assert_eq!(debugcon_out.buf.lock().as_slice(), [b'a', b'b', b'c']); + debugcon.write(ADDR, b"a"); + debugcon.write(ADDR, b"b"); + debugcon.write(ADDR, b"c"); + assert_eq!(debugcon_out.buf.lock().as_slice(), b"abc"); } #[test] diff --git a/devices/src/serial.rs b/devices/src/serial.rs index c1c3ea1cd9..2b4bf475f4 100644 --- a/devices/src/serial.rs +++ b/devices/src/serial.rs @@ -679,10 +679,10 @@ mod tests { Vec::new(), ); - serial.write(serial_bus_address(DATA), &[b'a']); - serial.write(serial_bus_address(DATA), &[b'b']); - serial.write(serial_bus_address(DATA), &[b'c']); - assert_eq!(serial_out.buf.lock().as_slice(), &[b'a', b'b', b'c']); + serial.write(serial_bus_address(DATA), b"a"); + serial.write(serial_bus_address(DATA), b"b"); + serial.write(serial_bus_address(DATA), b"c"); + assert_eq!(serial_out.buf.lock().as_slice(), b"abc"); } #[test] @@ -701,7 +701,7 @@ mod tests { ); serial.write(serial_bus_address(IER), &[IER_RECV_BIT]); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); assert_eq!(intr_evt.wait(), Ok(())); let mut data = [0u8; 1]; @@ -729,7 +729,7 @@ mod tests { ); serial.write(serial_bus_address(IER), &[IER_RECV_BIT]); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); assert_eq!(intr_evt.wait(), Ok(())); let mut data = [0u8; 1]; @@ -778,7 +778,7 @@ mod tests { ); serial.write(serial_bus_address(IER), &[IER_RECV_BIT]); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); assert_eq!(intr_evt.wait(), Ok(())); let mut data = [0u8; 1]; @@ -817,7 +817,7 @@ mod tests { ); serial.write(serial_bus_address(IER), &[IER_RECV_BIT]); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); assert_eq!(intr_evt.wait(), Ok(())); let mut data = [0u8; 1]; @@ -826,7 +826,7 @@ mod tests { // Take snapshot after reading b'a'. Serial still contains b'b' and b'c'. let snap = serial.snapshot().expect("failed to snapshot serial"); serial.clear_in_buffer(); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); serial.read(serial_bus_address(DATA), &mut data[..]); assert_eq!(data[0], b'a'); serial.read(serial_bus_address(DATA), &mut data[..]); @@ -864,7 +864,7 @@ mod tests { ); serial.write(serial_bus_address(IER), &[IER_RECV_BIT]); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); assert_eq!(intr_evt.wait(), Ok(())); let mut data = [0u8; 1]; @@ -924,7 +924,7 @@ mod tests { ); serial.write(serial_bus_address(IER), &[IER_RECV_BIT]); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); assert_eq!(intr_evt.wait(), Ok(())); let mut data = [0u8; 1]; @@ -948,7 +948,7 @@ mod tests { fn modify_device(serial: &mut Serial) { serial.clear_in_buffer(); - serial.queue_input_bytes(&[b'a', b'b', b'c']).unwrap(); + serial.queue_input_bytes(b"abc").unwrap(); } suspendable_tests!( @@ -999,18 +999,18 @@ mod tests { Vec::new(), ); - serial.write(serial_bus_address(DATA), &[b'a']); - serial.write(serial_bus_address(DATA), &[b'\n']); + serial.write(serial_bus_address(DATA), b"a"); + serial.write(serial_bus_address(DATA), b"\n"); assert_timestamp_is_present(serial_out.buf.lock().as_slice(), "a"); serial_out.buf.lock().clear(); - serial.write(serial_bus_address(DATA), &[b'b']); - serial.write(serial_bus_address(DATA), &[b'\n']); + serial.write(serial_bus_address(DATA), b"b"); + serial.write(serial_bus_address(DATA), b"\n"); assert_timestamp_is_present(serial_out.buf.lock().as_slice(), "b"); serial_out.buf.lock().clear(); - serial.write(serial_bus_address(DATA), &[b'c']); - serial.write(serial_bus_address(DATA), &[b'\n']); + serial.write(serial_bus_address(DATA), b"c"); + serial.write(serial_bus_address(DATA), b"\n"); assert_timestamp_is_present(serial_out.buf.lock().as_slice(), "c"); serial_out.buf.lock().clear(); }