From b2110bef59d72529d99c722df9b3e9a1d705e6f4 Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Tue, 23 Jul 2019 15:55:03 -0700 Subject: tree-wide: use PollContext::build_with where possible The old method of creating a PollContext and calling `add` inside of `and_then` chains was an ugly way handle the Results that can crop up after each call. The `build_with` function is equivalent but operates on a slice which has way less boilerplate. TEST=./build_test BUG=None Change-Id: I8b0d6532680e04c501187397bd211014a2363c25 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1715581 Tested-by: Zach Reizner Tested-by: kokoro Auto-Submit: Zach Reizner Reviewed-by: Daniel Verkamp Commit-Queue: Zach Reizner --- src/plugin/mod.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/plugin/mod.rs') diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index cf8332a..3b6d82b 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -624,13 +624,9 @@ pub fn run_config(cfg: Config) -> Result<()> { let kill_signaled = Arc::new(AtomicBool::new(false)); let mut vcpu_handles = Vec::with_capacity(vcpu_count as usize); - let poll_ctx = PollContext::new().map_err(Error::CreatePollContext)?; - poll_ctx - .add(&exit_evt, Token::Exit) - .map_err(Error::PollContextAdd)?; - poll_ctx - .add(&sigchld_fd, Token::ChildSignal) - .map_err(Error::PollContextAdd)?; + let poll_ctx = + PollContext::build_with(&[(&exit_evt, Token::Exit), (&sigchld_fd, Token::ChildSignal)]) + .map_err(Error::PollContextAdd)?; let mut sockets_to_drop = Vec::new(); let mut redo_poll_ctx_sockets = true; -- cgit 1.4.1