Procházet zdrojové kódy

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

Andreas Kling před 3 roky
rodič
revize
76f2596ce8
1 změnil soubory, kde provedl 3 přidání a 5 odebrání
  1. 3 5
      Kernel/Syscalls/process.cpp

+ 3 - 5
Kernel/Syscalls/process.cpp

@@ -39,14 +39,12 @@ KResultOr<FlatPtr> Process::sys$set_process_name(Userspace<const char*> user_nam
     REQUIRE_PROMISE(proc);
     REQUIRE_PROMISE(proc);
     if (user_name_length > 256)
     if (user_name_length > 256)
         return ENAMETOOLONG;
         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.
     // 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;
         return EINVAL;
     // FIXME: There's a String copy here. Process::m_name should be a KString.
     // 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;
     return 0;
 }
 }