Skip to content

Commit 5ddda6e

Browse files
Alexandra Iordachelauralt
authored andcommitted
fix (and ignore in tests) clippy lints...
...and add missing copyrights Signed-off-by: Alexandra Iordache <aghecen@amazon.com>
1 parent fa7e0cc commit 5ddda6e

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

src/backend/condition.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ impl SeccompCondition {
299299
}
300300

301301
#[cfg(test)]
302+
#[allow(clippy::undocumented_unsafe_blocks)]
302303
mod tests {
303304
use super::*;
304305
#[test]

src/backend/rule.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl From<SeccompRule> for BpfProgram {
115115
// If the nr of statements ever overflows `usize`, the rust vector allocation would
116116
// anyway fail.
117117
.checked_mul(CONDITION_MAX_LEN as usize)
118-
.unwrap() as usize,
118+
.unwrap(),
119119
);
120120
let mut offset = 1;
121121

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ pub fn apply_filter(bpf_filter: BpfProgramRef) -> Result<()> {
297297
return Err(Error::EmptyFilter);
298298
}
299299

300+
// SAFETY:
300301
// Safe because syscall arguments are valid.
301302
let rc = unsafe { libc::prctl(libc::PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) };
302303
if rc != 0 {
@@ -309,6 +310,7 @@ pub fn apply_filter(bpf_filter: BpfProgramRef) -> Result<()> {
309310
};
310311
let bpf_prog_ptr = &bpf_prog as *const sock_fprog;
311312

313+
// SAFETY:
312314
// Safe because the kernel performs a `copy_from_user` on the filter and leaves the memory
313315
// untouched. We can therefore use a reference to the BpfProgram, without needing ownership.
314316
let rc = unsafe {

tests/integration_tests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
3+
4+
#![allow(clippy::undocumented_unsafe_blocks)]
5+
16
use std::collections::BTreeMap;
27

38
use seccompiler::SeccompCmpArgLen::*;

tests/json.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
3+
14
#![cfg(feature = "json")]
5+
#![allow(clippy::undocumented_unsafe_blocks)]
26

37
use seccompiler::{apply_filter, compile_from_json, BpfProgram};
48
use std::convert::TryInto;

0 commit comments

Comments
 (0)