From 1a9f2a5454481a511257625f985d503c45fd8246 Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Tue, 19 May 2020 19:40:20 +0900 Subject: sys_util: Refactor IntoIovec The original stated purpose of this trait was to reduce memory allocations but having the `into_iovec` method return a Vec kind of defeats that purpose. Refactor the trait so that it can either convert a T into an iovec or convert a &[T] into a &[iovec]. Implement the trait for VolatileSlice, IoSlice, and IoSliceMut and update all the callers. BUG=none TEST=unit tests Cq-Depend: chromium:2210272 Change-Id: I9d0d617a23030d241d50411f4a5a16e7cba4bcee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2208527 Reviewed-by: Daniel Verkamp Reviewed-by: Zach Reizner Commit-Queue: Chirantan Ekbote Tested-by: Chirantan Ekbote --- crosvm_plugin/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crosvm_plugin') diff --git a/crosvm_plugin/src/lib.rs b/crosvm_plugin/src/lib.rs index 05c19bf..e9d135c 100644 --- a/crosvm_plugin/src/lib.rs +++ b/crosvm_plugin/src/lib.rs @@ -17,7 +17,7 @@ use std::env; use std::fs::File; -use std::io::{Read, Write}; +use std::io::{IoSlice, Read, Write}; use std::mem::{size_of, swap}; use std::os::raw::{c_int, c_void}; use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; @@ -290,7 +290,7 @@ impl crosvm { .write_to_vec(&mut self.request_buffer) .map_err(proto_error_to_int)?; self.socket - .send_with_fds(self.request_buffer.as_slice(), fds) + .send_with_fds(&[IoSlice::new(self.request_buffer.as_slice())], fds) .map_err(|e| -e.errno())?; let mut datagram_fds = [0; MAX_DATAGRAM_FD]; -- cgit 1.4.1