Kernel: Use TRY() in sys$set_process_name()
This commit is contained in:
parent
53aa01384d
commit
76f2596ce8
Notes:
sideshowbarker
2024-07-18 04:40:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/76f2596ce8a
1 changed files with 3 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue