diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:22:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:22:18 +0200 |
commit | 2d2ea05c97e97848f431b5c9e5f709fe276eb7c8 (patch) | |
tree | 07aa97be4a3e6236fa5c1fb5444f88f733af7eb2 /Kernel/Syscalls | |
parent | 963f847579637eacda1ac4ed542ce9d731fc454d (diff) | |
download | serenity-2d2ea05c97e97848f431b5c9e5f709fe276eb7c8.zip |
Kernel: Use TRY() in sys$sethostname()
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/hostname.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Kernel/Syscalls/hostname.cpp b/Kernel/Syscalls/hostname.cpp index 69f2132e3f..7dd259522a 100644 --- a/Kernel/Syscalls/hostname.cpp +++ b/Kernel/Syscalls/hostname.cpp @@ -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; }); } |