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>
diff --git a/src/linux.rs b/src/linux.rs
index 8d4a4ae..58a0e10 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -1432,16 +1432,15 @@
.set_raw_mode()
.expect("failed to set terminal raw mode");
- let poll_ctx = PollContext::new().map_err(Error::CreatePollContext)?;
- poll_ctx
- .add(&linux.exit_evt, Token::Exit)
- .map_err(Error::PollContextAdd)?;
+ let poll_ctx = PollContext::build_with(&[
+ (&linux.exit_evt, Token::Exit),
+ (&sigchld_fd, Token::ChildSignal),
+ ])
+ .map_err(Error::PollContextAdd)?;
+
if let Err(e) = poll_ctx.add(&stdin_handle, Token::Stdin) {
warn!("failed to add stdin to poll context: {}", e);
}
- poll_ctx
- .add(&sigchld_fd, Token::ChildSignal)
- .map_err(Error::PollContextAdd)?;
if let Some(socket_server) = &control_server_socket {
poll_ctx