Skip to content

Commit 0931408

Browse files
committed
Fixed formatting, inline, and conversions
1 parent a356105 commit 0931408

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/error.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const BLOCK_SIZE: u32 = 1 << 16;
2424

2525
impl Error {
2626
/// Create a new error from a raw OS error number (errno).
27+
#[inline]
2728
pub fn from_os_error(errno: i32) -> Self {
2829
assert!(errno > 0);
2930
Self(NonZeroU32::new(errno as u32).unwrap())
@@ -32,9 +33,10 @@ impl Error {
3233
/// Crate a custom error in the provided block (group of 2^16 error codes).
3334
/// The provided block must not be negative, and block 0 is reserved for
3435
/// custom errors in the `getrandom` crate.
36+
#[inline]
3537
pub fn custom_error(block: i16, code: u16) -> Self {
3638
assert!(block >= 0);
37-
let n = CUSTOM_START + (block as u32) * BLOCK_SIZE + (code as u32);
39+
let n = CUSTOM_START + (block as u16 as u32) * BLOCK_SIZE + (code as u32);
3840
Self(NonZeroU32::new(n).unwrap())
3941
}
4042

@@ -43,6 +45,7 @@ impl Error {
4345
/// This method is identical to `std::io::Error::raw_os_error()`, except
4446
/// that it works in `no_std` contexts. If this method returns `None`, the
4547
/// error value can still be formatted via the `Diplay` implementation.
48+
#[inline]
4649
pub fn raw_os_error(&self) -> Option<i32> {
4750
self.try_os_error().ok()
4851
}
@@ -51,6 +54,7 @@ impl Error {
5154
///
5255
/// This code can either come from the underlying OS, or be a custom error.
5356
/// Use [`raw_os_error()`] to disambiguate.
57+
#[inline]
5458
pub fn code(&self) -> NonZeroU32 {
5559
self.0
5660
}

src/linux_android.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
//! Implementation for Linux / Android
1010
use crate::util::LazyBool;
11-
use crate::util_libc::{sys_fill_exact, last_os_error};
11+
use crate::util_libc::{last_os_error, sys_fill_exact};
1212
use crate::{use_file, Error};
1313

1414
pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {

0 commit comments

Comments
 (0)