summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/execve.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-09-15 23:49:08 -0700
committerAndreas Kling <kling@serenityos.org>2021-09-16 17:17:13 +0200
commite8ec1e908dd63e686b085751fad04cfb5088f614 (patch)
tree405fede8f1629211f67c693137374f430d41ba5f /Kernel/Syscalls/execve.cpp
parentb530201111d02028f37ae7d103615109fad061a8 (diff)
downloadserenity-e8ec1e908dd63e686b085751fad04cfb5088f614.zip
Kernel: Only instantiate main_program_metadata in the scope it's needed
pvs-studio flagged this as a potential perf optimization.
Diffstat (limited to 'Kernel/Syscalls/execve.cpp')
-rw-r--r--Kernel/Syscalls/execve.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index 477c92464f..ac0529ab87 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -454,8 +454,6 @@ KResult Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_descrip
auto new_process_name = TRY(KString::try_create(parts.last()));
auto new_main_thread_name = TRY(new_process_name->try_clone());
- auto main_program_metadata = main_program_description->metadata();
-
auto load_result = TRY(load(main_program_description, interpreter_description, main_program_header));
// NOTE: We don't need the interpreter executable description after this point.
@@ -488,6 +486,7 @@ KResult Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_descrip
bool executable_is_setid = false;
if (!(main_program_description->custody()->mount_flags() & MS_NOSUID)) {
+ auto main_program_metadata = main_program_description->metadata();
if (main_program_metadata.is_setuid()) {
executable_is_setid = true;
ProtectedDataMutationScope scope { *this };