Skip to content

Commit 3f2f259

Browse files
committed
fix: small typo+ for non-major supported systems
1 parent b427fa4 commit 3f2f259

7 files changed

Lines changed: 31 additions & 20 deletions

File tree

benches/dirent_bench.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ fn bench_strlen(c: &mut Criterion) {
146146
let mut total = 0;
147147
for entry in &all_entries {
148148
total += unsafe {
149-
black_box(libc::strlen(black_box(
150-
access_dirent!(entry, d_name),
151-
)))
149+
black_box(libc::strlen(black_box(access_dirent!(entry, d_name))))
152150
};
153151
}
154152
black_box(total) //make sure compiler does not optimise this away

src/direntry.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,12 @@ impl DirEntry {
885885
Returns `DirEntryError::IOError` if the stat operation fails
886886
*/
887887
pub fn get_lstatat(&self, fd: &FileDes) -> Result<stat> {
888-
stat_syscall!(fstatat, fd.0, self.file_name_cstr().as_ptr(), AT_SYMLINK_NOFOLLOW)
888+
stat_syscall!(
889+
fstatat,
890+
fd.0,
891+
self.file_name_cstr().as_ptr(),
892+
AT_SYMLINK_NOFOLLOW
893+
)
889894
}
890895

891896
#[inline]
@@ -961,7 +966,12 @@ impl DirEntry {
961966
*
962967
*/
963968
pub fn get_statat(&self, fd: &FileDes) -> Result<stat> {
964-
stat_syscall!(fstatat, fd.0, self.file_name_cstr().as_ptr(), AT_SYMLINK_FOLLOW)
969+
stat_syscall!(
970+
fstatat,
971+
fd.0,
972+
self.file_name_cstr().as_ptr(),
973+
AT_SYMLINK_FOLLOW
974+
)
965975
}
966976

967977
#[inline]

src/iter.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{dirent64, readdir64};
55
use core::cell::Cell;
66
use core::ffi::CStr;
77
use core::ptr::NonNull;
8-
use libc::{fstatat,AT_SYMLINK_NOFOLLOW,DIR};
8+
use libc::{AT_SYMLINK_NOFOLLOW, DIR, fstatat};
99
/**
1010
POSIX-compliant directory iterator using libc's readdir
1111
@@ -381,15 +381,12 @@ pub trait DirentConstructor {
381381
/// Returns the file descriptor for the current directory being read
382382
fn file_descriptor(&self) -> &FileDes;
383383

384-
385-
386384
#[inline]
387-
#[allow(clippy::wildcard_enum_match_arm,reason="exhaustive")]
385+
#[allow(clippy::wildcard_enum_match_arm, reason = "exhaustive")]
388386
#[allow(clippy::multiple_unsafe_ops_per_block)]
389387
/// Constructs a `DirEntry` from a raw directory entry pointer
390388
#[allow(unused_unsafe)] //lazy fix for illumos/solaris (where we dont actually dereference the pointer, just return unknown TODO-MAKE MORE ELEGANT)
391389
unsafe fn construct_entry(&mut self, drnt: *const dirent64) -> DirEntry {
392-
393390
let base_len = self.file_index();
394391
debug_assert!(!drnt.is_null(), "drnt should never be null!");
395392
// SAFETY: The `drnt` must not be null (checked before using)
@@ -398,12 +395,18 @@ pub trait DirentConstructor {
398395
let inode = unsafe { access_dirent!(drnt, d_ino) };
399396

400397
// SAFETY: The `drnt` must not be null(by precondition)
401-
let full_path:&CStr = unsafe { self.construct_path(drnt) };
398+
let full_path: &CStr = unsafe { self.construct_path(drnt) };
402399
let path: Box<CStr> = full_path.into();
403400

404-
let file_type:FileType = match FileType::from_dtype(dtype){
405-
FileType::Unknown=>stat_syscall!(fstatat,self.file_descriptor().0,access_dirent!(drnt,d_name),AT_SYMLINK_NOFOLLOW,DTYPE),
406-
not_unknown=>not_unknown //if not unknown, skip the syscall (THIS IS A MASSIVE PERF WIN)
401+
let file_type: FileType = match FileType::from_dtype(dtype) {
402+
FileType::Unknown => stat_syscall!(
403+
fstatat,
404+
self.file_descriptor().0,
405+
access_dirent!(drnt, d_name),
406+
AT_SYMLINK_NOFOLLOW,
407+
DTYPE
408+
),
409+
not_unknown => not_unknown, //if not unknown, skip the syscall (THIS IS A MASSIVE PERF WIN)
407410
};
408411

409412
DirEntry {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl Finder {
334334
use_colours: bool,
335335
result_count: Option<usize>,
336336
sort: bool,
337-
print_errors:bool
337+
print_errors: bool,
338338
) -> core::result::Result<(), SearchConfigError> {
339339
let errors = self.errors.clone();
340340
let iter = self.traverse()?;

src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ macro_rules! skip_dot_or_dot_dot_entries {
249249
// Only check d_type for potential "." or ".." entries
250250
match access_dirent!($entry, d_type) {
251251
libc::DT_DIR | libc::DT_UNKNOWN => {
252-
let name_ptr:*const u8 = access_dirent!($entry, d_name);
252+
let name_ptr: *const u8 = access_dirent!($entry, d_name);
253253
// Combined check using pattern
254254
match (namelen, *name_ptr.add(0), *name_ptr.add(1)) {
255255
(1, b'.', _) => $action, // "." - length 1, first char '.'
@@ -277,7 +277,7 @@ macro_rules! skip_dot_or_dot_dot_entries {
277277
libc::DT_DIR | libc::DT_UNKNOWN => {
278278
// The value for 24 is checked in util.
279279
if access_dirent!($entry, d_reclen) == MINIMUM_DIRENT_SIZE {
280-
let name_ptr:*const u8 = access_dirent!($entry, d_name);
280+
let name_ptr: *const u8 = access_dirent!($entry, d_name);
281281
match (*name_ptr.add(0), *name_ptr.add(1), *name_ptr.add(2)) {
282282
(b'.', 0, _) | (b'.', b'.', 0) => $action, //similar to above
283283
_ => (),
@@ -303,7 +303,7 @@ macro_rules! skip_dot_or_dot_dot_entries {
303303
// Fallback for other systems: check d_type first
304304
match access_dirent!($entry, d_type) {
305305
libc::DT_DIR | libc::DT_UNKNOWN => {
306-
let name_ptr:*const u8 = access_dirent!($entry, d_name);
306+
let name_ptr: *const u8 = access_dirent!($entry, d_name);
307307
match (*name_ptr.add(0), *name_ptr.add(1), *name_ptr.add(2)) {
308308
(b'.', 0, _) | (b'.', b'.', 0) => $action,
309309
_ => (),

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn main() -> Result<(), SearchConfigError> {
281281
.thread_count(args.thread_num.unwrap_or(THREAD_COUNT))
282282
.build()?;
283283

284-
let _ = finder.print_results(args.no_colour, args.top_n, args.sort,args.show_errors);
284+
let _ = finder.print_results(args.no_colour, args.top_n, args.sort, args.show_errors);
285285

286286
Ok(())
287287
}

src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mod tests {
1111
use filetime::{FileTime, set_file_times};
1212
use std::env::temp_dir;
1313
use std::ffi::OsStr;
14+
use std::ffi::OsString;
1415
use std::fs;
1516
use std::fs::File;
1617
use std::io::Write;
@@ -19,7 +20,6 @@ mod tests {
1920
use std::os::unix::fs::symlink;
2021
use std::path::{Path, PathBuf};
2122
use std::sync::Arc;
22-
use std::{ffi::OsString};
2323

2424
use std::time::{Duration, SystemTime, UNIX_EPOCH};
2525

0 commit comments

Comments
 (0)