Skip to content

Commit cfb0272

Browse files
Sergii Glushchenkoandreeaflorescu
authored andcommitted
Fix warnings and adjust test coverage
Signed-off-by: Sergii Glushchenko <[email protected]>
1 parent f1292f8 commit cfb0272

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

coverage_config_x86_64.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"coverage_score": 87.4,
2+
"coverage_score": 87.1,
33
"exclude_path": "",
44
"crate_features": ""
55
}

src/fam.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub enum Error {
3535

3636
/// Trait for accessing properties of C defined FAM structures.
3737
///
38+
/// # Safety
39+
///
3840
/// This is unsafe due to the number of constraints that aren't checked:
3941
/// * the implementer should be a POD
4042
/// * the implementor should contain a flexible array member of elements of type `Entry`

src/linux/poll.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,10 @@ mod tests {
997997
};
998998

999999
assert_eq!(ev.token(), 0x10);
1000-
assert_eq!(ev.readable(), true);
1001-
assert_eq!(ev.writable(), true);
1002-
assert_eq!(ev.hungup(), true);
1003-
assert_eq!(ev.has_error(), true);
1000+
assert!(ev.readable());
1001+
assert!(ev.writable());
1002+
assert!(ev.hungup());
1003+
assert!(ev.has_error());
10041004
assert_eq!(
10051005
ev.raw_events(),
10061006
(EPOLLIN | EPOLLERR | EPOLLOUT | EPOLLHUP) as u32

src/linux/sock_ctrl_msg.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ impl ScmSocket for UnixStream {
426426
/// Trait for types that can be converted into an `iovec` that can be referenced by a syscall for
427427
/// the lifetime of this object.
428428
///
429+
/// # Safety
430+
///
429431
/// This is marked unsafe because the implementation must ensure that the returned pointer and size
430432
/// is valid and that the lifetime of the returned pointer is at least that of the trait object.
431433
pub unsafe trait IntoIovec {

src/linux/timerfd.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ mod tests {
234234
fn test_from_raw_fd() {
235235
let ret = unsafe { timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC) };
236236
let tfd = unsafe { TimerFd::from_raw_fd(ret) };
237-
assert_eq!(tfd.is_armed().unwrap(), false);
237+
assert!(!tfd.is_armed().unwrap());
238238
}
239239

240240
#[test]
@@ -246,20 +246,20 @@ mod tests {
246246
#[test]
247247
fn test_one_shot() {
248248
let mut tfd = TimerFd::new().expect("failed to create timerfd");
249-
assert_eq!(tfd.is_armed().unwrap(), false);
249+
assert!(!tfd.is_armed().unwrap());
250250

251251
let dur = Duration::from_millis(200);
252252
let now = Instant::now();
253253
tfd.reset(dur, None).expect("failed to arm timer");
254254

255-
assert_eq!(tfd.is_armed().unwrap(), true);
255+
assert!(tfd.is_armed().unwrap());
256256

257257
let count = tfd.wait().expect("unable to wait for timer");
258258

259259
assert_eq!(count, 1);
260260
assert!(now.elapsed() >= dur);
261261
tfd.clear().expect("unable to clear the timer");
262-
assert_eq!(tfd.is_armed().unwrap(), false);
262+
assert!(!tfd.is_armed().unwrap());
263263
}
264264

265265
#[test]
@@ -275,6 +275,6 @@ mod tests {
275275
let count = tfd.wait().expect("unable to wait for timer");
276276
assert!(count >= 5, "count = {}", count);
277277
tfd.clear().expect("unable to clear the timer");
278-
assert_eq!(tfd.is_armed().unwrap(), false);
278+
assert!(!tfd.is_armed().unwrap());
279279
}
280280
}

src/unix/terminal.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ fn set_flags(fd: RawFd, flags: c_int) -> Result<()> {
6464
/// Trait for file descriptors that are TTYs, according to
6565
/// [`isatty`](http://man7.org/linux/man-pages/man3/isatty.3.html).
6666
///
67+
/// # Safety
68+
///
6769
/// This is marked unsafe because the implementation must ensure that the returned
6870
/// RawFd is a valid fd and that the lifetime of the returned fd is at least that
6971
/// of the trait object.

0 commit comments

Comments
 (0)