Skip to content

Commit 5b28298

Browse files
committed
Simplify logic checking getentropy's return value
1 parent 3ee3a78 commit 5b28298

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/libstd/rand/os.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,11 @@ mod imp {
229229
unsafe { mem::transmute(v) }
230230
}
231231
fn fill_bytes(&mut self, v: &mut [u8]) {
232-
let mut ret: c_long;
233-
234232
// getentropy(2) permits a maximum buffer size of 256 bytes
235233
for s in v.chunks_mut(256) {
236-
unsafe {
237-
ret = syscall(NR_GETENTROPY, s.as_mut_ptr(), s.len());
238-
}
234+
let ret = unsafe {
235+
syscall(NR_GETENTROPY, s.as_mut_ptr(), s.len())
236+
};
239237
if ret == -1 {
240238
panic!("unexpected getentropy error: {}", errno());
241239
}

0 commit comments

Comments
 (0)