From 3eafb3b0b937f7afd5d1ef1e65e81c1648225788 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 7 Apr 2020 21:52:04 -0600 Subject: [PATCH] FD_ISSET: take a *const fd_set instead of *mut fd_set FD_ISSET does not modify its fd_set argument, so it may as well take a const pointer. AFAICT the only reason to take a *mut pointer is because the Linux man page documents it that way (though since glibc implements it as a macro, the constedness is undefined). But since libc implements it directly rather than calling a (nonexistent on most platforms) C function, we're defining the API ourselves. --- src/fuchsia/mod.rs | 2 +- src/unix/bsd/mod.rs | 2 +- src/unix/haiku/mod.rs | 2 +- src/unix/linux_like/mod.rs | 2 +- src/unix/newlib/mod.rs | 2 +- src/unix/redox/mod.rs | 2 +- src/unix/solarish/mod.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 4300338ba0b03..6ba5fd56e7735 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3158,7 +3158,7 @@ f! { return } - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { let fd = fd as usize; let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 156d3d60760ff..df4cd40c3ab5b 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -541,7 +541,7 @@ f! { return } - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index d88baec69a3af..f5cbc78426ecb 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1295,7 +1295,7 @@ f! { return } - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { let fd = fd as usize; let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 48798849d04f4..7f6afd5f2af64 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1397,7 +1397,7 @@ f! { return } - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { let fd = fd as usize; let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 6e87983fe53a4..59256b0c206ce 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -558,7 +558,7 @@ f! { return } - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 1601a8adfb2b5..05c7fad45496d 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -898,7 +898,7 @@ f! { return } - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { let fd = fd as usize; let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 03879bf1069ff..96f6edc6bfe1e 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2171,7 +2171,7 @@ f! { return } - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { + pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0