Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a9c504d

Browse files
committed
chore: appear rustfmt, clippy and rustc
Lots of new warnings and lints Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
1 parent c1658c1 commit a9c504d

File tree

27 files changed

+154
-162
lines changed

27 files changed

+154
-162
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-
returnErr(UtilsArgParserError::MissingArgument(arg_name.to_string()));
374-
}
371+
if let Some(arg_name) = argument.requires
372+
&& !args.contains(&(format!("--{}", arg_name)))
373+
{
374+
returnErr(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/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-
ifletSome((start_past_64bit_gap, remaining_past_64bit_gap)) = arch_memory_regions_with_gap(
135+
) && letSome((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 asu64),
145-
remaining_past_64bit_gap,
146-
));
147-
}
142+
)
143+
{
144+
regions.push((
145+
GuestAddress(start_past_64bit_gap asu64),
146+
remaining_past_64bit_gap,
147+
));
148148
}
149149

150150
regions

‎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);

‎src/vmm/src/devices/virtio/block/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Block {
4141
VhostUserBlock::new(config).map_err(BlockError::VhostUserBackend)?,
4242
))
4343
} else {
44-
returnErr(BlockError::InvalidBlockConfig);
44+
Err(BlockError::InvalidBlockConfig)
4545
}
4646
}
4747

‎src/vmm/src/devices/virtio/block/virtio/device.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ impl VirtioBlock {
455455
});
456456
}
457457

458-
if let FileEngine::Async(ref mut engine) = self.disk.file_engine{
459-
if let Err(err) = engine.kick_submission_queue(){
460-
error!("BlockError submitting pending block requests: {:?}", err);
461-
}
458+
if let FileEngine::Async(ref mut engine) = self.disk.file_engine
459+
&& let Err(err) = engine.kick_submission_queue()
460+
{
461+
error!("BlockError submitting pending block requests: {:?}", err);
462462
}
463463

464464
if !used_any {

‎src/vmm/src/devices/virtio/block/virtio/event_handler.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ impl VirtioBlock {
2929
)) {
3030
error!("Failed to register ratelimiter event: {}", err);
3131
}
32-
if let FileEngine::Async(ref engine) = self.disk.file_engine{
33-
if let Err(err) = ops.add(Events::with_data(
32+
if let FileEngine::Async(ref engine) = self.disk.file_engine
33+
&& let Err(err) = ops.add(Events::with_data(
3434
engine.completion_evt(),
3535
Self::PROCESS_ASYNC_COMPLETION,
3636
EventSet::IN,
37-
)){
38-
error!("Failed to register IO engine completion event: {}", err);
39-
}
37+
))
38+
{
39+
error!("Failed to register IO engine completion event: {}", err);
4040
}
4141
}
4242

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /