diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-08-25 17:15:28 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-08-25 17:15:28 +0000 |
commit | 28c5b4a41a45a3ee5ec6c88927388b208f0449c3 (patch) | |
tree | b3442d4525fbdc6d4a91c6b4f25e5a2cd8d126dc /test | |
parent | 3b4fb07c37ea5b0cf20e40009839bb62a6fbd829 (diff) | |
parent | 505bed350d37811c1ed52302f4b820711a57041f (diff) | |
download | nix-28c5b4a41a45a3ee5ec6c88927388b208f0449c3.zip |
Merge #744
744: Mark and document pty::ptsname() as unsafe r=asomers a=nelsonjchen
On some platforms, `ptsname()` mutates global variables and mutating
global variables is always considered `unsafe` by Rust.
Reference:
https://github.com/nix-rust/nix/pull/742#issuecomment-324385919
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pty.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/test_pty.rs b/test/test_pty.rs index 75ef4923..89706f0c 100644 --- a/test/test_pty.rs +++ b/test/test_pty.rs @@ -35,7 +35,7 @@ fn test_ptsname_equivalence() { assert!(master_fd.as_raw_fd() > 0); // Get the name of the slave - let slave_name = ptsname(&master_fd).unwrap(); + let slave_name = unsafe { ptsname(&master_fd) }.unwrap() ; let slave_name_r = ptsname_r(&master_fd).unwrap(); assert_eq!(slave_name, slave_name_r); } @@ -53,8 +53,8 @@ fn test_ptsname_copy() { assert!(master_fd.as_raw_fd() > 0); // Get the name of the slave - let slave_name1 = ptsname(&master_fd).unwrap(); - let slave_name2 = ptsname(&master_fd).unwrap(); + let slave_name1 = unsafe { ptsname(&master_fd) }.unwrap(); + let slave_name2 = unsafe { ptsname(&master_fd) }.unwrap(); assert!(slave_name1 == slave_name2); // Also make sure that the string was actually copied and they point to different parts of // memory. @@ -92,8 +92,8 @@ fn test_ptsname_unique() { assert!(master2_fd.as_raw_fd() > 0); // Get the name of the slave - let slave_name1 = ptsname(&master1_fd).unwrap(); - let slave_name2 = ptsname(&master2_fd).unwrap(); + let slave_name1 = unsafe { ptsname(&master1_fd) }.unwrap(); + let slave_name2 = unsafe { ptsname(&master2_fd) }.unwrap(); assert!(slave_name1 != slave_name2); } @@ -116,7 +116,7 @@ fn test_open_ptty_pair() { unlockpt(&master_fd).expect("unlockpt failed"); // Get the name of the slave - let slave_name = ptsname(&master_fd).expect("ptsname failed"); + let slave_name = unsafe { ptsname(&master_fd) }.expect("ptsname failed"); // Open the slave device let slave_fd = open(Path::new(&slave_name), O_RDWR, stat::Mode::empty()).unwrap(); |