Skip to content

Commit 0d0a189

Browse files
committed
Remove warnings when compiling for Redox
1 parent ea64d16 commit 0d0a189

File tree

6 files changed

+53
-16
lines changed

6 files changed

+53
-16
lines changed

test/sys/test_signal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use libc;
2+
#[cfg(not(target_os = "redox"))]
23
use nix::Error;
34
use nix::sys::signal::*;
45
use nix::unistd::*;

test/sys/test_uio.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use std::{cmp, iter};
66
use std::fs::{OpenOptions};
77
use std::os::unix::io::AsRawFd;
88

9-
use tempfile::{tempfile, tempdir};
9+
#[cfg(not(target_os = "redox"))]
10+
use tempfile::tempfile;
11+
use tempfile::tempdir;
1012

1113
#[test]
1214
fn test_writev() {

test/test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate bytes;
33
extern crate caps;
44
#[macro_use]
55
extern crate cfg_if;
6-
#[macro_use]
6+
#[cfg_attr(not(target_os = "redox"), macro_use)]
77
extern crate nix;
88
#[macro_use]
99
extern crate lazy_static;
@@ -58,6 +58,7 @@ macro_rules! skip_if_jailed {
5858
}
5959
}
6060

61+
#[cfg(not(target_os = "redox"))]
6162
macro_rules! skip_if_not_root {
6263
($name:expr) => {
6364
use nix::unistd::Uid;

test/test_fcntl.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
#[cfg(not(target_os = "redox"))]
12
use nix::Error;
3+
#[cfg(not(target_os = "redox"))]
24
use nix::errno::*;
5+
#[cfg(not(target_os = "redox"))]
36
use nix::fcntl::{open, OFlag, readlink};
47
#[cfg(not(target_os = "redox"))]
58
use nix::fcntl::{openat, readlinkat, renameat};
9+
#[cfg(not(target_os = "redox"))]
610
use nix::sys::stat::Mode;
11+
#[cfg(not(target_os = "redox"))]
712
use nix::unistd::{close, read};
13+
#[cfg(not(target_os = "redox"))]
814
use tempfile::{self, NamedTempFile};
15+
#[cfg(not(target_os = "redox"))]
916
use std::fs::File;
17+
#[cfg(not(target_os = "redox"))]
1018
use std::io::prelude::*;
19+
#[cfg(not(target_os = "redox"))]
1120
use std::os::unix::fs;
1221

1322
#[test]

test/test_stat.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1-
use std::fs::{self, File};
1+
#[cfg(not(target_os = "redox"))]
2+
use std::fs;
3+
use std::fs::File;
4+
#[cfg(not(target_os = "redox"))]
25
use std::os::unix::fs::{symlink, PermissionsExt};
36
use std::os::unix::prelude::AsRawFd;
7+
#[cfg(not(target_os = "redox"))]
48
use std::time::{Duration, UNIX_EPOCH};
9+
#[cfg(not(target_os = "redox"))]
510
use std::path::Path;
611

7-
#[cfg(not(any(target_os = "netbsd")))]
12+
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
813
use libc::{S_IFMT, S_IFLNK, mode_t};
914

15+
#[cfg(not(target_os = "redox"))]
1016
use nix::{fcntl, Error};
11-
use nix::errno::{Errno};
12-
use nix::sys::stat::{self, fchmod, futimens, stat, utimes};
17+
#[cfg(not(target_os = "redox"))]
18+
use nix::errno::Errno;
19+
#[cfg(not(target_os = "redox"))]
20+
use nix::sys::stat::{self, futimens, utimes};
21+
use nix::sys::stat::{fchmod, stat};
1322
#[cfg(not(target_os = "redox"))]
1423
use nix::sys::stat::{fchmodat, utimensat, mkdirat};
1524
#[cfg(any(target_os = "linux",
@@ -19,30 +28,34 @@ use nix::sys::stat::{fchmodat, utimensat, mkdirat};
1928
target_os = "freebsd",
2029
target_os = "netbsd"))]
2130
use nix::sys::stat::lutimes;
22-
use nix::sys::stat::{Mode, FchmodatFlags, UtimensatFlags};
31+
#[cfg(not(target_os = "redox"))]
32+
use nix::sys::stat::{FchmodatFlags, UtimensatFlags};
33+
use nix::sys::stat::Mode;
2334

24-
#[cfg(not(any(target_os = "netbsd")))]
35+
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
2536
use nix::sys::stat::FileStat;
2637

38+
#[cfg(not(target_os = "redox"))]
2739
use nix::sys::time::{TimeSpec, TimeVal, TimeValLike};
40+
#[cfg(not(target_os = "redox"))]
2841
use nix::unistd::chdir;
2942

