From 0fd15870b9e2f899bd7b6a4c7a4646773cb1d34c Mon Sep 17 00:00:00 2001 From: Valerii Hiora Date: Sat, 3 Jan 2015 14:37:30 +0200 Subject: Update to rust master - cstr fallout - deriving -> derive - lib stabilization warnings removal --- src/errno.rs | 6 +++--- src/fcntl.rs | 5 +++-- src/mount.rs | 1 + src/sys/event.rs | 4 ++-- src/sys/mman.rs | 7 ++++--- src/sys/signal.rs | 10 +++++----- src/sys/socket.rs | 4 ++-- src/sys/stat.rs | 1 + src/sys/wait.rs | 2 +- src/unistd.rs | 7 ++++--- tests/unistd.rs | 7 ++++--- 11 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/errno.rs b/src/errno.rs index af962c39..7b846fd9 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -8,7 +8,7 @@ pub use self::consts::Errno::*; pub type SysResult = Result; -#[deriving(Clone, PartialEq, Copy)] +#[derive(Clone, PartialEq, Copy)] pub struct SysError { pub kind: Errno, } @@ -420,7 +420,7 @@ pub fn from_ffi(res: c_int) -> SysResult<()> { #[cfg(target_os = "linux")] mod consts { - #[deriving(Show, Clone, PartialEq, FromPrimitive, Copy)] + #[derive(Show, Clone, PartialEq, FromPrimitive, Copy)] pub enum Errno { UnknownErrno = 0, EPERM = 1, @@ -562,7 +562,7 @@ mod consts { #[cfg(any(target_os = "macos", target_os = "ios"))] mod consts { - #[deriving(Copy, Show, Clone, PartialEq, FromPrimitive)] + #[derive(Copy, Show, Clone, PartialEq, FromPrimitive)] pub enum Errno { UnknownErrno = 0, EPERM = 1, diff --git a/src/fcntl.rs b/src/fcntl.rs index a7e0a81b..06044b88 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -1,3 +1,4 @@ +use std::c_str::ToCStr; use std::path::Path; use std::io::FilePermission; use libc::{c_int, mode_t}; @@ -18,7 +19,7 @@ mod ffi { use libc::{c_int, c_short, off_t, pid_t}; #[repr(C)] - #[deriving(Copy)] + #[derive(Copy)] pub struct flock { pub l_type: c_short, pub l_whence: c_short, @@ -46,7 +47,7 @@ mod ffi { use libc::{c_int, c_short, off_t, pid_t}; #[repr(C)] - #[deriving(Copy)] + #[derive(Copy)] pub struct flock { pub l_start: off_t, pub l_len: off_t, diff --git a/src/mount.rs b/src/mount.rs index 85c5563f..fa0f845a 100644 --- a/src/mount.rs +++ b/src/mount.rs @@ -1,3 +1,4 @@ +use std::c_str::ToCStr; use std::ptr; use std::path::Path; use libc::{c_ulong, c_int, c_void}; diff --git a/src/sys/event.rs b/src/sys/event.rs index fbba2f3a..09c94f77 100644 --- a/src/sys/event.rs +++ b/src/sys/event.rs @@ -12,7 +12,7 @@ mod ffi { pub use libc::{c_int, c_void, uintptr_t, intptr_t, timespec}; use super::{EventFilter, EventFlag, FilterFlag}; - #[deriving(Copy)] + #[derive(Copy)] #[repr(C)] pub struct kevent { pub ident: uintptr_t, // 8 @@ -39,7 +39,7 @@ mod ffi { } #[repr(i16)] -#[deriving(Copy, Show, PartialEq)] +#[derive(Copy, Show, PartialEq)] pub enum EventFilter { EVFILT_READ = -1, EVFILT_WRITE = -2, diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 178df873..f57ee108 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -1,4 +1,5 @@ use errno::{SysResult, SysError}; +use std::c_str::ToCStr; use std::io::FilePermission; use fcntl::{Fd, OFlag}; use libc::{c_void, size_t, off_t, mode_t}; @@ -86,9 +87,9 @@ mod consts { pub const PROT_WRITE: MmapProt = 0x2; pub const PROT_EXEC: MmapProt = 0x4; pub const PROT_NONE: MmapProt = 0x0; - + pub type MmapAdvise = c_int; - + pub const MADV_NORMAL : MmapAdvise = 0; /* No further special treatment. */ pub const MADV_RANDOM : MmapAdvise = 1; /* Expect random page references. */ pub const MADV_SEQUENTIAL : MmapAdvise = 2; /* Expect sequential page references. */ @@ -98,7 +99,7 @@ mod consts { pub const MADV_ZERO_WIRED_PAGES: MmapAdvise = 6; /* zero the wired pages that have not been unwired before the entry is deleted */ pub const MADV_FREE_REUSABLE : MmapAdvise = 7; /* pages can be reused (by anyone) */ pub const MADV_FREE_REUSE : MmapAdvise = 8; /* caller wants to reuse those pages */ - pub const MADV_CAN_REUSE : MmapAdvise = 9; + pub const MADV_CAN_REUSE : MmapAdvise = 9; pub type MmapSync = c_int; diff --git a/src/sys/signal.rs b/src/sys/signal.rs index 771255c3..a4a25ccc 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -95,7 +95,7 @@ pub mod signal { // actually a giant union. Currently we're only interested in these fields, // however. #[repr(C)] - #[deriving(Copy)] + #[derive(Copy)] pub struct siginfo { si_signo: libc::c_int, si_errno: libc::c_int, @@ -116,14 +116,14 @@ pub mod signal { #[repr(C)] #[cfg(target_word_size = "32")] - #[deriving(Copy)] + #[derive(Copy)] pub struct sigset_t { __val: [libc::c_ulong; 32], } #[repr(C)] #[cfg(target_word_size = "64")] - #[deriving(Copy)] + #[derive(Copy)] pub struct sigset_t { __val: [libc::c_ulong; 16], } @@ -248,7 +248,7 @@ pub mod signal { // This structure has more fields, but we're not all that interested in // them. #[repr(C)] - #[deriving(Copy)] + #[derive(Copy)] pub struct siginfo { pub si_signo: libc::c_int, pub si_errno: libc::c_int, @@ -296,7 +296,7 @@ mod ffi { } } -#[deriving(Copy)] +#[derive(Copy)] pub struct SigSet { sigset: sigset_t } diff --git a/src/sys/socket.rs b/src/sys/socket.rs index 09dda4d2..31723705 100644 --- a/src/sys/socket.rs +++ b/src/sys/socket.rs @@ -31,7 +31,7 @@ bitflags!( } ); -#[deriving(Copy)] +#[derive(Copy)] pub enum SockAddr { SockIpV4(sockaddr_in), SockIpV6(sockaddr_in6), @@ -444,7 +444,7 @@ pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr, flags: SockMessageFlags) } #[repr(C)] -#[deriving(Copy)] +#[derive(Copy)] pub struct linger { pub l_onoff: c_int, pub l_linger: c_int diff --git a/src/sys/stat.rs b/src/sys/stat.rs index 0f691c6f..9f760015 100644 --- a/src/sys/stat.rs +++ b/src/sys/stat.rs @@ -1,6 +1,7 @@ pub use libc::dev_t; pub use libc::stat as FileStat; +use std::c_str::ToCStr; use std::fmt; use std::io::FilePermission; use std::mem; diff --git a/src/sys/wait.rs b/src/sys/wait.rs index caebff34..c49765fd 100644 --- a/src/sys/wait.rs +++ b/src/sys/wait.rs @@ -15,7 +15,7 @@ bitflags!( } ); -#[deriving(Copy)] +#[derive(Copy)] pub enum WaitStatus { Exited(pid_t), StillAlive diff --git a/src/unistd.rs b/src/unistd.rs index a067dbd1..3f20f887 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -53,7 +53,7 @@ mod ffi { } } -#[deriving(Copy)] +#[derive(Copy)] pub enum Fork { Parent(pid_t), Child @@ -102,9 +102,9 @@ pub fn fork() -> SysResult { type IovecR = Iovec; type IovecW = Iovec; -#[deriving(Copy)] +#[derive(Copy)] pub struct ToRead; -#[deriving(Copy)] +#[derive(Copy)] pub struct ToWrite; #[repr(C)] @@ -410,6 +410,7 @@ pub fn ftruncate(fd: Fd, len: off_t) -> SysResult<()> { #[cfg(target_os = "linux")] mod linux { + use std::c_str::ToCStr; use std::path::Path; use syscall::{syscall, SYSPIVOTROOT}; use errno::{SysResult, SysError}; diff --git a/tests/unistd.rs b/tests/unistd.rs index 075181bc..7590fa07 100644 --- a/tests/unistd.rs +++ b/tests/unistd.rs @@ -3,8 +3,9 @@ extern crate nix; #[cfg(test)] mod test { use nix::unistd::{writev, readv, Iovec, pipe, close, read, write}; - use std::rand::{thread_rng, Rng}; use std::cmp::min; + use std::iter::repeat; + use std::rand::{thread_rng, Rng}; #[test] fn test_writev() { @@ -28,7 +29,7 @@ mod test { assert!(pipe_res.is_ok()); let (reader, writer) = pipe_res.ok().unwrap(); // FileDesc will close its filedesc (reader). - let mut read_buf = Vec::from_elem(128 * 16, 0u8); + let mut read_buf: Vec = repeat(0u8).take(128 * 16).collect(); // Blocking io, should write all data. let write_res = writev(writer, iovecs.as_slice()); // Successful write @@ -59,7 +60,7 @@ mod test { while allocated < to_write.len() { let left = to_write.len() - allocated; let vec_len = if left < 64 { left } else { thread_rng().gen_range(64, min(256, left)) }; - let v = Vec::from_elem(vec_len, 0u8); + let v: Vec = repeat(0u8).take(vec_len).collect(); storage.push(v); allocated += vec_len; } -- cgit v1.2.3