Skip to content

Commit be1bb3b

Browse files
committed
chore: appease rustfmt, clippy and rustc
Lots of new warnings and lints Signed-off-by: Patrick Roy <[email protected]>
1 parent 584c52c commit be1bb3b

File tree

30 files changed

+161
-169
lines changed

30 files changed

+161
-169
lines changed

src/firecracker/src/api_server/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ impl ApiServer {
174174
let vmm_outcome = *(self.vmm_response_receiver.recv().expect("VMM disconnected"));
175175
let response = ParsedRequest::convert_to_response(&vmm_outcome);
176176

177-
if vmm_outcome.is_ok() {
178-
if let Some((metric, action)) = metric_with_action {
179-
let elapsed_time_us =
180-
update_metric_with_elapsed_time(metric, request_processing_start_us);
181-
info!("'{}' API request took {} us.", action, elapsed_time_us);
182-
}
177+
if vmm_outcome.is_ok()
178+
&& let Some((metric, action)) = metric_with_action
179+
{
180+
let elapsed_time_us =
181+
update_metric_with_elapsed_time(metric, request_processing_start_us);
182+
info!("'{}' API request took {} us.", action, elapsed_time_us);
183183
}
184184
response
185185
}

src/utils/src/arg_parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'a> ArgParser<'a> {
7777
}
7878

7979
/// Return a reference to `arguments` field.
80-
pub fn arguments(&self) -> &Arguments {
80+
pub fn arguments(&self) -> &Arguments<'_> {
8181
&self.arguments
8282
}
8383

@@ -368,10 +368,10 @@ impl<'a> Arguments<'a> {
368368
if argument.user_value.is_some() {
369369
// For the arguments that require a specific argument to be also present in the list
370370
// of arguments provided by user, search for that argument.
371-
if let Some(arg_name) = argument.requires {
372-
if !args.contains(&(format!("--{}", arg_name))) {
373-
return Err(UtilsArgParserError::MissingArgument(arg_name.to_string()));
374-
}
371+
if let Some(arg_name) = argument.requires
372+
&& !args.contains(&(format!("--{}", arg_name)))
373+
{
374+
return Err(UtilsArgParserError::MissingArgument(arg_name.to_string()));
375375
}
376376
// Check the user-provided list for potential forbidden arguments.
377377
for arg_name in argument.forbids.iter() {

src/vmm/src/arch/aarch64/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ fn get_fdt_addr(mem: &GuestMemoryMmap) -> u64 {
169169
// we return the start of the DRAM so that
170170
// we allow the code to try and load the FDT.
171171

172-
if let Some(addr) = mem.last_addr().checked_sub(layout::FDT_MAX_SIZE as u64 - 1) {
173-
if mem.address_in_range(addr) {
174-
return addr.raw_value();
175-
}
172+
if let Some(addr) = mem.last_addr().checked_sub(layout::FDT_MAX_SIZE as u64 - 1)
173+
&& mem.address_in_range(addr)
174+
{
175+
return addr.raw_value();
176176
}
177177

178178
layout::DRAM_MEM_START

src/vmm/src/arch/aarch64/regs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl Aarch64RegisterVec {
243243
}
244244

245245
/// Returns an iterator over stored registers.
246-
pub fn iter(&self) -> impl Iterator<Item = Aarch64RegisterRef> {
246+
pub fn iter(&self) -> impl Iterator<Item = Aarch64RegisterRef<'_>> {
247247
Aarch64RegisterVecIterator {
248248
index: 0,
249249
offset: 0,
@@ -253,7 +253,7 @@ impl Aarch64RegisterVec {
253253
}
254254

255255
/// Returns an iterator over stored registers that allows register modifications.
256-
pub fn iter_mut(&mut self) -> impl Iterator<Item = Aarch64RegisterRefMut> {
256+
pub fn iter_mut(&mut self) -> impl Iterator<Item = Aarch64RegisterRefMut<'_>> {
257257
Aarch64RegisterVecIteratorMut {
258258
index: 0,
259259
offset: 0,

src/vmm/src/arch/x86_64/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,19 @@ pub fn arch_memory_regions(size: usize) -> Vec<(GuestAddress, usize)> {
132132
dram_size,
133133
u64_to_usize(MMIO32_MEM_START),
134134
u64_to_usize(MMIO32_MEM_SIZE),
135-
) {
136-
if let Some((start_past_64bit_gap, remaining_past_64bit_gap)) = arch_memory_regions_with_gap(
135+
) && let Some((start_past_64bit_gap, remaining_past_64bit_gap)) =
136+
arch_memory_regions_with_gap(
137137
&mut regions,
138138
start_past_32bit_gap,
139139
remaining_past_32bit_gap,
140140
u64_to_usize(MMIO64_MEM_START),
141141
u64_to_usize(MMIO64_MEM_SIZE),
142-
) {
143-
regions.push((
144-
GuestAddress(start_past_64bit_gap as u64),
145-
remaining_past_64bit_gap,
146-
));
147-
}
142+
)
143+
{
144+
regions.push((
145+
GuestAddress(start_past_64bit_gap as u64),
146+
remaining_past_64bit_gap,
147+
));
148148
}
149149

150150
regions

src/vmm/src/cpu_config/aarch64/custom_cpu_template.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::cpu_config::templates::{
1717
use crate::cpu_config::templates_serde::*;
1818

1919
impl GetCpuTemplate for Option<CpuTemplateType> {
20-
fn get_cpu_template(&self) -> Result<Cow<CustomCpuTemplate>, GetCpuTemplateError> {
20+
fn get_cpu_template(&self) -> Result<Cow<'_, CustomCpuTemplate>, GetCpuTemplateError> {
2121
match self {
2222
Some(template_type) => match template_type {
2323
CpuTemplateType::Custom(template) => Ok(Cow::Borrowed(template)),

src/vmm/src/cpu_config/templates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub enum GetCpuTemplateError {
4949
/// custom CPU templates and handle static CPU template and custom CPU template in a same manner.
5050
pub trait GetCpuTemplate {
5151
/// Get CPU template
52-
fn get_cpu_template(&self) -> Result<Cow<CustomCpuTemplate>, GetCpuTemplateError>;
52+
fn get_cpu_template(&self) -> Result<Cow<'_, CustomCpuTemplate>, GetCpuTemplateError>;
5353
}
5454

5555
/// Enum that represents types of cpu templates available.

src/vmm/src/cpu_config/x86_64/custom_cpu_template.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::cpu_config::x86_64::static_cpu_templates::{StaticCpuTemplate, c3, t2,
1919
use crate::logger::warn;
2020

2121
impl GetCpuTemplate for Option<CpuTemplateType> {
22-
fn get_cpu_template(&self) -> Result<Cow<CustomCpuTemplate>, GetCpuTemplateError> {
22+
fn get_cpu_template(&self) -> Result<Cow<'_, CustomCpuTemplate>, GetCpuTemplateError> {
2323
use GetCpuTemplateError::*;
2424

2525
match self {

src/vmm/src/devices/legacy/i8042.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,10 @@ impl vm_device::BusDevice for I8042Device {
230230
// Check if we still have data in the internal buffer. If so, we need to trigger
231231
// another interrupt, to let the guest know they need to issue another read from
232232
// port 0x60.
233-
if (self.status & SB_OUT_DATA_AVAIL) != 0 {
234-
if let Err(I8042Error::KbdInterruptFailure(err)) = self.trigger_kbd_interrupt()
235-
{
236-
warn!("Failed to trigger i8042 kbd interrupt {:?}", err);
237-
}
233+
if (self.status & SB_OUT_DATA_AVAIL) != 0
234+
&& let Err(I8042Error::KbdInterruptFailure(err)) = self.trigger_kbd_interrupt()
235+
{
236+
warn!("Failed to trigger i8042 kbd interrupt {:?}", err);
238237
}
239238
}
240239
_ => read_ok = false,

src/vmm/src/devices/legacy/serial.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ impl<I: Read + AsRawFd + Send + Debug> MutEventSubscriber
333333
// Therefore, only try to register stdin to epoll if it is a terminal or a FIFO pipe.
334334
// SAFETY: isatty has no invariants that need to be upheld. If serial_fd is an invalid
335335
// argument, it will return 0 and set errno to EBADF.
336-
if unsafe { libc::isatty(serial_fd) } == 1 || is_fifo(serial_fd) {
337-
if let Err(err) = ops.add(Events::new(&serial_fd, EventSet::IN)) {
338-
warn!("Failed to register serial input fd: {}", err);
339-
}
336+
if (unsafe { libc::isatty(serial_fd) } == 1 || is_fifo(serial_fd))
337+
&& let Err(err) = ops.add(Events::new(&serial_fd, EventSet::IN))
338+
{
339+
warn!("Failed to register serial input fd: {}", err);
340340
}
341341
if let Err(err) = ops.add(Events::new(&buf_ready_evt, EventSet::IN)) {
342342
warn!("Failed to register serial buffer ready event: {}", err);

0 commit comments

Comments
 (0)