30-
#[cfg(not(any(target_os = "netbsd")))]
43+
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
3144
use nix::Result;
3245
use tempfile;
3346

3447
#[allow(unused_comparisons)]
3548
// uid and gid are signed on Windows, but not on other platforms. This function
3649
// allows warning free compiles on all platforms, and can be removed when
3750
// expression-level #[allow] is available.
38-
#[cfg(not(any(target_os = "netbsd")))]
51+
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
3952
fn valid_uid_gid(stat: FileStat) -> bool {
4053
// uid could be 0 for the `root` user. This quite possible when
4154
// the tests are being run on a rooted Android device.
4255
stat.st_uid >= 0 && stat.st_gid >= 0
4356
}
4457

45-
#[cfg(not(any(target_os = "netbsd")))]
58+
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
4659
fn assert_stat_results(stat_result: Result<FileStat>) {
4760
let stats = stat_result.expect("stat call failed");
4861
assert!(stats.st_dev > 0); // must be positive integer, exact number machine dependent
@@ -55,7 +68,7 @@ fn assert_stat_results(stat_result: Result<FileStat>) {
5568
assert!(stats.st_blocks <= 16); // Up to 16 blocks can be allocated for a blank file
5669
}
5770

58-
#[cfg(not(any(target_os = "netbsd")))]
71+
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
5972
fn assert_lstat_results(stat_result: Result<FileStat>) {
6073
let stats = stat_result.expect("stat call failed");
6174
assert!(stats.st_dev > 0); // must be positive integer, exact number machine dependent
@@ -189,6 +202,7 @@ fn test_fchmodat() {
189202
///
190203
/// The atime and mtime are expressed with a resolution of seconds because some file systems
191204
/// (like macOS's HFS+) do not have higher granularity.
205+
#[cfg(not(target_os = "redox"))]
192206
fn assert_times_eq(exp_atime_sec: u64, exp_mtime_sec: u64, attr: &fs::Metadata) {
193207
assert_eq!(
194208
Duration::new(exp_atime_sec, 0),

test/test_unistd.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
use nix::fcntl::{self, fcntl, FcntlArg, FdFlag, open, OFlag, readlink};
1+
#[cfg(not(target_os = "redox"))]
2+
use nix::fcntl::{self, open, readlink};
3+
use nix::fcntl::{fcntl, FcntlArg, FdFlag, OFlag};
24
use nix::unistd::*;
35
use nix::unistd::ForkResult::*;
6+
#[cfg(not(target_os = "redox"))]
47
use nix::sys::signal::{SaFlags, SigAction, SigHandler, SigSet, Signal, sigaction};
58
use nix::sys::wait::*;
69
use nix::sys::stat::{self, Mode, SFlag};
710
use nix::errno::Errno;
11+
#[cfg(not(target_os = "redox"))]
812
use nix::Error;
913
use std::{env, iter};
14+
#[cfg(not(target_os = "redox"))]
1015
use std::ffi::CString;
11-
use std::fs::{self, DirBuilder, File};
16+
#[cfg(not(target_os = "redox"))]
17+
use std::fs::DirBuilder;
18+
use std::fs::{self, File};
1219
use std::io::Write;
1320
use std::os::unix::prelude::*;
1421
use tempfile::{self, tempfile};
15-
use libc::{self, _exit, off_t};
22+
use libc::{_exit, off_t};
1623

1724
#[test]
1825
#[cfg(not(any(target_os = "netbsd")))]
@@ -233,6 +240,7 @@ fn test_initgroups() {
233240
setgroups(&old_groups).unwrap();
234241
}
235242

243+
#[cfg(not(target_os = "redox"))]
236244
macro_rules! execve_test_factory(
237245
($test_name:ident, $syscall:ident, $exe: expr $(, $pathname:expr, $flags:expr)*) => (
238246
#[test]
@@ -466,7 +474,7 @@ cfg_if!{
466474
skip_if_jailed!("test_acct");
467475
}
468476
}
469-
} else {
477+
} else if #[cfg(not(target_os = "redox"))] {
470478
macro_rules! require_acct{
471479
() => {
472480
skip_if_not_root!("test_acct");
@@ -592,9 +600,11 @@ fn test_ftruncate() {
592600
}
593601

594602
// Used in `test_alarm`.
603+
#[cfg(not(target_os = "redox"))]
595604
static mut ALARM_CALLED: bool = false;
596605

597606
// Used in `test_alarm`.
607+
#[cfg(not(target_os = "redox"))]
598608
pub extern fn alarm_signal_handler(raw_signal: libc::c_int) {
599609
assert_eq!(raw_signal, libc::SIGALRM, "unexpected signal: {}", raw_signal);
600610
unsafe { ALARM_CALLED = true };

0 commit comments

Comments
 (0)