Skip to content

Commit d2b4054

Browse files
authored
Update dir.rs
1 parent d5c6504 commit d2b4054

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/dir.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ impl Entry {
351351

352352

353353
#[inline]
354-
#[allow(clippy::integer_division)] //i know reclen is always a multiple of 8, so this is fine
355-
#[allow(clippy::cast_possible_truncation)] //^
356-
#[allow(clippy::integer_division_remainder_used)] //division is fine.
357354
#[allow(clippy::ptr_as_ptr)] //safe to do this as u8 is aligned to 8 bytes
358355
#[allow(clippy::cast_lossless)] //shutup
359356
/// Const-fn strlen for dirent's `d_name` field using bit tricks, no SIMD, no overreads!!!
@@ -382,12 +379,10 @@ impl Entry {
382379
/// `SWAR` (SIMD Within A Register) is used to find the first null byte in the `d_name` field of a `libc::dirent64` structure.
383380
pub const unsafe fn dirent_const_time_strlen(dirent: *const libc::dirent64) -> usize {
384381
const DIRENT_HEADER_START: usize = std::mem::offset_of!(libc::dirent64, d_name) + 1; //we're going backwards(to the start of d_name) so we add 1 to the offset
385-
let reclen = unsafe { (*dirent).d_reclen as usize}; //THIS MACRO IS MODIFIED FROM THE STANDARD LIBRARY INTERNAL IMPLEMENTATION
386-
//an internal macro, alternatively written as (my macro just makes it easy to access without worrying about alignment)
387-
// let reclen = unsafe { (*dirent).d_reclen as u16 }; (do not access it via byte_offset!)
388-
// Calculate find the start of the d_name field
382+
let reclen = unsafe { (*dirent).d_reclen as usize};
383+
//find the record-length
389384
// THIS WILL ONLY WORK ON LITTLE-ENDIAN ARCHITECTURES, I CANT BE BOTHERED TO FIGURE THAT OUT, qemu isnt fun
390-
// Calculate find the start of the d_name field
385+
// Calculate the start of the d_name field
391386
let last_word = unsafe { *((dirent as *const u8).add(reclen - 8) as *const u64) };
392387
// Special case: When processing the 3rd u64 word (index 2), we need to mask
393388
// the non-name bytes (d_type and padding) to avoid false null detection.

0 commit comments

Comments
 (0)