diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 19:38:22 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 19:38:22 +0100 |
| commit | f651858b579138d5df0f89363879825513ece227 (patch) | |
| tree | 7f9fc7f18d7948e4c969b3901e9ca6559f4941d9 | |
| parent | ed6d2f6007b572b907e3cb11b4303c13d1572c9c (diff) | |
chore: MKFS library improvements on documentation.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | src/boot/src/BootThread.cc | 2 | ||||
| -rw-r--r-- | src/kernel/NeKit/Atom.h | 19 | ||||
| -rw-r--r-- | src/kernel/NeKit/InitializerList.h | 10 | ||||
| -rw-r--r-- | src/kernel/NeKit/Ref.h | 2 | ||||
| -rw-r--r-- | src/kernel/src/Swap/DiskSwap.cc | 3 | ||||
| -rw-r--r-- | src/libDDK/DriverKit/c++/driver_base.h | 10 | ||||
| -rw-r--r-- | src/libDDK/src/ddk_c++.cc | 2 | ||||
| -rw-r--r-- | tools/libmkfs/mkfs.h | 18 |
8 files changed, 40 insertions, 26 deletions
diff --git a/src/boot/src/BootThread.cc b/src/boot/src/BootThread.cc index 7d3beba8..fcd0d0a3 100644 --- a/src/boot/src/BootThread.cc +++ b/src/boot/src/BootThread.cc @@ -28,7 +28,7 @@ EXTERN_C Int32 rt_jump_to_address(VoidPtr code, HEL::BootInfoHeader* handover, U BootThread::BootThread(VoidPtr blob) : fStartAddress(nullptr), fBlob(blob) { // detect the image format (PEF, PE32, etc.) - const Char* blob_bytes = static_cast<Char*>(fBlob); + const Char* blob_bytes = static_cast<Char*>(fBlob); BootTextWriter writer; if (!blob_bytes) { diff --git a/src/kernel/NeKit/Atom.h b/src/kernel/NeKit/Atom.h index 7deff14e..7c5177fe 100644 --- a/src/kernel/NeKit/Atom.h +++ b/src/kernel/NeKit/Atom.h @@ -22,14 +22,21 @@ class Atom final { public: using Type = TypeAtomic; - + const TypeAtomic& operator[](const SizeT& bit) { return (fArrayOfAtoms & (1 << bit)); } - void operator|(const SizeT& bit) { fArrayOfAtoms |= (1 << bit); } - Atom& operator|=(const SizeT& bit) { this->operator|(bit); return *this; } - - friend bool operator==(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { return atomic[idx] == idx; } - friend bool operator!=(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { return atomic[idx] != idx; } + void operator|(const SizeT& bit) { fArrayOfAtoms |= (1 << bit); } + Atom& operator|=(const SizeT& bit) { + this->operator|(bit); + return *this; + } + + friend bool operator==(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { + return atomic[idx] == idx; + } + friend bool operator!=(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { + return atomic[idx] != idx; + } private: TypeAtomic fArrayOfAtoms; diff --git a/src/kernel/NeKit/InitializerList.h b/src/kernel/NeKit/InitializerList.h index 46639d4d..e21bd6bd 100644 --- a/src/kernel/NeKit/InitializerList.h +++ b/src/kernel/NeKit/InitializerList.h @@ -11,12 +11,12 @@ #include <NeKit/ErrorOr.h> namespace Kernel { - // \brief Initalizer List object for containers. +// \brief Initalizer List object for containers. template <class Type, SizeT N> class InitializerList final { public: InitializerList() = delete; - + explicit InitializerList(const Type* list) { if constexpr (N > 0) { for (auto i = 0UL; i < N; ++i) { @@ -30,9 +30,9 @@ class InitializerList final { InitializerList& operator=(const InitializerList&) = delete; InitializerList(const InitializerList&) = delete; - Type* begin() { return fList; } - Type* end() { return fList + N; } - + Type* begin() { return fList; } + Type* end() { return fList + N; } + constexpr SizeT size() const { return N; } Type* operator->() { return this->begin(); } diff --git a/src/kernel/NeKit/Ref.h b/src/kernel/NeKit/Ref.h index 4767f728..b4d6cb5e 100644 --- a/src/kernel/NeKit/Ref.h +++ b/src/kernel/NeKit/Ref.h @@ -11,8 +11,8 @@ #include <CompilerKit/CompilerKit.h> #include <KernelKit/HeapMgr.h> #include <NeKit/Config.h> -#include <NeKit/KernelPanic.h> #include <NeKit/Domain.h> +#include <NeKit/KernelPanic.h> #include <NeKit/Vettable.h> namespace Kernel { diff --git a/src/kernel/src/Swap/DiskSwap.cc b/src/kernel/src/Swap/DiskSwap.cc index 0f97eb4d..fcf962fa 100644 --- a/src/kernel/src/Swap/DiskSwap.cc +++ b/src/kernel/src/Swap/DiskSwap.cc @@ -37,8 +37,7 @@ BOOL IDiskSwap::Write(const Char* fork_name, SizeT fork_name_len, SwapDiskHdr* d /// @param data the data packet length. /// @return Whether the swap was fetched to disk, or not. /***********************************************************************************/ -SwapDiskHdr* IDiskSwap::Read(const Char* fork_name, SizeT fork_name_len, - SizeT data_len) { +SwapDiskHdr* IDiskSwap::Read(const Char* fork_name, SizeT fork_name_len, SizeT data_len) { if (!fork_name || !fork_name_len) return nullptr; if (*fork_name == 0) return nullptr; diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h index 683969f3..002cd768 100644 --- a/src/libDDK/DriverKit/c++/driver_base.h +++ b/src/libDDK/DriverKit/c++/driver_base.h @@ -31,9 +31,9 @@ class IDriverBase { using PtrType = void*; - virtual constexpr bool IsCastable() { return false; } - virtual constexpr bool IsActive() { return false; } - virtual PtrType Leak() { return nullptr; } + virtual constexpr bool IsCastable() { return false; } + virtual constexpr bool IsActive() { return false; } + virtual PtrType Leak() { return nullptr; } virtual constexpr int32_t Type() { return kInvalidType; } }; @@ -46,5 +46,7 @@ concept IsValidDriver = requires(Driver driver_base) { /// @brief Consteval helper to detect whether a template is truly based on IDriverBase. /// @note This helper is consteval only. template <class Driver> -inline bool ce_ddk_is_valid(Driver drv) { return IsValidDriver<Driver>(drv); } +inline bool ce_ddk_is_valid(Driver drv) { + return IsValidDriver<Driver>(drv); +} } // namespace Kernel::DDK diff --git a/src/libDDK/src/ddk_c++.cc b/src/libDDK/src/ddk_c++.cc index 920697ac..3acbb527 100644 --- a/src/libDDK/src/ddk_c++.cc +++ b/src/libDDK/src/ddk_c++.cc @@ -5,5 +5,3 @@ ======================================== */ #include <libDDK/DriverKit/c++/driver_base.h> - - diff --git a/tools/libmkfs/mkfs.h b/tools/libmkfs/mkfs.h index e3ce19b5..787f93a1 100644 --- a/tools/libmkfs/mkfs.h +++ b/tools/libmkfs/mkfs.h @@ -23,7 +23,8 @@ namespace detail { return static_cast<size_t>(gb) * 1024ULL * 1024ULL * 1024ULL; } - inline bool parse_decimal(const std::string& opt, unsigned long long& out) { + /// \brief Parse decimal parameter. + inline bool parse_decimal(const std::string& opt, long& out) { if (opt.empty()) return false; char* endptr = nullptr; unsigned long long val = std::strtoull(opt.c_str(), &endptr, 10); @@ -32,7 +33,8 @@ namespace detail { return true; } - inline bool parse_signed(const std::string& opt, long& out, int base = 10) { + /// \brief Parse decimal with numerical base. + inline bool parse_signed(const std::string& opt, long& out, const int& base = 10) { out = 0L; if (opt.empty()) return true; @@ -48,6 +50,7 @@ namespace detail { return true; } + /// \brief Helper to build arguments for filesystem tooling. inline std::string build_args(int argc, char** argv) { std::string combined; for (int i = 1; i < argc; ++i) { @@ -59,7 +62,7 @@ namespace detail { } // namespace detail /// @brief Helper function to get the option value from command line arguments. -template <typename CharType> +template <typename CharType = char> inline std::basic_string<CharType> get_option(const std::basic_string<CharType>& args, const std::basic_string<CharType>& option) { size_t pos = args.find(CharType('-') + option + CharType('=')); @@ -67,10 +70,15 @@ inline std::basic_string<CharType> get_option(const std::basic_string<CharType>& if (pos != std::string::npos) { size_t start = pos + option.length() + 2; size_t end = args.find(' ', start); + + if (end == std::string::npos) { + return {}; + } + return args.substr(start, end - start); } - return std::basic_string<CharType>{}; + return {}; } inline auto console_out() -> std::ostream& { @@ -79,4 +87,4 @@ inline auto console_out() -> std::ostream& { return conout; } -} // namespace mkfs
\ No newline at end of file +} // namespace mkfs |
