From 2156317958207e290a3f0679987a4f37e8f04b6c Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 21 Sep 2026 21:30:37 +0200 Subject: nasm: prefer the use of die() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For historical reasons, some points of the code were not using this function, calling eprintln!() and exit() manually instead. Signed-off-by: Miquel Sabaté Solà --- crates/nasm/src/main.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs index eea135e..8d3f35e 100644 --- a/crates/nasm/src/main.rs +++ b/crates/nasm/src/main.rs @@ -395,10 +395,7 @@ fn main() { // Open the file and truncate it if it already exists. let file = match File::create(&path) { Ok(f) => f, - Err(e) => { - eprintln!("error: could not create '{name}.out': {e}"); - std::process::exit(1); - } + Err(e) => die(format!("could not create '{name}.out': {e}")), }; // And write the contents for this segment/file with @@ -406,13 +403,11 @@ fn main() { let mut writer = BufWriter::new(file); for b in &segment.bundles { if let Err(e) = writer.write_all(&b.bytes[..b.size as usize]) { - eprintln!("error: could not write to '{name}.out': {e}"); - std::process::exit(1); + die(format!("could not write to '{name}.out': {e}")); } } if let Err(e) = writer.flush() { - eprintln!("error: could not write to '{name}.out': {e}"); - std::process::exit(1); + die(format!("could not write to '{name}.out': {e}")); } } } @@ -447,12 +442,10 @@ fn main() { for b in res.bundles { if let Err(e) = output.write_all(&b.bytes[..b.size as usize]) { - eprintln!("error: could not write result in '{output_name}': {e}"); - std::process::exit(1); + die(format!("could not write result in '{output_name}': {e}")); } if let Err(e) = output.flush() { - eprintln!("error: could not write to '{output_name}': {e}"); - std::process::exit(1); + die(format!("could not write to '{output_name}': {e}")); } } } -- cgit v1.2.3