mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust: Fix formatting issues
Some `rustfmt` findings. Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
ae5687f1d1
commit
994269c278
@@ -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<BindState> {
|
||||
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<BindState> {
|
||||
/// 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<AssocState> {
|
||||
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<AssocState> {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -174,17 +174,11 @@ impl ApConfigList {
|
||||
fn read_yaml_file(fname: &str) -> Result<Vec<ApConfigEntry>, 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:?}")),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user