From ed3e6b520108e4c2a72735148a7f04e7a6f9f57b Mon Sep 17 00:00:00 2001 From: Thomas Queiroz Date: Tue, 16 Nov 2021 18:06:57 -0300 Subject: [PATCH] uname: use UResult --- src/uu/uname/src/uname.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index 2c396081e..a4801dfc1 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -10,11 +10,9 @@ // spell-checker:ignore (ToDO) nodename kernelname kernelrelease kernelversion sysname hwplatform mnrsv -#[macro_use] -extern crate uucore; - use clap::{crate_version, App, Arg}; use platform_info::*; +use uucore::error::{FromIo, UResult}; const ABOUT: &str = "Print certain system information. With no OPTION, same as -s."; @@ -49,11 +47,13 @@ const HOST_OS: &str = "Fuchsia"; #[cfg(target_os = "redox")] const HOST_OS: &str = "Redox"; -pub fn uumain(args: impl uucore::Args) -> i32 { +#[uucore_procs::gen_uumain] +pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = format!("{} [OPTION]...", uucore::execution_phrase()); let matches = uu_app().usage(&usage[..]).get_matches_from(args); - let uname = crash_if_err!(1, PlatformInfo::new()); + let uname = + PlatformInfo::new().map_err_context(|| "failed to create PlatformInfo".to_string())?; let mut output = String::new(); let all = matches.is_present(options::ALL); @@ -115,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } println!("{}", output.trim_end()); - 0 + Ok(()) } pub fn uu_app() -> App<'static, 'static> {