diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-10 02:11:33 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-10 02:11:33 +0200 |
| commit | 34ff4ddd4ddeb4a8262dc86cdddc3677e5bfbc72 (patch) | |
| tree | 3734dc90a09a5ff65e62c9316b17e76acb3c3fc2 | |
| parent | 6e0874b728865db30475242fd6770de871a98b56 (diff) | |
feat: Fix FNV's pointer check.
why:
- It doesn't have any pointer check.
- We could save cycles by also checking for `*path == 0`
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | dev/kernel/src/FS/HeFS+FileSystemParser.cc | 2 | ||||
| -rw-r--r-- | dev/libSystem/SystemKit/Syscall.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/dev/kernel/src/FS/HeFS+FileSystemParser.cc b/dev/kernel/src/FS/HeFS+FileSystemParser.cc index 8092f53b..344369d5 100644 --- a/dev/kernel/src/FS/HeFS+FileSystemParser.cc +++ b/dev/kernel/src/FS/HeFS+FileSystemParser.cc @@ -89,6 +89,8 @@ namespace Detail { /// @param path the directory path. /// @return The hashed path. STATIC UInt64 hefsi_hash_64(const Utf8Char* path) { + if (!path || *path == 0) return 0; + const UInt64 FNV_OFFSET_BASIS = 0xcbf29ce484222325ULL; const UInt64 FNV_PRIME = 0x100000001b3ULL; diff --git a/dev/libSystem/SystemKit/Syscall.h b/dev/libSystem/SystemKit/Syscall.h index 5a840df1..a1505b46 100644 --- a/dev/libSystem/SystemKit/Syscall.h +++ b/dev/libSystem/SystemKit/Syscall.h @@ -15,6 +15,8 @@ IMPORT_C VoidPtr libsys_syscall_arg_3(SizeT id, VoidPtr arg1, VoidPtr arg3); IMPORT_C VoidPtr libsys_syscall_arg_4(SizeT id, VoidPtr arg1, VoidPtr arg3, VoidPtr arg4); inline UInt64 libsys_hash_64(const Char* path) { + if (!path || *path == 0) return 0; + const UInt64 FNV_OFFSET_BASIS = 0xcbf29ce484222325ULL; const UInt64 FNV_PRIME = 0x100000001b3ULL; |
