summary refs log tree commit diff
path: root/src/plugin
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2019-07-23 15:55:03 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-24 06:07:20 +0000
commitb2110bef59d72529d99c722df9b3e9a1d705e6f4 (patch)
treee69899bce04e4ade12a33121b84517ee886216f2 /src/plugin
parent229063c2bf2ee365458c8fd5cdda2ab27a23bf98 (diff)
downloadcrosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar
crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.gz
crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.bz2
crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.lz
crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.xz
crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.zst
crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.zip
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 <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'src/plugin')
-rw-r--r--src/plugin/mod.rs10
1 files changed, 3 insertions, 7 deletions
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;