Skip to content

Commit 2e6956e

Browse files
authored
chore: clippy cleanup ptr_eq (#2618)
* chore: clippy cleanup ptr_eq * chore: allow deprecated SOCK_PACKET
1 parent e4895d3 commit 2e6956e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/sys/mman.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ pub unsafe fn mmap<F: AsFd>(
439439
libc::mmap(ptr, length.into(), prot.bits(), flags.bits(), fd, offset)
440440
};
441441

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

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

523-
if ret == libc::MAP_FAILED {
523+
if std::ptr::eq(ret, libc::MAP_FAILED) {
524524
Err(Errno::last())
525525
} else {
526526
// SAFETY: `libc::mremap` returns a valid non-null pointer or `libc::MAP_FAILED`, thus `ret`

test/sys/test_sockopt.rs

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ fn test_so_type_unknown() {
241241
use nix::errno::Errno;
242242

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

0 commit comments

Comments
 (0)