misc: clippy: add redundant_else

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster 2025-11-18 12:30:49 +01:00 committed by Rob Bradford
parent d2b19bb969
commit a0b72dce22
10 changed files with 51 additions and 60 deletions

View file

@ -173,6 +173,7 @@ suspicious = "deny"
assertions_on_result_states = "deny"
manual_string_new = "deny"
map_unwrap_or = "deny"
redundant_else = "deny"
semicolon_if_nothing_returned = "deny"
undocumented_unsafe_blocks = "deny"
uninlined_format_args = "deny"

View file

@ -1214,9 +1214,8 @@ impl hypervisor::Hypervisor for KvmHypervisor {
// ioctl has been interrupted, we have to retry as
// this can't be considered as a regular error.
continue;
} else {
return Err(hypervisor::HypervisorError::VmCreate(e.into()));
}
return Err(hypervisor::HypervisorError::VmCreate(e.into()));
}
}
break;

View file

@ -303,9 +303,8 @@ impl hypervisor::Hypervisor for MshvHypervisor {
// ioctl has been interrupted, we have to retry as
// this can't be considered as a regular error.
continue;
} else {
return Err(hypervisor::HypervisorError::VmCreate(e.into()));
}
return Err(hypervisor::HypervisorError::VmCreate(e.into()));
}
}
break;

View file

@ -948,12 +948,11 @@ impl PciConfiguration {
self.pending_bar_reprogram
);
return self.pending_bar_reprogram.drain(..).collect();
} else {
info!(
"MSE bit is disabled. No BAR reprogramming parameter is returned: {:x?}",
self.pending_bar_reprogram
);
}
info!(
"MSE bit is disabled. No BAR reprogramming parameter is returned: {:x?}",
self.pending_bar_reprogram
);
}
Vec::new()

View file

@ -910,16 +910,15 @@ impl VfioCommon {
let cap_id = self.vfio_wrapper.read_config_byte(cap_next.into());
if PciCapabilityId::from(cap_id) == PciCapabilityId::MsiX {
return Some(cap_next as usize);
} else {
let cap_ptr = self.vfio_wrapper.read_config_byte((cap_next + 1).into())
& PCI_CONFIG_CAPABILITY_PTR_MASK;
}
let cap_ptr = self.vfio_wrapper.read_config_byte((cap_next + 1).into())
& PCI_CONFIG_CAPABILITY_PTR_MASK;
// See parse_capabilities below for an explanation.
if cap_ptr != cap_next {
cap_next = cap_ptr;
} else {
break;
}
// See parse_capabilities below for an explanation.
if cap_ptr != cap_next {
cap_next = cap_ptr;
} else {
break;
}
}

View file

@ -234,9 +234,8 @@ impl RateLimiterGroup {
Err(e) => {
if e.kind() == io::ErrorKind::Interrupted {
continue;
} else {
return Err(Error::Epoll(e));
}
return Err(Error::Epoll(e));
}
};

View file

@ -168,12 +168,11 @@ impl TokenBucket {
self.last_update = Instant::now();
// No need to continue to the refill process, we still have burst budget to consume from.
return BucketReduction::Success;
} else {
// We still have burst budget for *some* of the tokens requests.
// The tokens left unfulfilled will be consumed from current `self.budget`.
tokens -= self.one_time_burst;
self.one_time_burst = 0;
}
// We still have burst budget for *some* of the tokens requests.
// The tokens left unfulfilled will be consumed from current `self.budget`.
tokens -= self.one_time_burst;
self.one_time_burst = 0;
}
// Compute time passed since last refill/update.

View file

@ -726,17 +726,16 @@ impl VcpuState {
loop {
if self.vcpu_run_interrupted.load(Ordering::SeqCst) {
return Ok(());
} else {
// This is more effective than thread::yield_now() at
// avoiding a priority inversion with the vCPU thread
thread::sleep(std::time::Duration::from_millis(1));
count += 1;
if count >= 1000 {
return Err(Error::SignalAcknowledgeTimeout);
} else if count % 10 == 0 {
warn!("vCPU thread did not respond in {count}ms to signal - retrying");
self.signal_thread();
}
}
// This is more effective than thread::yield_now() at
// avoiding a priority inversion with the vCPU thread
thread::sleep(std::time::Duration::from_millis(1));
count += 1;
if count >= 1000 {
return Err(Error::SignalAcknowledgeTimeout);
} else if count % 10 == 0 {
warn!("vCPU thread did not respond in {count}ms to signal - retrying");
self.signal_thread();
}
}
}
@ -807,21 +806,20 @@ impl CpuManager {
if amx_tile != 0 {
return Err(Error::AmxEnable(anyhow!("Guest AMX usage not supported")));
} else {
let mut mask: usize = 0;
// SAFETY: Syscall with valid parameters. We use a raw mutable pointer to
// the `mask` place in order to ensure that we do not violate Rust's
// aliasing rules.
let result = unsafe {
libc::syscall(
libc::SYS_arch_prctl,
ARCH_GET_XCOMP_GUEST_PERM,
&raw mut mask,
)
};
if result != 0 || (mask & XFEATURE_XTILEDATA_MASK) != XFEATURE_XTILEDATA_MASK {
return Err(Error::AmxEnable(anyhow!("Guest AMX usage not supported")));
}
}
let mut mask: usize = 0;
// SAFETY: Syscall with valid parameters. We use a raw mutable pointer to
// the `mask` place in order to ensure that we do not violate Rust's
// aliasing rules.
let result = unsafe {
libc::syscall(
libc::SYS_arch_prctl,
ARCH_GET_XCOMP_GUEST_PERM,
&raw mut mask,
)
};
if result != 0 || (mask & XFEATURE_XTILEDATA_MASK) != XFEATURE_XTILEDATA_MASK {
return Err(Error::AmxEnable(anyhow!("Guest AMX usage not supported")));
}
}

View file

@ -289,9 +289,8 @@ impl SerialManager {
// be considered as a regular error. Instead it is more
// appropriate to retry, by calling into epoll_wait().
continue;
} else {
return Err(Error::Epoll(e));
}
return Err(Error::Epoll(e));
}
};

View file

@ -1743,14 +1743,13 @@ impl Vm {
zone.hotplugged_size = Some(hotplugged_size);
return Ok(());
} else {
error!(
"Invalid to ask less ({}) than boot RAM ({}) for \
this memory zone",
desired_memory, zone.size,
);
return Err(Error::ResizeZone);
}
error!(
"Invalid to ask less ({}) than boot RAM ({}) for \
this memory zone",
desired_memory, zone.size,
);
return Err(Error::ResizeZone);
}
}
}