Skip to content

Commit 8cc58e7

Browse files
authored
refactor: cfg for dir/env/errno (#2214)
1 parent 2563d24 commit 8cc58e7

File tree

3 files changed

+91
-387
lines changed

3 files changed

+91
-387
lines changed

src/dir.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,13 @@ impl Entry {
225225
pub fn ino(&self) -> u64 {
226226
cfg_if! {
227227
if #[cfg(any(target_os = "aix",
228-
target_os = "android",
229228
target_os = "emscripten",
230229
target_os = "fuchsia",
231230
target_os = "haiku",
232-
target_os = "illumos",
231+
solarish,
232+
linux_android,
233233
apple_targets,
234-
target_os = "l4re",
235-
target_os = "linux",
236-
target_os = "solaris"))] {
234+
target_os = "l4re"))] {
237235
self.0.d_ino as u64
238236
} else {
239237
u64::from(self.0.d_fileno)
@@ -252,12 +250,7 @@ impl Entry {
252250
/// notably, some Linux filesystems don't implement this. The caller should use `stat` or
253251
/// `fstat` if this returns `None`.
254252
pub fn file_type(&self) -> Option<Type> {
255-
#[cfg(not(any(
256-
target_os = "aix",
257-
target_os = "illumos",
258-
target_os = "solaris",
259-
target_os = "haiku"
260-
)))]
253+
#[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
261254
match self.0.d_type {
262255
libc::DT_FIFO => Some(Type::Fifo),
263256
libc::DT_CHR => Some(Type::CharacterDevice),
@@ -270,12 +263,7 @@ impl Entry {
270263
}
271264

272265
// illumos, Solaris, and Haiku systems do not have the d_type member at all:
273-
#[cfg(any(
274-
target_os = "aix",
275-
target_os = "illumos",
276-
target_os = "solaris",
277-
target_os = "haiku"
278-
))]
266+
#[cfg(any(solarish, target_os = "aix", target_os = "haiku"))]
279267
None
280268
}
281269
}

src/env.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ impl std::error::Error for ClearEnvError {}
4040
/// thread safety must still be upheld.
4141
pub unsafe fn clearenv() -> std::result::Result<(), ClearEnvError> {
4242
cfg_if! {
43-
if #[cfg(any(target_os = "fuchsia",
43+
if #[cfg(any(linux_android,
44+
target_os = "fuchsia",
4445
target_os = "wasi",
4546
target_env = "uclibc",
46-
target_os = "linux",
47-
target_os = "android",
4847
target_os = "emscripten"))] {
4948
let ret = unsafe { libc::clearenv() };
5049
} else {

0 commit comments

Comments
 (0)