summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryant Mairs <bryantmairs@google.com>2017-12-15 14:58:02 -0800
committerBryant Mairs <bryantmairs@google.com>2017-12-20 07:05:04 -0800
commitd8c538525807253aea6c64fc4bdcdb8a6e24f78d (patch)
treee7f489787ca2b3b08208bdbdd9720dde7c3df63a
parent4bad9bf9b9bb08d29511f060a3adae7453573a72 (diff)
downloadnix-d8c538525807253aea6c64fc4bdcdb8a6e24f78d.zip
Make numeric literals easier to read
-rw-r--r--src/sys/event.rs4
-rw-r--r--src/sys/ioctl/platform/bsd.rs6
-rw-r--r--test/sys/test_ioctl.rs60
-rw-r--r--test/sys/test_socket.rs2
-rw-r--r--test/sys/test_sockopt.rs2
5 files changed, 37 insertions, 37 deletions
diff --git a/src/sys/event.rs b/src/sys/event.rs
index e63fe502..4d5d1880 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -312,13 +312,13 @@ pub fn ev_set(ev: &mut KEvent,
fn test_struct_kevent() {
let udata : intptr_t = 12345;
- let expected = libc::kevent{ident: 0xdeadbeef,
+ let expected = libc::kevent{ident: 0xdead_beef,
filter: libc::EVFILT_READ,
flags: libc::EV_ONESHOT | libc::EV_ADD,
fflags: libc::NOTE_CHILD | libc::NOTE_EXIT,
data: 0x1337,
udata: udata as type_of_udata};
- let actual = KEvent::new(0xdeadbeef,
+ let actual = KEvent::new(0xdead_beef,
EventFilter::EVFILT_READ,
EventFlag::EV_ONESHOT | EventFlag::EV_ADD,
FilterFlag::NOTE_CHILD | FilterFlag::NOTE_EXIT,
diff --git a/src/sys/ioctl/platform/bsd.rs b/src/sys/ioctl/platform/bsd.rs
index ea39da3d..a36808d7 100644
--- a/src/sys/ioctl/platform/bsd.rs
+++ b/src/sys/ioctl/platform/bsd.rs
@@ -5,11 +5,11 @@ pub type ioctl_num_type = ::libc::c_ulong;
mod consts {
use ::sys::ioctl::platform::ioctl_num_type;
#[doc(hidden)]
- pub const VOID: ioctl_num_type = 0x20000000;
+ pub const VOID: ioctl_num_type = 0x2000_0000;
#[doc(hidden)]
- pub const OUT: ioctl_num_type = 0x40000000;
+ pub const OUT: ioctl_num_type = 0x4000_0000;
#[doc(hidden)]
- pub const IN: ioctl_num_type = 0x80000000;
+ pub const IN: ioctl_num_type = 0x8000_0000;
#[doc(hidden)]
pub const INOUT: ioctl_num_type = (IN|OUT);
#[doc(hidden)]
diff --git a/test/sys/test_ioctl.rs b/test/sys/test_ioctl.rs
index 1ed4a4b4..26ff42f8 100644
--- a/test/sys/test_ioctl.rs
+++ b/test/sys/test_ioctl.rs
@@ -87,22 +87,22 @@ mod linux {
#[test]
fn test_op_none() {
if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){
- assert_eq!(io!(b'q', 10), 0x2000710A);
- assert_eq!(io!(b'a', 255), 0x200061FF);
+ assert_eq!(io!(b'q', 10), 0x2000_710A);
+ assert_eq!(io!(b'a', 255), 0x2000_61FF);
} else {
- assert_eq!(io!(b'q', 10), 0x0000710A);
- assert_eq!(io!(b'a', 255), 0x000061FF);
+ assert_eq!(io!(b'q', 10), 0x0000_710A);
+ assert_eq!(io!(b'a', 255), 0x0000_61FF);
}
}
#[test]
fn test_op_write() {
if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){
- assert_eq!(iow!(b'z', 10, 1), 0x80017A0A);
- assert_eq!(iow!(b'z', 10, 512), 0x82007A0A);
+ assert_eq!(iow!(b'z', 10, 1), 0x8001_7A0A);
+ assert_eq!(iow!(b'z', 10, 512), 0x8200_7A0A);
} else {
- assert_eq!(iow!(b'z', 10, 1), 0x40017A0A);
- assert_eq!(iow!(b'z', 10, 512), 0x42007A0A);
+ assert_eq!(iow!(b'z', 10, 1), 0x4001_7A0A);
+ assert_eq!(iow!(b'z', 10, 512), 0x4200_7A0A);
}
}
@@ -110,9 +110,9 @@ mod linux {
#[test]
fn test_op_write_64() {
if cfg!(any(target_arch = "mips64", target_arch="powerpc64")){
- assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x80007A0A);
+ assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A);
} else {
- assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x40007A0A);
+ assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A);
}
}
@@ -120,11 +120,11 @@ mod linux {
#[test]
fn test_op_read() {
if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){
- assert_eq!(ior!(b'z', 10, 1), 0x40017A0A);
- assert_eq!(ior!(b'z', 10, 512), 0x42007A0A);
+ assert_eq!(ior!(b'z', 10, 1), 0x4001_7A0A);
+ assert_eq!(ior!(b'z', 10, 512), 0x4200_7A0A);
} else {
- assert_eq!(ior!(b'z', 10, 1), 0x80017A0A);
- assert_eq!(ior!(b'z', 10, 512), 0x82007A0A);
+ assert_eq!(ior!(b'z', 10, 1), 0x8001_7A0A);
+ assert_eq!(ior!(b'z', 10, 512), 0x8200_7A0A);
}
}
@@ -132,22 +132,22 @@ mod linux {
#[test]
fn test_op_read_64() {
if cfg!(any(target_arch = "mips64", target_arch="powerpc64")){
- assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x40007A0A);
+ assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A);
} else {
- assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x80007A0A);
+ assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A);
}
}
#[test]
fn test_op_read_write() {
- assert_eq!(iorw!(b'z', 10, 1), 0xC0017A0A);
- assert_eq!(iorw!(b'z', 10, 512), 0xC2007A0A);
+ assert_eq!(iorw!(b'z', 10, 1), 0xC001_7A0A);
+ assert_eq!(iorw!(b'z', 10, 512), 0xC200_7A0A);
}
#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_read_write_64() {
- assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC0007A0A);
+ assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC000_7A0A);
}
}
@@ -160,44 +160,44 @@ mod linux {
mod bsd {
#[test]
fn test_op_none() {
- assert_eq!(io!(b'q', 10), 0x2000710A);
- assert_eq!(io!(b'a', 255), 0x200061FF);
+ assert_eq!(io!(b'q', 10), 0x2000_710A);
+ assert_eq!(io!(b'a', 255), 0x2000_61FF);
}
#[test]
fn test_op_write() {
- assert_eq!(iow!(b'z', 10, 1), 0x80017A0A);
- assert_eq!(iow!(b'z', 10, 512), 0x82007A0A);
+ assert_eq!(iow!(b'z', 10, 1), 0x8001_7A0A);
+ assert_eq!(iow!(b'z', 10, 512), 0x8200_7A0A);
}
#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_write_64() {
- assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x80007A0A);
+ assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A);
}
#[test]
fn test_op_read() {
- assert_eq!(ior!(b'z', 10, 1), 0x40017A0A);
- assert_eq!(ior!(b'z', 10, 512), 0x42007A0A);
+ assert_eq!(ior!(b'z', 10, 1), 0x4001_7A0A);
+ assert_eq!(ior!(b'z', 10, 512), 0x4200_7A0A);
}
#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_read_64() {
- assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x40007A0A);
+ assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A);
}
#[test]
fn test_op_read_write() {
- assert_eq!(iorw!(b'z', 10, 1), 0xC0017A0A);
- assert_eq!(iorw!(b'z', 10, 512), 0xC2007A0A);
+ assert_eq!(iorw!(b'z', 10, 1), 0xC001_7A0A);
+ assert_eq!(iorw!(b'z', 10, 512), 0xC200_7A0A);
}
#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_read_write_64() {
- assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC0007A0A);
+ assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC000_7A0A);
}
}
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs
index d29b2ecb..a997fbca 100644
--- a/test/sys/test_socket.rs
+++ b/test/sys/test_socket.rs
@@ -13,7 +13,7 @@ pub fn test_inetv4_addr_to_sock_addr() {
match addr {
InetAddr::V4(addr) => {
- let ip: u32 = 0x7f000001;
+ let ip: u32 = 0x7f00_0001;
let port: u16 = 3000;
assert_eq!(addr.sin_addr.s_addr, ip.to_be());
diff --git a/test/sys/test_sockopt.rs b/test/sys/test_sockopt.rs
index 81db8248..a38657c1 100644
--- a/test/sys/test_sockopt.rs
+++ b/test/sys/test_sockopt.rs
@@ -5,7 +5,7 @@ use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, S
fn test_so_buf() {
let fd = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), SockProtocol::Udp)
.unwrap();
- let bufsize: usize = thread_rng().gen_range(4096, 131072);
+ let bufsize: usize = thread_rng().gen_range(4096, 131_072);
setsockopt(fd, sockopt::SndBuf, &bufsize).unwrap();
let actual = getsockopt(fd, sockopt::SndBuf).unwrap();
assert!(actual >= bufsize);