clippy: fix warnings from collapsible_if lint

This commit is contained in:
Daniel Hofstetter
2025-08-08 11:14:04 +02:00
parent 4366804267
commit cb25413e54
5 changed files with 37 additions and 34 deletions

View File

@@ -217,10 +217,12 @@ impl SysFSCpu {
.map_err(|err| ChCpuError::io0("write standard output", err));
}
if let Some(enabled_cpu_list) = enabled_cpu_list {
if previous_config && !configure && enabled_cpu_list.0.contains(&cpu_index) {
return Err(ChCpuError::CpuIsEnabled(cpu_index));
}
if let Some(enabled_cpu_list) = enabled_cpu_list
&& previous_config
&& !configure
&& enabled_cpu_list.0.contains(&cpu_index)
{
return Err(ChCpuError::CpuIsEnabled(cpu_index));
}
if let Err(err) = self.write_value(&configure_path, u8::from(configure)) {

View File

@@ -341,11 +341,11 @@ pub(crate) fn describe(
let now = time_of_day()?;
let sys_v_ipc = SysVIpc::new(id)?;
if let Some(id) = id {
if sys_v_ipc.0.len() != 1 {
eprintln!("id {id} not found");
return Ok(());
}
if let Some(id) = id
&& sys_v_ipc.0.len() != 1
{
eprintln!("id {id} not found");
return Ok(());
}
table.set_name(c"messages")?;

View File

@@ -410,11 +410,11 @@ pub(crate) fn describe(
let now = time_of_day()?;
let sys_v_ipc = SysVIpc::new(id)?;
if let Some(id) = id {
if sys_v_ipc.0.len() != 1 {
eprintln!("id {id} not found");
return Ok(());
}
if let Some(id) = id
&& sys_v_ipc.0.len() != 1
{
eprintln!("id {id} not found");
return Ok(());
}
table.set_name(c"semaphores")?;

View File

@@ -391,11 +391,11 @@ pub(crate) fn describe(
let now = time_of_day()?;
let sys_v_ipc = SysVIpc::new(id)?;
if let Some(id) = id {
if sys_v_ipc.0.len() != 1 {
eprintln!("id {id} not found");
return Ok(());
}
if let Some(id) = id
&& sys_v_ipc.0.len() != 1
{
eprintln!("id {id} not found");
return Ok(());
}
table.set_name(c"sharedmemory")?;

View File

@@ -275,22 +275,23 @@ impl LockInfo {
let range = start..end;
if let Some(pid_locks) = pid_locks {
if command_name.is_none() && !blocked {
let lock_compare = |lock: &&LockInfo| {
lock.range == range
&& lock.inode == inode
&& lock.device_id == device_id
&& lock.mandatory == mandatory
&& lock.blocked == blocked
&& lock.kind == kind
&& lock.mode == mode
};
if let Some(pid_locks) = pid_locks
&& command_name.is_none()
&& !blocked
{
let lock_compare = |lock: &&LockInfo| {
lock.range == range
&& lock.inode == inode
&& lock.device_id == device_id
&& lock.mandatory == mandatory
&& lock.blocked == blocked
&& lock.kind == kind
&& lock.mode == mode
};
if let Some(found) = pid_locks.iter().find(lock_compare) {
process_id = found.process_id;
command_name = found.command_name.clone();
}
if let Some(found) = pid_locks.iter().find(lock_compare) {
process_id = found.process_id;
command_name = found.command_name.clone();
}
}