Edward O'Callaghan has uploaded this change for review.

View Change

CHROMIUM: flashrom_tester: Drop nix dependency

We can just use the libc functions directly. This is exactly what nix
does anyway.

BUG=none
TEST=unit tests
BRANCH=none

Original-Change-Id: I45c02f0c71d164bd8f504fe2b8d3acd54e0d5704
Original-Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2560393
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Allen Webb <allenwebb@google.com>
Original-Commit-Queue: Allen Webb <allenwebb@google.com>

Change-Id: If7d1c7c7b5663a32c0a338866f7f7f9bee604cc0
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M util/flashrom_tester/Cargo.toml
M util/flashrom_tester/src/main.rs
2 files changed, 13 insertions(+), 7 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/16/49916/1
diff --git a/util/flashrom_tester/Cargo.toml b/util/flashrom_tester/Cargo.toml
index 0898d3c..e7a5820 100644
--- a/util/flashrom_tester/Cargo.toml
+++ b/util/flashrom_tester/Cargo.toml
@@ -18,8 +18,8 @@
chrono = { version = "0.4", optional = true }
clap = { version = "2.33", default-features = false, optional = true }
flashrom = { path = "flashrom/" }
+libc = "0.2"
log = { version = "0.4", features = ["std"] }
-nix = "0.14.1"
rand = "0.6.4"
serde_json = "1"
sys-info = "0.5.7"
diff --git a/util/flashrom_tester/src/main.rs b/util/flashrom_tester/src/main.rs
index e589ee1..80484d2 100644
--- a/util/flashrom_tester/src/main.rs
+++ b/util/flashrom_tester/src/main.rs
@@ -152,12 +152,11 @@
/// Once a signal is trapped, the default behavior is restored (terminating
/// the process) for future signals.
fn handle_sigint() -> &'static AtomicBool {
- use nix::libc::c_int;
- use nix::sys::signal::{self, SigHandler, Signal};
+ use libc::c_int;
use std::sync::atomic::Ordering;

unsafe {
- let _ = signal::signal(Signal::SIGINT, SigHandler::Handler(sigint_handler));
+ let _ = libc::signal(libc::SIGINT, sigint_handler as libc::sighandler_t);
}
static TERMINATE_FLAG: AtomicBool = AtomicBool::new(false);

@@ -169,10 +168,17 @@
test, or press ^C again to exit immediately (possibly bricking your machine).
";

- // Use raw write() because signal-safety is a very hard problem
- let _ = nix::unistd::write(STDERR_FILENO, MESSAGE);
+ // Use raw write() because signal-safety is a very hard problem. Safe because this doesn't
+ // modify any memory.
+ let _ = unsafe {
+ libc::write(
+ STDERR_FILENO,
+ MESSAGE.as_ptr() as *const libc::c_void,
+ MESSAGE.len() as libc::size_t,
+ )
+ };
unsafe {
- let _ = signal::signal(Signal::SIGINT, SigHandler::SigDfl);
+ let _ = libc::signal(libc::SIGINT, libc::SIG_DFL);
}
TERMINATE_FLAG.store(true, Ordering::Release);
}

To view, visit change 49916. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If7d1c7c7b5663a32c0a338866f7f7f9bee604cc0
Gerrit-Change-Number: 49916
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange