Skip to content

refactor: cfg for dir/env/errno #2214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,13 @@ impl Entry {
pub fn ino(&self) -> u64 {
cfg_if! {
if #[cfg(any(target_os = "aix",
target_os = "android",
target_os = "emscripten",
target_os = "fuchsia",
target_os = "haiku",
target_os = "illumos",
solarish,
linux_android,
apple_targets,
target_os = "l4re",
target_os = "linux",
target_os = "solaris"))] {
target_os = "l4re"))] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly we could probably eliminate l4re. I'm not sure why it's there in the first place. This is the only reference to it in Nix, and it doesn't come remotely close to compiling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do it

self.0.d_ino as u64
} else {
u64::from(self.0.d_fileno)
Expand All @@ -252,12 +250,7 @@ impl Entry {
/// notably, some Linux filesystems don't implement this. The caller should use `stat` or
/// `fstat` if this returns `None`.
pub fn file_type(&self) -> Option<Type> {
#[cfg(not(any(
target_os = "aix",
target_os = "illumos",
target_os = "solaris",
target_os = "haiku"
)))]
#[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
match self.0.d_type {
libc::DT_FIFO => Some(Type::Fifo),
libc::DT_CHR => Some(Type::CharacterDevice),
Expand All @@ -270,12 +263,7 @@ impl Entry {
}

// illumos, Solaris, and Haiku systems do not have the d_type member at all:
#[cfg(any(
target_os = "aix",
target_os = "illumos",
target_os = "solaris",
target_os = "haiku"
))]
#[cfg(any(solarish, target_os = "aix", target_os = "haiku"))]
None
}
}
5 changes: 2 additions & 3 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ impl std::error::Error for ClearEnvError {}
/// thread safety must still be upheld.
pub unsafe fn clearenv() -> std::result::Result<(), ClearEnvError> {
cfg_if! {
if #[cfg(any(target_os = "fuchsia",
if #[cfg(any(linux_android,
target_os = "fuchsia",
target_os = "wasi",
target_env = "uclibc",
target_os = "linux",
target_os = "android",
target_os = "emscripten"))] {
let ret = unsafe { libc::clearenv() };
} else {
Expand Down
Loading