Skip to content

Commit

Permalink
Run a round of clippy to fix CI
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
  • Loading branch information
SUPERCILEX authored and rtzoeller committed Dec 2, 2022
1 parent 3fd7fb1 commit 3731613
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions test/test_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fn flags() -> OFlag {
#[allow(clippy::unnecessary_sort_by)] // False positive
fn read() {
let tmp = tempdir().unwrap();
File::create(&tmp.path().join("foo")).unwrap();
::std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap();
File::create(tmp.path().join("foo")).unwrap();
std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap();
let mut dir = Dir::open(tmp.path(), flags(), Mode::empty()).unwrap();
let mut entries: Vec<_> = dir.iter().map(|e| e.unwrap()).collect();
entries.sort_by(|a, b| a.file_name().cmp(b.file_name()));
Expand Down
8 changes: 4 additions & 4 deletions test/test_fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn test_renameat() {
let old_dir = tempfile::tempdir().unwrap();
let old_dirfd = open(old_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
let old_path = old_dir.path().join("old");
File::create(&old_path).unwrap();
File::create(old_path).unwrap();
let new_dir = tempfile::tempdir().unwrap();
let new_dirfd = open(new_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
renameat(Some(old_dirfd), "old", Some(new_dirfd), "new").unwrap();
Expand All @@ -86,7 +86,7 @@ fn test_renameat2_behaves_like_renameat_with_no_flags() {
let old_dir = tempfile::tempdir().unwrap();
let old_dirfd = open(old_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
let old_path = old_dir.path().join("old");
File::create(&old_path).unwrap();
File::create(old_path).unwrap();
let new_dir = tempfile::tempdir().unwrap();
let new_dirfd = open(new_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
renameat2(
Expand Down Expand Up @@ -174,11 +174,11 @@ fn test_renameat2_noreplace() {
let old_dir = tempfile::tempdir().unwrap();
let old_dirfd = open(old_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
let old_path = old_dir.path().join("old");
File::create(&old_path).unwrap();
File::create(old_path).unwrap();
let new_dir = tempfile::tempdir().unwrap();
let new_dirfd = open(new_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
let new_path = new_dir.path().join("new");
File::create(&new_path).unwrap();
File::create(new_path).unwrap();
assert_eq!(
renameat2(
Some(old_dirfd),
Expand Down
10 changes: 6 additions & 4 deletions test/test_kmod/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ fn compile_kernel_module() -> (PathBuf, String, TempDir) {

copy(
"test/test_kmod/hello_mod/hello.c",
&tmp_dir.path().join("hello.c"),
).expect("unable to copy hello.c to temporary build directory");
tmp_dir.path().join("hello.c"),
)
.expect("unable to copy hello.c to temporary build directory");
copy(
"test/test_kmod/hello_mod/Makefile",
&tmp_dir.path().join("Makefile"),
).expect("unable to copy Makefile to temporary build directory");
tmp_dir.path().join("Makefile"),
)
.expect("unable to copy Makefile to temporary build directory");

let status = Command::new("make")
.current_dir(tmp_dir.path())
Expand Down
10 changes: 5 additions & 5 deletions test/test_unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ fn test_linkat_file() {
let newfilepath = tempdir.path().join(newfilename);

// Create file
File::create(&oldfilepath).unwrap();
File::create(oldfilepath).unwrap();

// Get file descriptor for base directory
let dirfd = fcntl::open(tempdir.path(), fcntl::OFlag::empty(), stat::Mode::empty()).unwrap();
Expand All @@ -848,7 +848,7 @@ fn test_linkat_olddirfd_none() {
let newfilepath = tempdir_newfile.path().join(newfilename);

// Create file
File::create(&oldfilepath).unwrap();
File::create(oldfilepath).unwrap();

// Get file descriptor for base directory of new file
let dirfd = fcntl::open(tempdir_newfile.path(), fcntl::OFlag::empty(), stat::Mode::empty()).unwrap();
Expand All @@ -873,7 +873,7 @@ fn test_linkat_newdirfd_none() {
let newfilepath = tempdir_newfile.path().join(newfilename);

// Create file
File::create(&oldfilepath).unwrap();
File::create(oldfilepath).unwrap();

// Get file descriptor for base directory of old file
let dirfd = fcntl::open(tempdir_oldfile.path(), fcntl::OFlag::empty(), stat::Mode::empty()).unwrap();
Expand Down Expand Up @@ -967,7 +967,7 @@ fn test_unlinkat_dir_noremovedir() {
let dirpath = tempdir.path().join(dirname);

// Create dir
DirBuilder::new().recursive(true).create(&dirpath).unwrap();
DirBuilder::new().recursive(true).create(dirpath).unwrap();

// Get file descriptor for base directory
let dirfd = fcntl::open(tempdir.path(), fcntl::OFlag::empty(), stat::Mode::empty()).unwrap();
Expand Down Expand Up @@ -1053,7 +1053,7 @@ fn test_setfsuid() {
let file = tempfile::NamedTempFile::new_in("/var/tmp").unwrap();
let temp_path = file.into_temp_path();
dbg!(&temp_path);
let temp_path_2 = (&temp_path).to_path_buf();
let temp_path_2 = temp_path.to_path_buf();
let mut permissions = fs::metadata(&temp_path).unwrap().permissions();
permissions.set_mode(0o640);

Expand Down

0 comments on commit 3731613

Please sign in to comment.