Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resolver = "2"

[workspace.lints.rust]
missing_debug_implementations = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] }

[workspace.lints.clippy]
ptr_as_ptr = "warn"
Expand Down
30 changes: 15 additions & 15 deletions src/acpi-tables/src/aml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct Package<'a> {
children: Vec<&'a dyn Aml>,
}

impl<'a> Aml for Package<'a> {
impl Aml for Package<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = vec![self.children.len().try_into().unwrap()];
for child in &self.children {
Expand Down Expand Up @@ -336,7 +336,7 @@ pub struct ResourceTemplate<'a> {
children: Vec<&'a dyn Aml>,
}

impl<'a> Aml for ResourceTemplate<'a> {
impl Aml for ResourceTemplate<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = Vec::new();
// Add buffer data
Expand Down Expand Up @@ -607,7 +607,7 @@ pub struct Device<'a> {
children: Vec<&'a dyn Aml>,
}

impl<'a> Aml for Device<'a> {
impl Aml for Device<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = Vec::new();
self.path.append_aml_bytes(&mut tmp)?;
Expand Down Expand Up @@ -637,7 +637,7 @@ pub struct Scope<'a> {
children: Vec<&'a dyn Aml>,
}

impl<'a> Aml for Scope<'a> {
impl Aml for Scope<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = Vec::new();
self.path.append_aml_bytes(&mut tmp)?;
Expand Down Expand Up @@ -678,7 +678,7 @@ impl<'a> Method<'a> {
}
}

impl<'a> Aml for Method<'a> {
impl Aml for Method<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = Vec::new();
self.path.append_aml_bytes(&mut tmp)?;
Expand Down Expand Up @@ -707,7 +707,7 @@ impl<'a> Return<'a> {
}
}

impl<'a> Aml for Return<'a> {
impl Aml for Return<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0xa4); // ReturnOp
self.value.append_aml_bytes(bytes)?;
Expand Down Expand Up @@ -850,7 +850,7 @@ impl<'a> If<'a> {
}
}

impl<'a> Aml for If<'a> {
impl Aml for If<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = Vec::new();
self.predicate.append_aml_bytes(&mut tmp)?;
Expand Down Expand Up @@ -878,7 +878,7 @@ impl<'a> Equal<'a> {
}
}

impl<'a> Aml for Equal<'a> {
impl Aml for Equal<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0x93); // LEqualOp
self.left.append_aml_bytes(bytes)?;
Expand All @@ -898,7 +898,7 @@ impl<'a> LessThan<'a> {
}
}

impl<'a> Aml for LessThan<'a> {
impl Aml for LessThan<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0x95); // LLessOp
self.left.append_aml_bytes(bytes)?;
Expand Down Expand Up @@ -942,7 +942,7 @@ impl<'a> Store<'a> {
}
}

impl<'a> Aml for Store<'a> {
impl Aml for Store<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0x70); // StoreOp
self.value.append_aml_bytes(bytes)?;
Expand Down Expand Up @@ -1023,7 +1023,7 @@ impl<'a> Notify<'a> {
}
}

impl<'a> Aml for Notify<'a> {
impl Aml for Notify<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0x86); // NotifyOp
self.object.append_aml_bytes(bytes)?;
Expand All @@ -1046,7 +1046,7 @@ impl<'a> While<'a> {
}
}

impl<'a> Aml for While<'a> {
impl Aml for While<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
let mut tmp = Vec::new();
self.predicate.append_aml_bytes(&mut tmp)?;
Expand Down Expand Up @@ -1116,7 +1116,7 @@ impl<'a> MethodCall<'a> {
}
}

