Skip to content

Commit 4b90911

Browse files
committed
CI: enforce clippy rules in clippy command
Instead of polluting the source code with it. Signed-off-by: Diana Popa <[email protected]>
1 parent e6ce775 commit 4b90911

File tree

19 files changed

+11
-44
lines changed

19 files changed

+11
-44
lines changed

src/api_server/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#![deny(missing_docs)]
5-
#![warn(clippy::ptr_as_ptr)]
6-
#![warn(clippy::undocumented_unsafe_blocks)]
75

86
//! Implements the interface for intercepting API requests, forwarding them to the VMM
97
//! and responding to the user.

src/arch/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#![deny(missing_docs)]
5-
#![warn(clippy::ptr_as_ptr)]
6-
#![warn(clippy::undocumented_unsafe_blocks)]
75

86
//! Implements platform specific functionality.
97
//! Supported platforms: x86_64 and aarch64.

src/cpuid/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// found in the THIRD-PARTY file.
77

88
#![deny(missing_docs)]
9-
#![warn(clippy::ptr_as_ptr)]
10-
#![warn(clippy::undocumented_unsafe_blocks)]
119

1210
//! Utility for configuring the CPUID (CPU identification) for the guest microVM.
1311

src/devices/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
// Use of this source code is governed by a BSD-style license that can be
66
// found in the THIRD-PARTY file.
77

8-
#![warn(clippy::ptr_as_ptr)]
9-
#![warn(clippy::undocumented_unsafe_blocks)]
10-
118
//! Emulates virtual and hardware devices.
129
use std::io;
1310

src/dumbo/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#![deny(missing_docs)]
5-
#![warn(clippy::ptr_as_ptr)]
6-
#![warn(clippy::undocumented_unsafe_blocks)]
75

86
//! Provides helper logic for parsing and writing protocol data units, and minimalist
97
//! implementations of a TCP listener, a TCP connection, and an HTTP/1.1 server.

src/firecracker/src/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#![warn(clippy::ptr_as_ptr)]
5-
#![warn(clippy::undocumented_unsafe_blocks)]
6-
74
mod api_server_adapter;
85
mod metrics;
96

src/io_uring/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#![deny(missing_docs)]
5-
#![warn(clippy::ptr_as_ptr)]
6-
#![warn(clippy::undocumented_unsafe_blocks)]
75

86
//! High-level interface over Linux io_uring.
97
//!

src/jailer/src/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#![warn(clippy::ptr_as_ptr)]
5-
#![warn(clippy::undocumented_unsafe_blocks)]
6-
74
mod cgroup;
85
mod chroot;
96
mod env;

src/logger/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#![deny(missing_docs)]
5-
#![warn(clippy::ptr_as_ptr)]
6-
#![warn(clippy::undocumented_unsafe_blocks)]
75

86
//! Crate that implements Firecracker specific functionality as far as logging and metrics
97
//! collecting.

src/mmds/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#![warn(clippy::ptr_as_ptr)]
5-
#![warn(clippy::undocumented_unsafe_blocks)]
6-
74
pub mod data_store;
85
pub mod ns;
96
pub mod persist;

src/rate_limiter/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#![deny(missing_docs)]
5-
#![warn(clippy::ptr_as_ptr)]
6-
#![warn(clippy::undocumented_unsafe_blocks)]
75

86
//! # Rate Limiter
97
//!

src/rebase-snap/src/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#![warn(clippy::ptr_as_ptr)]
5-
#![warn(clippy::undocumented_unsafe_blocks)]
6-
74
use std::fs::{File, OpenOptions};
85
use std::io::{Seek, SeekFrom};
96
use std::os::unix::io::AsRawFd;

src/seccompiler/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
34
#![deny(missing_docs)]
4-
#![warn(clippy::ptr_as_ptr)]
5-
#![warn(clippy::undocumented_unsafe_blocks)]
65

76
//! The library crate that defines common helper functions that are generally used in
87
//! conjunction with seccompiler-bin.

src/snapshot/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
#![deny(missing_docs)]
4-
#![warn(clippy::ptr_as_ptr)]
5-
#![warn(clippy::undocumented_unsafe_blocks)]
64

75
//! Provides version tolerant serialization and deserialization facilities and
86
//! implements a persistent storage format for Firecracker state snapshots.

src/utils/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#![warn(clippy::ptr_as_ptr)]
5-
#![warn(clippy::undocumented_unsafe_blocks)]
6-
74
// We use `utils` as a wrapper over `vmm_sys_util` to control the latter
85
// dependency easier (i.e. update only in one place `vmm_sys_util` version).
96
// More specifically, we are re-exporting modules from `vmm_sys_util` as part

src/vm-memory/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
55
// Use of this source code is governed by a BSD-style license that can be
66
// found in the THIRD-PARTY file.
7-
#![warn(clippy::undocumented_unsafe_blocks)]
87

98
use std::io::Error as IoError;
109
use std::os::unix::io::AsRawFd;
@@ -103,7 +102,7 @@ fn build_guarded_region(
103102
// SAFETY: Safe because the parameters are valid.
104103
unsafe {
105104
MmapRegionBuilder::new_with_bitmap(size, bitmap)
106-
.with_raw_mmap_pointer(region_addr as *mut u8)
105+
.with_raw_mmap_pointer(region_addr.cast::<u8>())
107106
.with_mmap_prot(prot)
108107
.with_mmap_flags(flags)
109108
.build()

src/vmm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// Use of this source code is governed by a BSD-style license that can be
66
// found in the THIRD-PARTY file.
77

8+
#![deny(missing_docs)]
9+
810
//! Virtual Machine Monitor that leverages the Linux Kernel-based Virtual Machine (KVM),
911
//! and other virtualization features to run a single lightweight micro-virtual
1012
//! machine (microVM).
11-
#![deny(missing_docs)]
12-
#![warn(clippy::undocumented_unsafe_blocks)]
1313
1414
/// Handles setup and initialization a `Vmm` object.
1515
pub mod builder;

src/vmm/src/persist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ fn guest_memory_from_uffd(
668668
let host_base_addr = mem_region.as_ptr();
669669
let size = mem_region.size();
670670

671-
uffd.register(host_base_addr as _, size as _)
671+
uffd.register(host_base_addr.cast(), size as _)
672672
.map_err(GuestMemoryFromUffdError::Register)?;
673673
backend_mappings.push(GuestRegionUffdMapping {
674674
base_host_virt_addr: host_base_addr as u64,

tests/integration_tests/build/test_clippy.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"{}-unknown-linux-gnu".format(MACHINE),
1414
"{}-unknown-linux-musl".format(MACHINE),
1515
]
16+
CLIPPY_CFG = ["ptr_as_ptr", "undocumented_unsafe_blocks"]
1617

1718

1819
@pytest.mark.parametrize("target", TARGETS)
@@ -22,6 +23,8 @@ def test_rust_clippy(target):
2223
2324
@type: build
2425
"""
25-
utils.run_cmd(
26-
"cargo clippy --target {} --all --profile test" " -- -D warnings".format(target)
27-
)
26+
cmd = "cargo clippy --target {} --all --profile test" " --".format(target)
27+
for clippy_rule in CLIPPY_CFG:
28+
cmd += " -D clippy::{}".format(clippy_rule)
29+
cmd += " -D warnings"
30+
utils.run_cmd(cmd)

0 commit comments

Comments
 (0)