diff options
| author | bors <bors@rust-lang.org> | 2020-07-23 08:56:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-07-23 08:56:45 +0000 |
| commit | 2bbfa02b1b15974d5772b520aa027bf79f8c248e (patch) | |
| tree | e7e74cc74874cf154f4b5c5ea97cf04c132c982d /src/libstd/sys/vxworks | |
| parent | fcac11993ca055bbdc7683a2f6ed7b88a838fb0f (diff) | |
| parent | 8f02f2c1abd6c3fbd3053da5bb6759a4698a949e (diff) | |
| download | rust-2bbfa02b1b15974d5772b520aa027bf79f8c248e.tar.gz rust-2bbfa02b1b15974d5772b520aa027bf79f8c248e.zip | |
Auto merge of #74667 - Manishearth:rollup-s6k59sw, r=Manishearth
Rollup of 8 pull requests Successful merges: - #74141 (libstd/libcore: fix various typos) - #74490 (add a Backtrace::disabled function) - #74548 (one more Path::with_extension example, to demonstrate behavior) - #74587 (Prefer constant over function) - #74606 (Remove Linux workarounds for missing CLOEXEC support) - #74637 (Make str point to primitive page) - #74654 (require type defaults to be after const generic parameters) - #74659 (Improve codegen for unchecked float casts on wasm) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd/sys/vxworks')
| -rw-r--r-- | src/libstd/sys/vxworks/fd.rs | 20 | ||||
| -rw-r--r-- | src/libstd/sys/vxworks/time.rs | 2 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/libstd/sys/vxworks/fd.rs b/src/libstd/sys/vxworks/fd.rs index 7fa86f0db04..ea186846929 100644 --- a/src/libstd/sys/vxworks/fd.rs +++ b/src/libstd/sys/vxworks/fd.rs @@ -13,12 +13,10 @@ pub struct FileDesc { fd: c_int, } -fn max_len() -> usize { - // The maximum read limit on most posix-like systems is `SSIZE_MAX`, - // with the man page quoting that if the count of bytes to read is - // greater than `SSIZE_MAX` the result is "unspecified". - <ssize_t>::MAX as usize -} +// The maximum read limit on most POSIX-like systems is `SSIZE_MAX`, +// with the man page quoting that if the count of bytes to read is +// greater than `SSIZE_MAX` the result is "unspecified". +const READ_LIMIT: usize = ssize_t::MAX as usize; impl FileDesc { pub fn new(fd: c_int) -> FileDesc { @@ -29,7 +27,7 @@ impl FileDesc { self.fd } - /// Extracts the actual filedescriptor without closing it. + /// Extracts the actual file descriptor without closing it. pub fn into_raw(self) -> c_int { let fd = self.fd; mem::forget(self); @@ -38,7 +36,7 @@ impl FileDesc { pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { let ret = cvt(unsafe { - libc::read(self.fd, buf.as_mut_ptr() as *mut c_void, cmp::min(buf.len(), max_len())) + libc::read(self.fd, buf.as_mut_ptr() as *mut c_void, cmp::min(buf.len(), READ_LIMIT)) })?; Ok(ret as usize) } @@ -79,7 +77,7 @@ impl FileDesc { cvt_pread( self.fd, buf.as_mut_ptr() as *mut c_void, - cmp::min(buf.len(), max_len()), + cmp::min(buf.len(), READ_LIMIT), offset as i64, ) .map(|n| n as usize) @@ -88,7 +86,7 @@ impl FileDesc { pub fn write(&self, buf: &[u8]) -> io::Result<usize> { let ret = cvt(unsafe { - libc::write(self.fd, buf.as_ptr() as *const c_void, cmp::min(buf.len(), max_len())) + libc::write(self.fd, buf.as_ptr() as *const c_void, cmp::min(buf.len(), READ_LIMIT)) })?; Ok(ret as usize) } @@ -124,7 +122,7 @@ impl FileDesc { cvt_pwrite( self.fd, buf.as_ptr() as *const c_void, - cmp::min(buf.len(), max_len()), + cmp::min(buf.len(), READ_LIMIT), offset as i64, ) .map(|n| n as usize) diff --git a/src/libstd/sys/vxworks/time.rs b/src/libstd/sys/vxworks/time.rs index 8365c9ee9c9..8f46f4d284f 100644 --- a/src/libstd/sys/vxworks/time.rs +++ b/src/libstd/sys/vxworks/time.rs @@ -1,6 +1,6 @@ use crate::cmp::Ordering; use crate::time::Duration; -use ::core::hash::{Hash, Hasher}; +use core::hash::{Hash, Hasher}; pub use self::inner::{Instant, SystemTime, UNIX_EPOCH}; use crate::convert::TryInto; |
