Skip to content

Commit ee297a1

Browse files
authored
Miscellaneous clippy fixes. (#928)
1 parent b28c5a8 commit ee297a1

33 files changed

+328
-331
lines changed

src/backend/libc/fs/dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,5 +393,5 @@ fn dir_iterator_handles_io_errors() {
393393
}
394394

395395
assert!(matches!(dir.next(), Some(Err(_))));
396-
assert!(matches!(dir.next(), None));
396+
assert!(dir.next().is_none());
397397
}

src/backend/linux_raw/arch/x86.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ pub(in crate::backend) unsafe fn indirect_syscall5(
148148
// clobbered as the return value anyway.
149149
asm!(
150150
"push esi",
151-
"push DWORD PTR [eax + 0]",
152-
"mov esi, DWORD PTR [eax + 4]",
153-
"mov eax, DWORD PTR [eax + 8]",
154-
"call DWORD PTR [esp]",
151+
"push [eax + 0]",
152+
"mov esi, [eax + 4]",
153+
"mov eax, [eax + 8]",
154+
"call [esp]",
155155
"pop esi",
156156
"pop esi",
157157
inout("eax") &[callee as _, a3.to_asm(), nr.to_asm()] => r0,
@@ -186,11 +186,11 @@ pub(in crate::backend) unsafe fn indirect_syscall6(
186186
asm!(
187187
"push ebp",
188188
"push esi",
189-
"push DWORD PTR [eax + 0]",
190-
"mov esi, DWORD PTR [eax + 4]",
191-
"mov ebp, DWORD PTR [eax + 8]",
192-
"mov eax, DWORD PTR [eax + 12]",
193-
"call DWORD PTR [esp]",
189+
"push [eax + 0]",
190+
"mov esi, [eax + 4]",
191+
"mov ebp, [eax + 8]",
192+
"mov eax, [eax + 12]",
193+
"call [esp]",
194194
"pop esi",
195195
"pop esi",
196196
"pop ebp",
@@ -441,9 +441,9 @@ pub(in crate::backend) unsafe fn syscall6(
441441
asm!(
442442
"push ebp",
443443
"push esi",
444-
"mov esi, DWORD PTR [eax + 0]",
445-
"mov ebp, DWORD PTR [eax + 4]",
446-
"mov eax, DWORD PTR [eax + 8]",
444+
"mov esi, [eax + 0]",
445+
"mov ebp, [eax + 4]",
446+
"mov eax, [eax + 8]",
447447
"int $$0x80",
448448
"pop esi",
449449
"pop ebp",
@@ -472,9 +472,9 @@ pub(in crate::backend) unsafe fn syscall6_readonly(
472472
asm!(
473473
"push ebp",
474474
"push esi",
475-
"mov esi, DWORD PTR [eax + 0]",
476-
"mov ebp, DWORD PTR [eax + 4]",
477-
"mov eax, DWORD PTR [eax + 8]",
475+
"mov esi, [eax + 0]",
476+
"mov ebp, [eax + 4]",
477+
"mov eax, [eax + 8]",
478478
"int $$0x80",
479479
"pop esi",
480480
"pop ebp",

src/backend/linux_raw/fs/dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,5 @@ fn dir_iterator_handles_io_errors() {
292292
crate::io::dup2(&file_fd, &mut dir.fd).unwrap();
293293

294294
assert!(matches!(dir.next(), Some(Err(_))));
295-
assert!(matches!(dir.next(), None));
295+
assert!(dir.next().is_none());
296296
}

src/backend/linux_raw/param/auxv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ impl Iterator for AuxFile {
471471
Ok(0) => panic!("unexpected end of auxv file"),
472472
Ok(n) => slice = &mut slice[n..],
473473
Err(crate::io::Errno::INTR) => continue,
474-
Err(err) => Err(err).unwrap(),
474+
Err(err) => panic!("{:?}", err),
475475
}
476476
}
477477
Some(unsafe { read_unaligned(buf.as_ptr().cast()) })

tests/event/eventfd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn test_eventfd() {
1010
Ok(efd) => efd,
1111
#[cfg(target_os = "freebsd")]
1212
Err(rustix::io::Errno::NOSYS) => return, // FreeBSD 12 lacks `eventfd`
13-
Err(e) => Err(e).unwrap(),
13+
Err(err) => panic!("{:?}", err),
1414
};
1515

1616
let child = thread::spawn(move || {

tests/fs/chmodat.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ fn test_chmod() {
66
let tmp = tempfile::tempdir().unwrap();
77

88
let _ = open(
9-
tmp.path().join("foo"),
9+
tmp.path().join("file"),
1010
OFlags::CREATE | OFlags::WRONLY,
1111
Mode::RWXU,
1212
)
1313
.unwrap();
14-
symlink(tmp.path().join("foo"), tmp.path().join("link")).unwrap();
14+
symlink(tmp.path().join("file"), tmp.path().join("link")).unwrap();
1515

16-
let before = stat(tmp.path().join("foo")).unwrap();
16+
let before = stat(tmp.path().join("file")).unwrap();
1717
assert_ne!(before.st_mode as u64 & libc::S_IRWXU as u64, 0);
1818

19-
chmod(tmp.path().join("foo"), Mode::empty()).unwrap();
19+
chmod(tmp.path().join("file"), Mode::empty()).unwrap();
2020

21-
let after = stat(tmp.path().join("foo")).unwrap();
21+
let after = stat(tmp.path().join("file")).unwrap();
2222
assert_eq!(after.st_mode as u64 & libc::S_IRWXU as u64, 0);
2323

24-
chmod(tmp.path().join("foo"), Mode::RWXU).unwrap();
24+
chmod(tmp.path().join("file"), Mode::RWXU).unwrap();
2525

26-
let reverted = stat(tmp.path().join("foo")).unwrap();
26+
let reverted = stat(tmp.path().join("file")).unwrap();
2727
assert_ne!(reverted.st_mode as u64 & libc::S_IRWXU as u64, 0);
2828
}
2929

@@ -35,25 +35,25 @@ fn test_chmodat() {
3535
let tmp = tempfile::tempdir().unwrap();
3636
let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::RWXU).unwrap();
3737

38-
let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RWXU).unwrap();
39-
symlinkat("foo", &dir, "link").unwrap();
38+
let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RWXU).unwrap();
39+
symlinkat("file", &dir, "link").unwrap();
4040

4141
match chmodat(&dir, "link", Mode::empty(), AtFlags::SYMLINK_NOFOLLOW) {
4242
Ok(()) => (),
4343
Err(rustix::io::Errno::OPNOTSUPP) => return,
44-
Err(e) => Err(e).unwrap(),
44+
Err(err) => panic!("{:?}", err),
4545
}
4646

47-
let before = statat(&dir, "foo", AtFlags::empty()).unwrap();
47+
let before = statat(&dir, "file", AtFlags::empty()).unwrap();
4848
assert_ne!(before.st_mode as u64 & libc::S_IRWXU as u64, 0);
4949

50-
chmodat(&dir, "foo", Mode::empty(), AtFlags::empty()).unwrap();
50+
chmodat(&dir, "file", Mode::empty(), AtFlags::empty()).unwrap();
5151

52-
let after = statat(&dir, "foo", AtFlags::empty()).unwrap();
52+
let after = statat(&dir, "file", AtFlags::empty()).unwrap();
5353
assert_eq!(after.st_mode as u64 & libc::S_IRWXU as u64, 0);
5454

55-
chmodat(&dir, "foo", Mode::RWXU, AtFlags::empty()).unwrap();
55+
chmodat(&dir, "file", Mode::RWXU, AtFlags::empty()).unwrap();
5656

57-
let reverted = statat(&dir, "foo", AtFlags::empty()).unwrap();
57+
let reverted = statat(&dir, "file", AtFlags::empty()).unwrap();
5858
assert_ne!(reverted.st_mode as u64 & libc::S_IRWXU as u64, 0);
5959
}

tests/fs/dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn dir_iterator_handles_dir_removal() {
8282
drop(tmp);
8383

8484
let mut dir = rustix::fs::Dir::read_from(&fd).unwrap();
85-
assert!(matches!(dir.next(), None));
85+
assert!(dir.next().is_none());
8686
}
8787

8888
// Like `dir_iterator_handles_dir_removal`, but close the directory after
@@ -105,5 +105,5 @@ fn dir_iterator_handles_dir_removal_after_open() {
105105
// Drop the `TempDir`, which deletes the directory.
106106
drop(tmp);
107107

108-
assert!(matches!(dir.next(), None));
108+
assert!(dir.next().is_none());
109109
}

tests/fs/fcntl.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ fn test_fcntl_apple() {
2323

2424
let tmp = tempfile::tempdir().unwrap();
2525
let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
26-
let foo = openat(
26+
let file = openat(
2727
&dir,
28-
"foo",
28+
"file",
2929
OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC,
3030
Mode::RUSR | Mode::WUSR,
3131
)
@@ -34,13 +34,13 @@ fn test_fcntl_apple() {
3434
// It appears `fsync_rdadvise` at offset 0 length 0 doesn't work if the
3535
// file has size zero, so write in some bytes.
3636
assert_eq!(
37-
rustix::io::write(&foo, b"data").expect("write"),
37+
rustix::io::write(&file, b"data").expect("write"),
3838
4,
3939
"write failed"
4040
);
4141

42-
rustix::fs::fcntl_rdadvise(&foo, 0, 0).unwrap();
43-
rustix::fs::fcntl_fullfsync(&foo).unwrap();
44-
rustix::fs::fcntl_nocache(&foo, true).unwrap();
45-
rustix::fs::fcntl_global_nocache(&foo, true).unwrap();
42+
rustix::fs::fcntl_rdadvise(&file, 0, 0).unwrap();
43+
rustix::fs::fcntl_fullfsync(&file).unwrap();
44+
rustix::fs::fcntl_nocache(&file, true).unwrap();
45+
rustix::fs::fcntl_global_nocache(&file, true).unwrap();
4646
}

tests/fs/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn test_file() {
3333
)
3434
}
3535
}
36-
Err(err) => Err(err).unwrap(),
36+
Err(err) => panic!("{:?}", err),
3737
}
3838

3939
// Check that `SYMLINK_FOLLOW` is rejected. Except on NetBSD which seems

tests/fs/futimens.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ fn test_futimens() {
66
let tmp = tempfile::tempdir().unwrap();
77
let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
88

9-
let foo = openat(
9+
let file = openat(
1010
&dir,
11-
"foo",
11+
"file",
1212
OFlags::CREATE | OFlags::WRONLY | OFlags::CLOEXEC,
1313
Mode::empty(),
1414
)
@@ -24,9 +24,9 @@ fn test_futimens() {
2424
tv_nsec: 47000,
2525
},
2626
};
27-
futimens(&foo, &times).unwrap();
27+
futimens(&file, &times).unwrap();
2828

29-
let after = fstat(&foo).unwrap();
29+
let after = fstat(&file).unwrap();
3030

3131
assert_eq!(times.last_modification.tv_sec as u64, after.st_mtime as u64);
3232
#[cfg(not(target_os = "netbsd"))]

0 commit comments

Comments
 (0)