summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 14:38:28 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 14:38:28 +0200
commit8cd48799462ff01dfa7bcd0ba962b9bdee800e50 (patch)
tree7912cccb4d0d7b3da04b085b6faca6d1a34e9ae7 /Kernel
parentc902b3cb0d2d9dc14e5bb1172754c6144e103661 (diff)
downloadserenity-8cd48799462ff01dfa7bcd0ba962b9bdee800e50.zip
Kernel: Use TRY() in sys$link() and sys$symlink()
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Syscalls/link.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/Kernel/Syscalls/link.cpp b/Kernel/Syscalls/link.cpp
index d0b08125ac..f0b6e44ecf 100644
--- a/Kernel/Syscalls/link.cpp
+++ b/Kernel/Syscalls/link.cpp
@@ -17,13 +17,9 @@ KResultOr<FlatPtr> Process::sys$link(Userspace<const Syscall::SC_link_params*> u
Syscall::SC_link_params params;
if (!copy_from_user(&params, user_params))
return EFAULT;
- auto old_path_or_error = try_copy_kstring_from_user(params.old_path);
- if (old_path_or_error.is_error())
- return old_path_or_error.error();
- auto new_path_or_error = try_copy_kstring_from_user(params.new_path);
- if (new_path_or_error.is_error())
- return new_path_or_error.error();
- return VirtualFileSystem::the().link(old_path_or_error.value()->view(), new_path_or_error.value()->view(), current_directory());
+ auto old_path = TRY(try_copy_kstring_from_user(params.old_path));
+ auto new_path = TRY(try_copy_kstring_from_user(params.new_path));
+ return VirtualFileSystem::the().link(old_path->view(), new_path->view(), current_directory());
}
KResultOr<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_params*> user_params)
@@ -33,13 +29,9 @@ KResultOr<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_para
Syscall::SC_symlink_params params;
if (!copy_from_user(&params, user_params))
return EFAULT;
- auto target = get_syscall_path_argument(params.target);
- if (target.is_error())
- return target.error();
- auto linkpath = get_syscall_path_argument(params.linkpath);
- if (linkpath.is_error())
- return linkpath.error();
- return VirtualFileSystem::the().symlink(target.value()->view(), linkpath.value()->view(), current_directory());
+ auto target = TRY(get_syscall_path_argument(params.target));
+ auto linkpath = TRY(get_syscall_path_argument(params.linkpath));
+ return VirtualFileSystem::the().symlink(target->view(), linkpath->view(), current_directory());
}
}