From d9595d1737677dd61d9f52f674c34f13d708e39c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 9 Apr 2013 01:31:23 -0400 Subject: core: remove unnecessary unsafe blocks/functions --- src/libcore/io.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/libcore/io.rs') diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 3853e7c8f2b..3c5900f51a2 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1536,11 +1536,8 @@ pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] { pub fn with_str_writer(f: &fn(@Writer)) -> ~str { let mut v = with_bytes_writer(f); - // FIXME (#3758): This should not be needed. - unsafe { - // Make sure the vector has a trailing null and is proper utf8. - v.push(0); - } + // Make sure the vector has a trailing null and is proper utf8. + v.push(0); assert!(str::is_utf8(v)); unsafe { ::cast::transmute(v) } @@ -1640,16 +1637,14 @@ pub mod fsync { // outer res pub fn FILE_res_sync(file: &FILERes, opt_level: Option, blk: &fn(v: Res<*libc::FILE>)) { - unsafe { - blk(Res(Arg { - val: file.f, opt_level: opt_level, - fsync_fn: |file, l| { - unsafe { - os::fsync_fd(libc::fileno(file), l) as int - } + blk(Res(Arg { + val: file.f, opt_level: opt_level, + fsync_fn: |file, l| { + unsafe { + os::fsync_fd(libc::fileno(file), l) as int } - })); - } + } + })); } // fsync fd after executing blk -- cgit 1.4.1-3-g733a5