summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-08-19 13:47:27 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-26 23:41:52 +0000
commitc2444305a9e8e41f289fe916f0a3f1fbcf2456bf (patch)
treee1e74fd2ac1d0544364e14c76e81988dc3437412
parentd1245509b2a5f9494fd2dcf62876dc82ec8d00f9 (diff)
downloadcrosvm-c2444305a9e8e41f289fe916f0a3f1fbcf2456bf.tar
crosvm-c2444305a9e8e41f289fe916f0a3f1fbcf2456bf.tar.gz
crosvm-c2444305a9e8e41f289fe916f0a3f1fbcf2456bf.tar.bz2
crosvm-c2444305a9e8e41f289fe916f0a3f1fbcf2456bf.tar.lz
crosvm-c2444305a9e8e41f289fe916f0a3f1fbcf2456bf.tar.xz
crosvm-c2444305a9e8e41f289fe916f0a3f1fbcf2456bf.tar.zst
crosvm-c2444305a9e8e41f289fe916f0a3f1fbcf2456bf.zip
devices: vsock: replace byteorder with from_le_bytes()
BUG=None
TEST=cargo test -p devices vsock

Change-Id: I9da35f894898198413737f9caa29a7f772e4f720
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761153
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
-rw-r--r--devices/src/virtio/vhost/vsock.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/devices/src/virtio/vhost/vsock.rs b/devices/src/virtio/vhost/vsock.rs
index a61bce8..ad10cc1 100644
--- a/devices/src/virtio/vhost/vsock.rs
+++ b/devices/src/virtio/vhost/vsock.rs
@@ -194,7 +194,8 @@ impl VirtioDevice for Vsock {
 mod tests {
     use super::*;
 
-    use byteorder::{ByteOrder, LittleEndian};
+    use std::convert::TryInto;
+
     #[test]
     fn ack_features() {
         let cid = 5;
@@ -237,13 +238,19 @@ mod tests {
 
         let mut buf = [0 as u8; 8];
         vsock.read_config(0, &mut buf);
-        assert_eq!(cid, LittleEndian::read_u64(&buf));
+        assert_eq!(cid, u64::from_le_bytes(buf));
 
         vsock.read_config(0, &mut buf[..4]);
-        assert_eq!((cid & 0xffffffff) as u32, LittleEndian::read_u32(&buf[..4]));
+        assert_eq!(
+            (cid & 0xffffffff) as u32,
+            u32::from_le_bytes(buf[..4].try_into().unwrap())
+        );
 
         vsock.read_config(4, &mut buf[..4]);
-        assert_eq!((cid >> 32) as u32, LittleEndian::read_u32(&buf[..4]));
+        assert_eq!(
+            (cid >> 32) as u32,
+            u32::from_le_bytes(buf[..4].try_into().unwrap())
+        );
 
         let data: [u8; 8] = [8, 226, 5, 46, 159, 59, 89, 77];
         buf.copy_from_slice(&data);