diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-29 11:52:08 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-29 11:52:08 +0200 |
| commit | 6cfc4f283c8e068bc1345c46149b90a86be40a2f (patch) | |
| tree | abe3318b61ee43e3b8d4c9893201f78152ad62f4 /Kernel | |
| parent | 0d661d2587046d3fc078bc15a089b94489c08a8d (diff) | |
[MHR-37] Last commit on ticket.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel')
| -rw-r--r-- | Kernel/KernelKit/User.hxx | 6 | ||||
| -rw-r--r-- | Kernel/Sources/Main.cxx | 3 | ||||
| -rw-r--r-- | Kernel/Sources/String.cxx | 9 | ||||
| -rw-r--r-- | Kernel/Sources/User.cxx | 10 | ||||
| -rw-r--r-- | Kernel/Sources/Utils.cxx | 5 |
5 files changed, 14 insertions, 19 deletions
diff --git a/Kernel/KernelKit/User.hxx b/Kernel/KernelKit/User.hxx index d9d9bb1e..861fd17a 100644 --- a/Kernel/KernelKit/User.hxx +++ b/Kernel/KernelKit/User.hxx @@ -40,7 +40,7 @@ namespace Kernel class User final { public: - explicit User() = default; + explicit User() = delete; User(const Int32& sel, const Char* userName); User(const RingKind& kind, const Char* userName); @@ -58,7 +58,7 @@ namespace Kernel /// @brief Get software ring const RingKind& Ring() noexcept; /// @brief Get user name - const StringView Name() noexcept; + StringView& Name() noexcept; /// @brief Is he a standard user? Bool IsStdUser() noexcept; @@ -68,7 +68,7 @@ namespace Kernel private: RingKind fRing{RingKind::kRingStdUser}; - StringView fUserName{kMaxUserNameLen}; + StringView fUserName; VoidPtr fUserToken{nullptr}; friend UserView; diff --git a/Kernel/Sources/Main.cxx b/Kernel/Sources/Main.cxx index fb9b522b..318cbe3f 100644 --- a/Kernel/Sources/Main.cxx +++ b/Kernel/Sources/Main.cxx @@ -190,9 +190,8 @@ namespace Kernel::Detail { Kernel::UserView::The()->fRootUser = new User(RingKind::kRingSuperUser, kSuperUser); - Kernel::kcout << "newoskrnl: logged in as: " << Kernel::UserView::The()->fRootUser->Name().CData() << Kernel::endl; - Kernel::UserView::The()->LogIn(Kernel::UserView::The()->fRootUser, ""); + Kernel::UserView::The()->LogIn(Kernel::UserView::The()->fRootUser, nullptr); Kernel::kcout << "newoskrnl: " << cKernelVersion.GetKey().CData() << ": " << Kernel::number(cKernelVersion.GetValue()) << Kernel::endl; } diff --git a/Kernel/Sources/String.cxx b/Kernel/Sources/String.cxx index 2ed52029..8d4c7930 100644 --- a/Kernel/Sources/String.cxx +++ b/Kernel/Sources/String.cxx @@ -214,7 +214,7 @@ namespace Kernel return ret; } - STATIC void rt_string_append(Char* lhs, Char* rhs, Int cur) + STATIC void rt_string_append(Char* lhs, const Char* rhs, Int32 cur) { SizeT sz_rhs = rt_string_len(rhs); SizeT rhs_i = 0; @@ -223,16 +223,11 @@ namespace Kernel { lhs[rhs_i + cur] = rhs[rhs_i]; } - - lhs[rhs_i + cur] = 0; } StringView& StringView::operator+=(const Char* rhs) { - if (rt_string_len(rhs) > this->Length()) - return *this; - - rt_string_append(this->fData, const_cast<Char*>(rhs), this->fCur); + rt_string_append(this->fData, rhs, this->fCur); this->fCur += rt_string_len(rhs); return *this; diff --git a/Kernel/Sources/User.cxx b/Kernel/Sources/User.cxx index a86f9ac3..92acba97 100644 --- a/Kernel/Sources/User.cxx +++ b/Kernel/Sources/User.cxx @@ -23,13 +23,16 @@ namespace Kernel : fRing((RingKind)sel) { MUST_PASS(sel >= 0); - this->fUserName += userName; + + auto view = StringBuilder::Construct(userName); + this->fUserName += view.Leak().Leak(); } User::User(const RingKind& ringKind, const Char* userName) : fRing(ringKind) { - this->fUserName += userName; + auto view = StringBuilder::Construct(userName); + this->fUserName += view.Leak().Leak(); } User::~User() = default; @@ -44,7 +47,7 @@ namespace Kernel return lhs.fRing != this->fRing; } - const StringView User::Name() noexcept + StringView& User::Name() noexcept { return this->fUserName; } @@ -111,6 +114,7 @@ namespace Kernel } fCurrentUser = user; + Kernel::kcout << "newoskrnl: logged in as: " << fCurrentUser->Name().CData() << Kernel::endl; } Void UserView::LogOff() noexcept diff --git a/Kernel/Sources/Utils.cxx b/Kernel/Sources/Utils.cxx index eeac3f93..152f28fa 100644 --- a/Kernel/Sources/Utils.cxx +++ b/Kernel/Sources/Utils.cxx @@ -29,9 +29,6 @@ namespace Kernel Size rt_string_len(const Char* str, SizeT _len) { - if (*str == '\0') - return 0; - Size len{0}; while (str[len] != '\0') { @@ -40,7 +37,7 @@ namespace Kernel return 0; } - ++len; + len++; } return len; |
