1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:52:07 +00:00

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

This commit is contained in:
Andreas Kling 2021-09-05 18:22:18 +02:00
parent 963f847579
commit 2d2ea05c97

View file

@ -30,12 +30,10 @@ KResultOr<FlatPtr> Process::sys$sethostname(Userspace<const char*> buffer, size_
return EPERM;
if (length > 64)
return ENAMETOOLONG;
auto new_name = TRY(try_copy_kstring_from_user(buffer, length));
return hostname().with_exclusive([&](auto& name) -> KResultOr<FlatPtr> {
auto name_or_error = try_copy_kstring_from_user(buffer, length);
if (name_or_error.is_error())
return name_or_error.error();
// FIXME: Use KString instead of String here.
name = name_or_error.value()->view();
name = new_name->view();
return 0;
});
}