Skip to content

Commit bd1ae01

Browse files
committed
Add more safety comments.
1 parent 5bc0a9e commit bd1ae01

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/inherited.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ mod test {
157157
}
158158

159159
fn is_fd_opened(raw_fd: RawFd) -> bool {
160+
// SAFETY: F_GETFD doesn't take any other parameters, and is safe even on an invalid file
161+
// descriptor.
160162
unsafe { libc::fcntl(raw_fd, libc::F_GETFD) != -1 }
161163
}
162164

@@ -270,6 +272,7 @@ mod test {
270272
let fixture = Fixture::setup(2).unwrap();
271273
let f = fixture.fds[0];
272274

275+
// SAFETY: 0 is a valid parameter for F_SETFD.
273276
let res = unsafe { libc::fcntl(f.as_raw_fd(), libc::F_SETFD, 0) };
274277
assert_ne!(res, -1);
275278

0 commit comments

Comments
 (0)