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 --- src/plugin/process.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugin') diff --git a/src/plugin/process.rs b/src/plugin/process.rs index 783239a..688aa85 100644 --- a/src/plugin/process.rs +++ b/src/plugin/process.rs @@ -5,7 +5,7 @@ use std::collections::hash_map::{Entry, HashMap, VacantEntry}; use std::env::set_var; use std::fs::File; -use std::io::Write; +use std::io::{IoSlice, Write}; use std::mem::transmute; use std::os::unix::io::{IntoRawFd, RawFd}; use std::os::unix::net::UnixDatagram; @@ -730,7 +730,7 @@ impl Process { .map_err(Error::EncodeResponse)?; assert_ne!(self.response_buffer.len(), 0); self.request_sockets[index] - .send_with_fds(&self.response_buffer[..], &response_fds) + .send_with_fds(&[IoSlice::new(&self.response_buffer[..])], &response_fds) .map_err(Error::PluginSocketSend)?; Ok(()) -- cgit 1.4.1