Skip to content

Commit 45781c7

Browse files
committed
Delegate to linux_android from linux_android_with_fallback.
Instead of duplicating the implementation of `linux_android::getrandom_inner` inline, call `linux_android::getrandom_inner`, like we do for `use_file::getrandom_inner`. This way, there is no doubt that they do exactly the same thing.
1 parent 05cdf6f commit 45781c7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ cfg_if! {
299299
mod util_libc;
300300
mod use_file;
301301
mod lazy;
302+
mod linux_android;
302303
#[path = "linux_android_with_fallback.rs"] mod imp;
303304
} else if #[cfg(any(target_os = "android", target_os = "linux"))] {
304305
mod util_libc;

src/linux_android_with_fallback.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
//! Implementation for Linux / Android with `/dev/urandom` fallback
22
use crate::{
33
lazy::LazyBool,
4-
util_libc::{getrandom_syscall, last_os_error, sys_fill_exact},
5-
{use_file, Error},
4+
linux_android, use_file,
5+
util_libc::{getrandom_syscall, last_os_error},
6+
Error,
67
};
78
use core::mem::MaybeUninit;
89

910
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
1011
// getrandom(2) was introduced in Linux 3.17
1112
static HAS_GETRANDOM: LazyBool = LazyBool::new();
1213
if HAS_GETRANDOM.unsync_init(is_getrandom_available) {
13-
sys_fill_exact(dest, getrandom_syscall)
14+
linux_android::getrandom_inner(dest)
1415
} else {
1516
use_file::getrandom_inner(dest)
1617
}

0 commit comments

Comments
 (0)