Skip to content

Commit

Permalink
Remove raw pointer from OpenOptions struct
Browse files Browse the repository at this point in the history
Otherwise it is not Send and Sync anymore
  • Loading branch information
pitdicker committed Jan 20, 2016
1 parent 9c56918 commit ae30294
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,12 @@ mod tests {
assert_eq!(check!(fs::metadata(&tmpdir.join("h"))).len(), 9);
}

#[test]
fn _assert_send_sync() {
fn _assert_send_sync<T: Send + Sync>() {}
_assert_send_sync::<OpenOptions>();
}

#[test]
fn binary_file() {
let mut bytes = [0; 1024];
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sys/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct OpenOptions {
attributes: c::DWORD,
share_mode: c::DWORD,
security_qos_flags: c::DWORD,
security_attributes: c::LPSECURITY_ATTRIBUTES,
security_attributes: usize, // FIXME: should be a reference
}

#[derive(Clone, PartialEq, Eq, Debug)]
Expand Down Expand Up @@ -170,7 +170,7 @@ impl OpenOptions {
share_mode: c::FILE_SHARE_READ | c::FILE_SHARE_WRITE | c::FILE_SHARE_DELETE,
attributes: 0,
security_qos_flags: 0,
security_attributes: ptr::null_mut(),
security_attributes: 0,
}
}

Expand All @@ -187,7 +187,7 @@ impl OpenOptions {
pub fn attributes(&mut self, attrs: u32) { self.attributes = attrs; }
pub fn security_qos_flags(&mut self, flags: u32) { self.security_qos_flags = flags; }
pub fn security_attributes(&mut self, attrs: c::LPSECURITY_ATTRIBUTES) {
self.security_attributes = attrs;
self.security_attributes = attrs as usize;
}

fn get_access_mode(&self) -> io::Result<c::DWORD> {
Expand Down

0 comments on commit ae30294

Please sign in to comment.