From 207f3f1cb4e5cdeb53dffcaec63a4a1e958ce6d1 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 27 Apr 2024 08:39:41 -0400 Subject: [PATCH] LibCore: Remove unnecessary lifetime extension from ProcessSpawnOptions We don't need `file_actions` to be a constant-reference. It's created in-place by its one user (HackStudio). Because it is currently a const- ref, if we try to create a ProcessSpawnOptions like so: Core::ProcessSpawnOptions options { .name = "foo"sv }; We get the following error with clang 18: lifetime extension of temporary created by aggregate initialization using a default member initializer is not yet supported; lifetime of temporary will end at the end of the full-expression --- Userland/Libraries/LibCore/Process.cpp | 2 +- Userland/Libraries/LibCore/Process.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCore/Process.cpp b/Userland/Libraries/LibCore/Process.cpp index 52267c97146..3935750a25b 100644 --- a/Userland/Libraries/LibCore/Process.cpp +++ b/Userland/Libraries/LibCore/Process.cpp @@ -364,7 +364,7 @@ ErrorOr IPCProcess::spawn_and_connect_to_proces ArmedScopeGuard guard_fd_0 { [&] { MUST(System::close(socket_fds[0])); } }; ArmedScopeGuard guard_fd_1 { [&] { MUST(System::close(socket_fds[1])); } }; - auto& file_actions = const_cast&>(options.file_actions); + auto& file_actions = const_cast(options).file_actions; file_actions.append(FileAction::CloseFile { socket_fds[0] }); auto takeover_string = MUST(String::formatted("{}:{}", options.name, socket_fds[1])); diff --git a/Userland/Libraries/LibCore/Process.h b/Userland/Libraries/LibCore/Process.h index 78db8d8dbff..18c7b918097 100644 --- a/Userland/Libraries/LibCore/Process.h +++ b/Userland/Libraries/LibCore/Process.h @@ -41,7 +41,7 @@ struct ProcessSpawnOptions { Optional working_directory {}; using FileActionType = Variant; - Vector const& file_actions {}; + Vector file_actions {}; }; class IPCProcess;