Skip to content

Commit

Permalink
fix compilation on uefi (with std feature enabled) or i686 (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
usamoi authored Dec 18, 2024
1 parent 12c9f80 commit 9195c09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ jobs:
target: [
x86_64-unknown-uefi,
x86_64-unknown-l4re-uclibc,
i686-unknown-uefi,
]
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion src/backends/rdrand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ unsafe fn rdrand_u32() -> Option<u32> {
unsafe fn rdrand_u64() -> Option<u64> {
let a = rdrand()?;
let b = rdrand()?;
Some((u64::from(a) << 32) || u64::from(b))
Some((u64::from(a) << 32) | u64::from(b))
}

pub fn inner_u32() -> Result<u32, Error> {
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl fmt::Debug for Error {
let mut dbg = f.debug_struct("Error");
if let Some(errno) = self.raw_os_error() {
dbg.field("os_error", &errno);
#[cfg(feature = "std")]
#[cfg(all(feature = "std", not(target_os = "uefi")))]
dbg.field("description", &std::io::Error::from_raw_os_error(errno));
} else if let Some(desc) = self.internal_desc() {
dbg.field("internal_code", &self.0.get());
Expand All @@ -150,7 +150,7 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(errno) = self.raw_os_error() {
cfg_if! {
if #[cfg(feature = "std")] {
if #[cfg(all(feature = "std", not(target_os = "uefi")))] {
std::io::Error::from_raw_os_error(errno).fmt(f)
} else {
write!(f, "OS Error: {}", errno)
Expand Down
5 changes: 5 additions & 0 deletions src/error_std_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ use std::io;

impl From<Error> for io::Error {
fn from(err: Error) -> Self {
#[cfg(not(target_os = "uefi"))]
match err.raw_os_error() {
Some(errno) => io::Error::from_raw_os_error(errno),
None => io::Error::new(io::ErrorKind::Other, err),
}
#[cfg(target_os = "uefi")]
{
io::Error::new(io::ErrorKind::Other, err)
}
}
}

Expand Down

0 comments on commit 9195c09

Please sign in to comment.