impl<'a> Aml for MethodCall<'a> {
impl Aml for MethodCall<'_> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
self.name.append_aml_bytes(bytes)?;
for arg in self.args.iter() {
Expand Down Expand Up @@ -1169,7 +1169,7 @@ impl<'a, T> CreateField<'a, T> {
}
}

impl<'a> Aml for CreateField<'a, u64> {
impl Aml for CreateField<'_, u64> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0x8f); // CreateQWordFieldOp
self.buffer.append_aml_bytes(bytes)?;
Expand All @@ -1178,7 +1178,7 @@ impl<'a> Aml for CreateField<'a, u64> {
}
}

impl<'a> Aml for CreateField<'a, u32> {
impl Aml for CreateField<'_, u32> {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
bytes.push(0x8a); // CreateDWordFieldOp
self.buffer.append_aml_bytes(bytes)?;
Expand Down
2 changes: 0 additions & 2 deletions src/clippy-tracing/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#![warn(clippy::pedantic)]

//! A tool to add, remove and check for `tracing::instrument` in large projects where it is
//! infeasible to manually add it to thousands of functions.

Expand Down
3 changes: 1 addition & 2 deletions src/firecracker/src/api_server/request/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ struct ActionBody {

pub(crate) fn parse_put_actions(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.put_api_requests.actions_count.inc();
let action_body = serde_json::from_slice::<ActionBody>(body.raw()).map_err(|err| {
let action_body = serde_json::from_slice::<ActionBody>(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.actions_fails.inc();
err
})?;

match action_body.action_type {
Expand Down
3 changes: 1 addition & 2 deletions src/firecracker/src/api_server/request/boot_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ use super::Body;
pub(crate) fn parse_put_boot_source(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.put_api_requests.boot_source_count.inc();
Ok(ParsedRequest::new_sync(VmmAction::ConfigureBootSource(
serde_json::from_slice::<BootSourceConfig>(body.raw()).map_err(|err| {
serde_json::from_slice::<BootSourceConfig>(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.boot_source_fails.inc();
err
})?,
)))
}
Expand Down
6 changes: 2 additions & 4 deletions src/firecracker/src/api_server/request/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ pub(crate) fn parse_put_drive(
return Err(RequestError::EmptyID);
};

let device_cfg = serde_json::from_slice::<BlockDeviceConfig>(body.raw()).map_err(|err| {
let device_cfg = serde_json::from_slice::<BlockDeviceConfig>(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.drive_fails.inc();
err
})?;

if id != device_cfg.drive_id {
Expand Down Expand Up @@ -51,9 +50,8 @@ pub(crate) fn parse_patch_drive(
};

let block_device_update_cfg: BlockDeviceUpdateConfig =
serde_json::from_slice::<BlockDeviceUpdateConfig>(body.raw()).map_err(|err| {
serde_json::from_slice::<BlockDeviceUpdateConfig>(body.raw()).inspect_err(|_| {
METRICS.patch_api_requests.drive_fails.inc();
err
})?;

if id != block_device_update_cfg.drive_id {
Expand Down
3 changes: 1 addition & 2 deletions src/firecracker/src/api_server/request/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use super::Body;
pub(crate) fn parse_put_logger(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.put_api_requests.logger_count.inc();
let res = serde_json::from_slice::<vmm::logger::LoggerConfig>(body.raw());
let config = res.map_err(|err| {
let config = res.inspect_err(|_| {
METRICS.put_api_requests.logger_fails.inc();
err
})?;
Ok(ParsedRequest::new_sync(VmmAction::ConfigureLogger(config)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ pub(crate) fn parse_get_machine_config() -> Result<ParsedRequest, RequestError>

pub(crate) fn parse_put_machine_config(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.put_api_requests.machine_cfg_count.inc();
let config = serde_json::from_slice::<MachineConfig>(body.raw()).map_err(|err| {
let config = serde_json::from_slice::<MachineConfig>(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.machine_cfg_fails.inc();
err
})?;

// Check for the presence of deprecated `cpu_template` field.
Expand All @@ -44,9 +43,8 @@ pub(crate) fn parse_put_machine_config(body: &Body) -> Result<ParsedRequest, Req
pub(crate) fn parse_patch_machine_config(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.patch_api_requests.machine_cfg_count.inc();
let config_update =
serde_json::from_slice::<MachineConfigUpdate>(body.raw()).map_err(|err| {
serde_json::from_slice::<MachineConfigUpdate>(body.raw()).inspect_err(|_| {
METRICS.patch_api_requests.machine_cfg_fails.inc();
err
})?;

if config_update.is_empty() {
Expand Down
3 changes: 1 addition & 2 deletions src/firecracker/src/api_server/request/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ use super::Body;
pub(crate) fn parse_put_metrics(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.put_api_requests.metrics_count.inc();
Ok(ParsedRequest::new_sync(VmmAction::ConfigureMetrics(
serde_json::from_slice::<MetricsConfig>(body.raw()).map_err(|err| {
serde_json::from_slice::<MetricsConfig>(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.metrics_fails.inc();
err
})?,
)))
}
Expand Down
9 changes: 3 additions & 6 deletions src/firecracker/src/api_server/request/mmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ pub(crate) fn parse_get_mmds() -> Result<ParsedRequest, RequestError> {
}

fn parse_put_mmds_config(body: &Body) -> Result<ParsedRequest, RequestError> {
let config: MmdsConfig = serde_json::from_slice(body.raw()).map_err(|err| {
let config: MmdsConfig = serde_json::from_slice(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.mmds_fails.inc();
err
})?;
// Construct the `ParsedRequest` object.
let version = config.version;
Expand All @@ -42,9 +41,8 @@ pub(crate) fn parse_put_mmds(
METRICS.put_api_requests.mmds_count.inc();
match path_second_token {
None => Ok(ParsedRequest::new_sync(VmmAction::PutMMDS(
serde_json::from_slice(body.raw()).map_err(|err| {
serde_json::from_slice(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.mmds_fails.inc();
err
})?,
))),
Some("config") => parse_put_mmds_config(body),
Expand All @@ -61,9 +59,8 @@ pub(crate) fn parse_put_mmds(
pub(crate) fn parse_patch_mmds(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.patch_api_requests.mmds_count.inc();
Ok(ParsedRequest::new_sync(VmmAction::PatchMMDS(
serde_json::from_slice(body.raw()).map_err(|err| {
serde_json::from_slice(body.raw()).inspect_err(|_| {
METRICS.patch_api_requests.mmds_fails.inc();
err
})?,
)))
}
Expand Down
6 changes: 2 additions & 4 deletions src/firecracker/src/api_server/request/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ pub(crate) fn parse_put_net(
return Err(RequestError::EmptyID);
};

let netif = serde_json::from_slice::<NetworkInterfaceConfig>(body.raw()).map_err(|err| {
let netif = serde_json::from_slice::<NetworkInterfaceConfig>(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.network_fails.inc();
err
})?;
if id != netif.iface_id.as_str() {
METRICS.put_api_requests.network_fails.inc();
Expand Down Expand Up @@ -53,9 +52,8 @@ pub(crate) fn parse_patch_net(
};

let netif =
serde_json::from_slice::<NetworkInterfaceUpdateConfig>(body.raw()).map_err(|err| {
serde_json::from_slice::<NetworkInterfaceUpdateConfig>(body.raw()).inspect_err(|_| {
METRICS.patch_api_requests.network_fails.inc();
err
})?;
if id != netif.iface_id {
METRICS.patch_api_requests.network_count.inc();
Expand Down
3 changes: 1 addition & 2 deletions src/firecracker/src/api_server/request/vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use super::Body;

pub(crate) fn parse_put_vsock(body: &Body) -> Result<ParsedRequest, RequestError> {
METRICS.put_api_requests.vsock_count.inc();
let vsock_cfg = serde_json::from_slice::<VsockDeviceConfig>(body.raw()).map_err(|err| {
let vsock_cfg = serde_json::from_slice::<VsockDeviceConfig>(body.raw()).inspect_err(|_| {
METRICS.put_api_requests.vsock_fails.inc();
err
})?;

// Check for the presence of deprecated `vsock_id` field.
Expand Down
2 changes: 1 addition & 1 deletion src/seccompiler/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ mod tests {
}

impl SeccompCondition {
// Creates a new `SeccompCondition`.
/// Creates a new `SeccompCondition`.
pub fn new(
arg_number: u8,
arg_len: SeccompCmpArgLen,
Expand Down
4 changes: 2 additions & 2 deletions src/seccompiler/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ mod tests {
};

impl Filter {
pub fn new(
fn new(
default_action: SeccompAction,
filter_action: SeccompAction,
filter: Vec<SyscallRule>,
Expand All @@ -272,7 +272,7 @@ mod tests {
}

impl SyscallRule {
pub fn new(syscall: String, conditions: Option<Vec<Cond>>) -> SyscallRule {
fn new(syscall: String, conditions: Option<Vec<Cond>>) -> SyscallRule {
SyscallRule {
syscall,
conditions,
Expand Down
4 changes: 2 additions & 2 deletions src/vmm/benches/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn queue_benchmark(c: &mut Criterion) {
for i in 0_u16..16_u16 {
let index = std::hint::black_box(i);
let len = std::hint::black_box(i + 1);
_ = queue.add_used(index as u16, len as u32);
_ = queue.add_used(index, len as u32);
}
})
});
Expand All @@ -100,7 +100,7 @@ pub fn queue_benchmark(c: &mut Criterion) {
for i in 0_u16..256_u16 {
let index = std::hint::black_box(i);
let len = std::hint::black_box(i + 1);
_ = queue.add_used(index as u16, len as u32);
_ = queue.add_used(index, len as u32);
}
})
});
Expand Down
4 changes: 2 additions & 2 deletions src/vmm/src/acpi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct AcpiTableWriter<'a> {
resource_allocator: &'a mut ResourceAllocator,
}

impl<'a> AcpiTableWriter<'a> {
impl AcpiTableWriter<'_> {
/// Write a table in guest memory
///
/// This will allocate enough space inside guest memory and write the table in the allocated
Expand Down Expand Up @@ -181,7 +181,7 @@ pub(crate) fn create_acpi_tables(
}

#[cfg(test)]
pub mod tests {
mod tests {
use acpi_tables::Sdt;
use vm_memory::Bytes;

Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/arch/x86_64/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file.

/// Magic addresses externally used to lay out x86_64 VMs.
//! Magic addresses externally used to lay out x86_64 VMs.

/// Initial stack for the boot CPU.
pub const BOOT_STACK_POINTER: u64 = 0x8ff0;
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ pub(crate) fn set_stdout_nonblocking() {
}

#[cfg(test)]
pub mod tests {
pub(crate) mod tests {
use std::io::Write;

use linux_loader::cmdline::Cmdline;
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/cpu_config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ pub mod x86_64;
pub mod aarch64;

#[cfg(test)]
pub mod test_utils;
pub(crate) mod test_utils;
Loading