Kernel: Use TRY() in sys$set_process_name()

This commit is contained in:
Andreas Kling 2021-09-05 18:17:06 +02:00
parent 53aa01384d
commit 76f2596ce8
Notes: sideshowbarker 2024-07-18 04:40:54 +09:00

View file

@ -39,14 +39,12 @@ KResultOr<FlatPtr> Process::sys$set_process_name(Userspace<const char*> user_nam
REQUIRE_PROMISE(proc);
if (user_name_length > 256)
return ENAMETOOLONG;
auto name_or_error = try_copy_kstring_from_user(user_name, user_name_length);
if (name_or_error.is_error())
return name_or_error.error();
auto name = TRY(try_copy_kstring_from_user(user_name, user_name_length));
// Empty and whitespace-only names only exist to confuse users.
if (name_or_error.value()->view().is_whitespace())
if (name->view().is_whitespace())
return EINVAL;
// FIXME: There's a String copy here. Process::m_name should be a KString.
m_name = name_or_error.value()->view();
m_name = name->view();
return 0;
}