From 994269c278964062b8c31eb6df4f50b638998304 Mon Sep 17 00:00:00 2001 From: Steffen Eiden Date: Wed, 19 Nov 2025 10:24:25 +0100 Subject: [PATCH] rust: Fix formatting issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some `rustfmt` findings. Reviewed-by: Jan Höppner Signed-off-by: Steffen Eiden Signed-off-by: Jan Höppner --- rust/pv_core/src/apdevice.rs | 20 +++++--------------- rust/pvapconfig/src/ap.rs | 8 ++------ rust/pvapconfig/src/config.rs | 10 ++-------- rust/pvapconfig/src/main.rs | 4 +--- 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/rust/pv_core/src/apdevice.rs b/rust/pv_core/src/apdevice.rs index ec9f7834..34b8e091 100644 --- a/rust/pv_core/src/apdevice.rs +++ b/rust/pv_core/src/apdevice.rs @@ -303,9 +303,7 @@ pub enum BindState { /// Returns a BindState enum as defined above or on failure /// an error string. Does NOT print any error messages. pub fn get_apqn_bind_state(card: u32, dom: u32) -> Result { - let path = format!( - "{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_bind" - ); + let path = format!("{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_bind"); let state_str = read_file_string(path, "se_bind attribute")?; let state = state_str.trim(); match state { @@ -330,9 +328,7 @@ pub fn get_apqn_bind_state(card: u32, dom: u32) -> Result { /// Panics if a desired bind state other than Bound or Unbound is given. pub fn set_apqn_bind_state(card: u32, dom: u32, state: BindState) -> Result<()> { let ctx = "bind APQN"; - let path = format!( - "{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_bind" - ); + let path = format!("{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_bind"); match state { BindState::Bound => write_file(path, 1.to_string(), ctx), BindState::Unbound => write_file(path, 0.to_string(), ctx), @@ -372,9 +368,7 @@ pub enum AssocState { /// Returns an AssocState enum as defined above or on failure /// an error string. Does NOT print any error messages. pub fn get_apqn_associate_state(card: u32, dom: u32) -> Result { - let path = format!( - "{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_associate" - ); + let path = format!("{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_associate"); let state_str = read_file_string(path, "se_associate attribute")?; let state = state_str.trim(); match state.strip_prefix("associated ") { @@ -389,9 +383,7 @@ pub fn get_apqn_associate_state(card: u32, dom: u32) -> Result { } fn set_apqn_associate_state_associate(card: u32, dom: u32, idx: u16) -> Result<()> { - let path = format!( - "{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_associate" - ); + let path = format!("{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_associate"); write_file(path, idx.to_string(), "associate APQN")?; let mut ms: u64 = 0; loop { @@ -418,9 +410,7 @@ fn set_apqn_associate_state_associate(card: u32, dom: u32, idx: u16) -> Result<( } fn set_apqn_associate_state_unbind(card: u32, dom: u32) -> Result<()> { - let bindpath = format!( - "{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_bind" - ); + let bindpath = format!("{PATH_SYS_DEVICES_AP}/card{card:02x}/{card:02x}.{dom:04x}/se_bind"); write_file(bindpath, 0.to_string(), "unbind APQN")?; let mut ms: u64 = 0; loop { diff --git a/rust/pvapconfig/src/ap.rs b/rust/pvapconfig/src/ap.rs index 93b23ca8..f9f5dffc 100644 --- a/rust/pvapconfig/src/ap.rs +++ b/rust/pvapconfig/src/ap.rs @@ -126,9 +126,7 @@ impl ApqnList { match sysfs_get_list_of_subdirs_matching_regex(PATH_SYS_DEVICES_AP, RE_CARD_DIR) { Ok(r) => r, Err(err) => { - eprintln!( - "Failure reading AP devices {PATH_SYS_DEVICES_AP} ({err:?})." - ); + eprintln!("Failure reading AP devices {PATH_SYS_DEVICES_AP} ({err:?})."); return None; } }; @@ -137,9 +135,7 @@ impl ApqnList { let queue_dirs = match sysfs_get_list_of_subdirs_matching_regex(&path, RE_QUEUE_DIR) { Ok(r) => r, Err(err) => { - eprintln!( - "Failure reading AP queue directories in {path} ({err:?})." - ); + eprintln!("Failure reading AP queue directories in {path} ({err:?})."); return None; } }; diff --git a/rust/pvapconfig/src/config.rs b/rust/pvapconfig/src/config.rs index d92f82ba..a4e712a4 100644 --- a/rust/pvapconfig/src/config.rs +++ b/rust/pvapconfig/src/config.rs @@ -174,17 +174,11 @@ impl ApConfigList { fn read_yaml_file(fname: &str) -> Result, String> { let file = match File::open(fname) { Ok(f) => f, - Err(err) => { - return Err(format!( - "Failure to open AP config file {fname}: {err:?}" - )) - } + Err(err) => return Err(format!("Failure to open AP config file {fname}: {err:?}")), }; match serde_yaml::from_reader(file) { Ok(cfg) => Ok(cfg), - Err(err) => Err(format!( - "Failure parsing AP config file {fname}: {err:?}" - )), + Err(err) => Err(format!("Failure parsing AP config file {fname}: {err:?}")), } } diff --git a/rust/pvapconfig/src/main.rs b/rust/pvapconfig/src/main.rs index 5ad67db1..7645e10b 100644 --- a/rust/pvapconfig/src/main.rs +++ b/rust/pvapconfig/src/main.rs @@ -102,9 +102,7 @@ fn main() -> ExitCode { Err(err) => println_and_exit_failure!("{}", err), }; if apconfig.is_empty() { - println!( - "No AP configuration entries in config file '{configfile}': Nothing to do." - ); + println!("No AP configuration entries in config file '{configfile}': Nothing to do."); return ExitCode::SUCCESS; } info!("Found {} AP configuration entries.\n", apconfig.len());