Skip to content

Commit 744aecf

Browse files
committed
Remove unnecessary unsafe block
1 parent 2eda01e commit 744aecf

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

src/libstd/sys/unix/android.rs

+16-20
Original file line numberDiff line numberDiff line change
@@ -120,30 +120,26 @@ pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i6
120120
-> io::Result<ssize_t>
121121
{
122122
weak!(fn pread64(c_int, *mut c_void, size_t, i64) -> ssize_t);
123-
unsafe {
124-
pread64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
125-
if let Ok(o) = offset.try_into() {
126-
cvt(pread(fd, buf, count, o))
127-
} else {
128-
Err(io::Error::new(io::ErrorKind::InvalidInput,
129-
"cannot pread >2GB"))
130-
}
131-
})
132-
}
123+
pread64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
124+
if let Ok(o) = offset.try_into() {
125+
cvt(pread(fd, buf, count, o))
126+
} else {
127+
Err(io::Error::new(io::ErrorKind::InvalidInput,
128+
"cannot pread >2GB"))
129+
}
130+
})
133131
}
134132

135133
pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64)
136134
-> io::Result<ssize_t>
137135
{
138136
weak!(fn pwrite64(c_int, *const c_void, size_t, i64) -> ssize_t);
139-
unsafe {
140-
pwrite64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
141-
if let Ok(o) = offset.try_into() {
142-
cvt(pwrite(fd, buf, count, o))
143-
} else {
144-
Err(io::Error::new(io::ErrorKind::InvalidInput,
145-
"cannot pwrite >2GB"))
146-
}
147-
})
148-
}
137+
pwrite64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
138+
if let Ok(o) = offset.try_into() {
139+
cvt(pwrite(fd, buf, count, o))
140+
} else {
141+
Err(io::Error::new(io::ErrorKind::InvalidInput,
142+
"cannot pwrite >2GB"))
143+
}
144+
})
149145
}

0 commit comments

Comments
 (0)