Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sys/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ pub unsafe fn mmap<F: AsFd>(
libc::mmap(ptr, length.into(), prot.bits(), flags.bits(), fd, offset)
};

if ret == libc::MAP_FAILED {
if std::ptr::eq(ret, libc::MAP_FAILED) {
Err(Errno::last())
} else {
// SAFETY: `libc::mmap` returns a valid non-null pointer or `libc::MAP_FAILED`, thus `ret`
Expand Down Expand Up @@ -471,7 +471,7 @@ pub unsafe fn mmap_anonymous(
libc::mmap(ptr, length.into(), prot.bits(), flags.bits(), -1, 0)
};

if ret == libc::MAP_FAILED {
if std::ptr::eq(ret, libc::MAP_FAILED) {
Err(Errno::last())
} else {
// SAFETY: `libc::mmap` returns a valid non-null pointer or `libc::MAP_FAILED`, thus `ret`
Expand Down Expand Up @@ -520,7 +520,7 @@ pub unsafe fn mremap(
)
};

if ret == libc::MAP_FAILED {
if std::ptr::eq(ret, libc::MAP_FAILED) {
Err(Errno::last())
} else {
// SAFETY: `libc::mremap` returns a valid non-null pointer or `libc::MAP_FAILED`, thus `ret`
Expand Down
2 changes: 2 additions & 0 deletions test/sys/test_sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ fn test_so_type_unknown() {
use nix::errno::Errno;

require_capability!("test_so_type", CAP_NET_RAW);
// SOCK_PACKET is deprecated, but since it is used for testing here, we allow it
#[allow(deprecated)]
let raw_fd = unsafe { libc::socket(libc::AF_PACKET, libc::SOCK_PACKET, 0) };
assert!(raw_fd >= 0, "Error opening socket: {}", nix::Error::last());
let sockfd = unsafe { OwnedFd::from_raw_fd(raw_fd) };
Expand Down