mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
Kernel: Make KString factories return KResultOr + use TRY() everywhere
There are a number of places that don't have an error propagation path right now, so I've added FIXME's about that.
This commit is contained in:
parent
69b9b2888c
commit
56a2594de7
21 changed files with 100 additions and 122 deletions
|
@ -26,20 +26,18 @@ Kernel::KResultOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Use
|
|||
return EFAULT;
|
||||
}
|
||||
char* buffer;
|
||||
auto new_string = Kernel::KString::try_create_uninitialized(length, buffer);
|
||||
if (!new_string)
|
||||
return ENOMEM;
|
||||
auto new_string = TRY(Kernel::KString::try_create_uninitialized(length, buffer));
|
||||
|
||||
buffer[length] = '\0';
|
||||
|
||||
if (length == 0)
|
||||
return new_string.release_nonnull();
|
||||
return new_string;
|
||||
|
||||
if (!Kernel::safe_memcpy(buffer, user_str.unsafe_userspace_ptr(), (size_t)length, fault_at)) {
|
||||
dbgln("copy_kstring_from_user({:p}, {}) failed at {} (memcpy)", static_cast<const void*>(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at });
|
||||
return EFAULT;
|
||||
}
|
||||
return new_string.release_nonnull();
|
||||
return new_string;
|
||||
}
|
||||
|
||||
[[nodiscard]] Optional<Time> copy_time_from_user(const timespec* ts_user)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue