From 229b64a4b723a391c21f247d72d78cd575ace6ff Mon Sep 17 00:00:00 2001 From: Asutosh Variar <96536388+asutoshvariar@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:06:15 +0400 Subject: [PATCH] Everywhere: Convert from_string_view -> from_string_literal where static --- .../src/main/cpp/RequestServerService.cpp | 2 +- Ladybird/Qt/AutoComplete.cpp | 14 ++++---- Ladybird/RequestServer/main.cpp | 2 +- Tests/AK/TestJSON.cpp | 4 +-- Userland/Libraries/LibAudio/FlacWriter.cpp | 24 ++++++------- Userland/Libraries/LibAudio/MultiChannel.h | 4 +-- Userland/Libraries/LibAudio/VorbisComment.cpp | 2 +- Userland/Libraries/LibCore/Process.cpp | 2 +- .../LibCore/ResourceImplementation.cpp | 2 +- Userland/Libraries/LibCore/System.cpp | 6 ++-- Userland/Libraries/LibCore/VulkanContext.cpp | 6 ++-- Userland/Libraries/LibCrypto/ASN1/DER.h | 4 +-- Userland/Libraries/LibCrypto/Hash/MGF.h | 2 +- Userland/Libraries/LibCrypto/Hash/PBKDF2.h | 2 +- Userland/Libraries/LibCrypto/Padding/OAEP.h | 2 +- Userland/Libraries/LibTLS/Certificate.cpp | 2 +- Userland/Libraries/LibWeb/ARIA/RoleType.cpp | 2 +- .../LibWeb/Crypto/CryptoAlgorithms.cpp | 8 ++--- Userland/Libraries/LibWeb/DOM/Element.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Responses.cpp | 2 +- .../LibWeb/WebDriver/Capabilities.cpp | 12 +++---- .../LibWebView/ViewImplementation.cpp | 2 +- Userland/Services/WebDriver/Client.cpp | 2 +- Userland/Utilities/aconv.cpp | 12 +++---- Userland/Utilities/animation.cpp | 4 +-- Userland/Utilities/image.cpp | 34 +++++++++---------- 26 files changed, 80 insertions(+), 80 deletions(-) diff --git a/Ladybird/Android/src/main/cpp/RequestServerService.cpp b/Ladybird/Android/src/main/cpp/RequestServerService.cpp index e38732bda4a..7fd4be4c590 100644 --- a/Ladybird/Android/src/main/cpp/RequestServerService.cpp +++ b/Ladybird/Android/src/main/cpp/RequestServerService.cpp @@ -25,7 +25,7 @@ static ErrorOr find_certificates(StringView serenity_resource_root) { auto cert_path = ByteString::formatted("{}/res/ladybird/cacert.pem", serenity_resource_root); if (!FileSystem::exists(cert_path)) - return Error::from_string_view("Don't know how to load certs!"sv); + return Error::from_string_literal("Don't know how to load certs!"); return cert_path; } diff --git a/Ladybird/Qt/AutoComplete.cpp b/Ladybird/Qt/AutoComplete.cpp index 9ee81e4b6da..0f4f3975e4d 100644 --- a/Ladybird/Qt/AutoComplete.cpp +++ b/Ladybird/Qt/AutoComplete.cpp @@ -41,18 +41,18 @@ AutoComplete::AutoComplete(QWidget* parent) ErrorOr> AutoComplete::parse_google_autocomplete(Vector const& json) { if (json.size() != 5) - return Error::from_string_view("Invalid JSON, expected 5 elements in array"sv); + return Error::from_string_literal("Invalid JSON, expected 5 elements in array"); if (!json[0].is_string()) - return Error::from_string_view("Invalid JSON, expected first element to be a string"sv); + return Error::from_string_literal("Invalid JSON, expected first element to be a string"); auto query = TRY(String::from_byte_string(json[0].as_string())); if (!json[1].is_array()) - return Error::from_string_view("Invalid JSON, expected second element to be an array"sv); + return Error::from_string_literal("Invalid JSON, expected second element to be an array"); auto suggestions_array = json[1].as_array().values(); if (query != m_query) - return Error::from_string_view("Invalid JSON, query does not match"sv); + return Error::from_string_literal("Invalid JSON, query does not match"); Vector results; results.ensure_capacity(suggestions_array.size()); @@ -86,13 +86,13 @@ ErrorOr> AutoComplete::parse_yahoo_autocomplete(JsonObject const& auto suggestions_object = json.get("r"sv)->as_array().values(); if (query != m_query) - return Error::from_string_view("Invalid JSON, query does not match"sv); + return Error::from_string_literal("Invalid JSON, query does not match"); Vector results; results.ensure_capacity(suggestions_object.size()); for (auto& suggestion_object : suggestions_object) { if (!suggestion_object.is_object()) - return Error::from_string_view("Invalid JSON, expected value to be an object"sv); + return Error::from_string_literal("Invalid JSON, expected value to be an object"); auto suggestion = suggestion_object.as_object(); if (!suggestion.get("k"sv).has_value() || !suggestion.get("k"sv)->is_string()) @@ -121,7 +121,7 @@ ErrorOr AutoComplete::got_network_response(QNetworkReply* reply) } else if (engine_name == "Yahoo") results = TRY(parse_yahoo_autocomplete(json.as_object())); else { - return Error::from_string_view("Invalid engine name"sv); + return Error::from_string_literal("Invalid engine name"); } constexpr size_t MAX_AUTOCOMPLETE_RESULTS = 6; diff --git a/Ladybird/RequestServer/main.cpp b/Ladybird/RequestServer/main.cpp index cb565d14c9b..d401a558cf2 100644 --- a/Ladybird/RequestServer/main.cpp +++ b/Ladybird/RequestServer/main.cpp @@ -28,7 +28,7 @@ static ErrorOr find_certificates(StringView serenity_resource_root) { auto cert_path = ByteString::formatted("{}/ladybird/cacert.pem", serenity_resource_root); if (!FileSystem::exists(cert_path)) - return Error::from_string_view("Don't know how to load certs!"sv); + return Error::from_string_literal("Don't know how to load certs!"); return cert_path; } diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp index a53410391cd..8c49755e9b8 100644 --- a/Tests/AK/TestJSON.cpp +++ b/Tests/AK/TestJSON.cpp @@ -334,7 +334,7 @@ TEST_CASE(fallible_json_object_for_each) })); auto result1 = object.try_for_each_member([](auto const&, auto const&) -> ErrorOr { - return Error::from_string_view("nanananana"sv); + return Error::from_string_literal("nanananana"); }); EXPECT(result1.is_error()); EXPECT_EQ(result1.error().string_literal(), "nanananana"sv); @@ -374,7 +374,7 @@ TEST_CASE(fallible_json_array_for_each) })); auto result1 = array.try_for_each([](auto const&) -> ErrorOr { - return Error::from_string_view("nanananana"sv); + return Error::from_string_literal("nanananana"); }); EXPECT(result1.is_error()); EXPECT_EQ(result1.error().string_literal(), "nanananana"sv); diff --git a/Userland/Libraries/LibAudio/FlacWriter.cpp b/Userland/Libraries/LibAudio/FlacWriter.cpp index 18c66efb8c7..434e6411d14 100644 --- a/Userland/Libraries/LibAudio/FlacWriter.cpp +++ b/Userland/Libraries/LibAudio/FlacWriter.cpp @@ -40,7 +40,7 @@ FlacWriter::~FlacWriter() ErrorOr FlacWriter::finalize() { if (m_state == WriteState::FullyFinalized) - return Error::from_string_view("File is already finalized"sv); + return Error::from_string_literal("File is already finalized"); if (m_state == WriteState::HeaderUnwritten) TRY(finalize_header_format()); @@ -74,7 +74,7 @@ ErrorOr FlacWriter::finalize() ErrorOr FlacWriter::finalize_header_format() { if (m_state != WriteState::HeaderUnwritten) - return Error::from_string_view("Header format is already finalized"sv); + return Error::from_string_literal("Header format is already finalized"); TRY(write_header()); m_state = WriteState::FormatFinalized; return {}; @@ -83,9 +83,9 @@ ErrorOr FlacWriter::finalize_header_format() ErrorOr FlacWriter::set_num_channels(u8 num_channels) { if (m_state != WriteState::HeaderUnwritten) - return Error::from_string_view("Header format is already finalized"sv); + return Error::from_string_literal("Header format is already finalized"); if (num_channels > 8) - return Error::from_string_view("FLAC doesn't support more than 8 channels"sv); + return Error::from_string_literal("FLAC doesn't support more than 8 channels"); m_num_channels = num_channels; return {}; @@ -94,7 +94,7 @@ ErrorOr FlacWriter::set_num_channels(u8 num_channels) ErrorOr FlacWriter::set_sample_rate(u32 sample_rate) { if (m_state != WriteState::HeaderUnwritten) - return Error::from_string_view("Header format is already finalized"sv); + return Error::from_string_literal("Header format is already finalized"); m_sample_rate = sample_rate; return {}; @@ -103,9 +103,9 @@ ErrorOr FlacWriter::set_sample_rate(u32 sample_rate) ErrorOr FlacWriter::set_bits_per_sample(u16 bits_per_sample) { if (m_state != WriteState::HeaderUnwritten) - return Error::from_string_view("Header format is already finalized"sv); + return Error::from_string_literal("Header format is already finalized"); if (bits_per_sample < 8 || bits_per_sample > 32) - return Error::from_string_view("FLAC only supports bits per sample between 8 and 32"sv); + return Error::from_string_literal("FLAC only supports bits per sample between 8 and 32"); m_bits_per_sample = bits_per_sample; return {}; @@ -246,7 +246,7 @@ ErrorOr FlacWriter::write_header() ErrorOr FlacWriter::add_metadata_block(FlacRawMetadataBlock block, Optional insertion_index) { if (m_state != WriteState::HeaderUnwritten) - return Error::from_string_view("Metadata blocks can only be added before the header is finalized"sv); + return Error::from_string_literal("Metadata blocks can only be added before the header is finalized"); if (insertion_index.has_value()) TRY(m_cached_metadata_blocks.try_insert(insertion_index.value(), move(block))); @@ -260,11 +260,11 @@ ErrorOr FlacWriter::write_metadata_block(FlacRawMetadataBlock& block) { if (m_state == WriteState::FormatFinalized) { if (!m_last_padding.has_value()) - return Error::from_string_view("No (more) padding available to write block into"sv); + return Error::from_string_literal("No (more) padding available to write block into"); auto const last_padding = m_last_padding.release_value(); if (block.length > last_padding.size) - return Error::from_string_view("Late metadata block doesn't fit in available padding"sv); + return Error::from_string_literal("Late metadata block doesn't fit in available padding"); auto const current_position = TRY(m_stream->tell()); ScopeGuard guard = [&] { (void)m_stream->seek(current_position, SeekMode::SetPosition); }; @@ -294,7 +294,7 @@ ErrorOr FlacWriter::write_metadata_block(FlacRawMetadataBlock& block) }; TRY(m_stream->write_value(new_padding_block)); } else if (new_size != 0) { - return Error::from_string_view("Remaining padding is not divisible by 4, there will be some stray zero bytes!"sv); + return Error::from_string_literal("Remaining padding is not divisible by 4, there will be some stray zero bytes!"); } return {}; @@ -482,7 +482,7 @@ ErrorOr FlacFrameHeader::write_to_stream(Stream& stream) const ErrorOr FlacWriter::write_samples(ReadonlySpan samples) { if (m_state == WriteState::FullyFinalized) - return Error::from_string_view("File is already finalized"sv); + return Error::from_string_literal("File is already finalized"); auto remaining_samples = samples; while (remaining_samples.size() > 0) { diff --git a/Userland/Libraries/LibAudio/MultiChannel.h b/Userland/Libraries/LibAudio/MultiChannel.h index c2fe280815f..d88873acf2d 100644 --- a/Userland/Libraries/LibAudio/MultiChannel.h +++ b/Userland/Libraries/LibAudio/MultiChannel.h @@ -26,7 +26,7 @@ template ChannelType, ArrayLike InputType> ErrorOr> downmix_surround_to_stereo(InputType const& input, float sample_scale_factor) { if (input.size() == 0) - return Error::from_string_view("Cannot resample from 0 channels"sv); + return Error::from_string_literal("Cannot resample from 0 channels"); auto channel_count = input.size(); auto sample_count = input[0].size(); @@ -94,7 +94,7 @@ ErrorOr> downmix_surround_to_stereo(InputType const& input, f } break; default: - return Error::from_string_view("Invalid number of channels greater than 8"sv); + return Error::from_string_literal("Invalid number of channels greater than 8"); } return output; diff --git a/Userland/Libraries/LibAudio/VorbisComment.cpp b/Userland/Libraries/LibAudio/VorbisComment.cpp index 74e58f8af9f..91f54f4f452 100644 --- a/Userland/Libraries/LibAudio/VorbisComment.cpp +++ b/Userland/Libraries/LibAudio/VorbisComment.cpp @@ -33,7 +33,7 @@ static ErrorOr read_vorbis_field(Metadata& metadata_to_write_into, String auto field_name_and_contents = TRY(unparsed_user_comment.split_limit('=', 2)); if (field_name_and_contents.size() != 2) - return Error::from_string_view("User comment does not contain '='"sv); + return Error::from_string_literal("User comment does not contain '='"); auto contents = field_name_and_contents.take_last(); auto field_name = TRY(field_name_and_contents.take_first().to_uppercase()); diff --git a/Userland/Libraries/LibCore/Process.cpp b/Userland/Libraries/LibCore/Process.cpp index 11f988b95f8..a2c65aaeb43 100644 --- a/Userland/Libraries/LibCore/Process.cpp +++ b/Userland/Libraries/LibCore/Process.cpp @@ -299,7 +299,7 @@ ErrorOr Process::is_being_debugged() # endif #endif // FIXME: Implement this for more platforms. - return Error::from_string_view("Platform does not support checking for debugger"sv); + return Error::from_string_literal("Platform does not support checking for debugger"); } // Forces the process to sleep until a debugger is attached, then breaks. diff --git a/Userland/Libraries/LibCore/ResourceImplementation.cpp b/Userland/Libraries/LibCore/ResourceImplementation.cpp index 7917adcc941..2834124acef 100644 --- a/Userland/Libraries/LibCore/ResourceImplementation.cpp +++ b/Userland/Libraries/LibCore/ResourceImplementation.cpp @@ -59,7 +59,7 @@ ErrorOr> ResourceImplementation::load_from_uri(StringVie } dbgln("ResourceImplementation: Unknown scheme for {}", uri); - return Error::from_string_view("Invalid scheme"sv); + return Error::from_string_literal("Invalid scheme"); } Vector ResourceImplementation::child_names(Resource const& resource) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 8df13df172b..fcbc7c869b8 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -1825,16 +1825,16 @@ ErrorOr current_executable_path() for (int32 cookie { 0 }; get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK && info.type != B_APP_IMAGE;) ; if (info.type != B_APP_IMAGE) - return Error::from_string_view("current_executable_path() failed"sv); + return Error::from_string_literal("current_executable_path() failed"); if (sizeof(info.name) > sizeof(path)) return Error::from_errno(ENAMETOOLONG); strlcpy(path, info.name, sizeof(path) - 1); #elif defined(AK_OS_EMSCRIPTEN) - return Error::from_string_view("current_executable_path() unknown on this platform"sv); + return Error::from_string_literal("current_executable_path() unknown on this platform"); #else # warning "Not sure how to get current_executable_path on this platform!" // GetModuleFileName on Windows, unsure about OpenBSD. - return Error::from_string_view("current_executable_path unknown"sv); + return Error::from_string_literal("current_executable_path unknown"); #endif path[sizeof(path) - 1] = '\0'; return ByteString { path, strlen(path) }; diff --git a/Userland/Libraries/LibCore/VulkanContext.cpp b/Userland/Libraries/LibCore/VulkanContext.cpp index 32d5331fee8..5680116dbd5 100644 --- a/Userland/Libraries/LibCore/VulkanContext.cpp +++ b/Userland/Libraries/LibCore/VulkanContext.cpp @@ -29,7 +29,7 @@ static ErrorOr create_instance(uint32_t api_version) auto result = vkCreateInstance(&create_info, nullptr, &instance); if (result != VK_SUCCESS) { dbgln("vkCreateInstance returned {}", to_underlying(result)); - return Error::from_string_view("Application instance creation failed"sv); + return Error::from_string_literal("Application instance creation failed"); } return instance; @@ -41,7 +41,7 @@ static ErrorOr pick_physical_device(VkInstance instance) vkEnumeratePhysicalDevices(instance, &device_count, nullptr); if (device_count == 0) - return Error::from_string_view("Can't find any physical devices available"sv); + return Error::from_string_literal("Can't find any physical devices available"); Vector devices; devices.resize(device_count); @@ -100,7 +100,7 @@ static ErrorOr create_logical_device(VkPhysicalDevice physical_device) create_device_info.pEnabledFeatures = &deviceFeatures; if (vkCreateDevice(physical_device, &create_device_info, nullptr, &device) != VK_SUCCESS) { - return Error::from_string_view("Logical device creation failed"sv); + return Error::from_string_literal("Logical device creation failed"); } return device; diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.h b/Userland/Libraries/LibCrypto/ASN1/DER.h index aa2e5de325f..b9a09d7b0b3 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.h +++ b/Userland/Libraries/LibCrypto/ASN1/DER.h @@ -77,10 +77,10 @@ public: ErrorOr rewrite_tag(Kind kind) { if (m_stack.is_empty()) - return Error::from_string_view("Nothing on stack to rewrite"sv); + return Error::from_string_literal("Nothing on stack to rewrite"); if (eof()) - return Error::from_string_view("Stream is empty"sv); + return Error::from_string_literal("Stream is empty"); if (m_current_tag.has_value()) { m_current_tag->kind = kind; diff --git a/Userland/Libraries/LibCrypto/Hash/MGF.h b/Userland/Libraries/LibCrypto/Hash/MGF.h index 1bd00e1dfea..a97f2a46e26 100644 --- a/Userland/Libraries/LibCrypto/Hash/MGF.h +++ b/Userland/Libraries/LibCrypto/Hash/MGF.h @@ -26,7 +26,7 @@ public: // 1. If length > 2^32(hLen), output "mask too long" and stop. if constexpr (sizeof(size_t) > 32) { if (length > (h_len << 32)) - return Error::from_string_view("mask too long"sv); + return Error::from_string_literal("mask too long"); } // 2. Let T be the empty octet string. diff --git a/Userland/Libraries/LibCrypto/Hash/PBKDF2.h b/Userland/Libraries/LibCrypto/Hash/PBKDF2.h index d10d161edd9..9b917d130be 100644 --- a/Userland/Libraries/LibCrypto/Hash/PBKDF2.h +++ b/Userland/Libraries/LibCrypto/Hash/PBKDF2.h @@ -27,7 +27,7 @@ public: // 1. If dkLen > (2^32 - 1) * hLen, output "derived key too long" and stop. if (key_length_bytes > (AK::pow(2.0, 32.0) - 1) * h_len) - return Error::from_string_view("derived key too long"sv); + return Error::from_string_literal("derived key too long"); // 2 . Let l be the number of hLen-octet blocks in the derived key rounding up, // and let r be the number of octets in the last block diff --git a/Userland/Libraries/LibCrypto/Padding/OAEP.h b/Userland/Libraries/LibCrypto/Padding/OAEP.h index 6cc34a1982a..6c329705c98 100644 --- a/Userland/Libraries/LibCrypto/Padding/OAEP.h +++ b/Userland/Libraries/LibCrypto/Padding/OAEP.h @@ -30,7 +30,7 @@ public: auto h_len = HashFunction::digest_size(); auto max_message_size = length - (2 * h_len) - 1; if (message.size() > max_message_size) - return Error::from_string_view("message too long"sv); + return Error::from_string_literal("message too long"); // 3. Generate an octet string PS consisting of emLen-||M||-2hLen-1 zero octets. The length of PS may be 0. auto padding_size = length - message.size() - (2 * h_len) - 1; diff --git a/Userland/Libraries/LibTLS/Certificate.cpp b/Userland/Libraries/LibTLS/Certificate.cpp index 63bee5c2a80..5d9cdd4161a 100644 --- a/Userland/Libraries/LibTLS/Certificate.cpp +++ b/Userland/Libraries/LibTLS/Certificate.cpp @@ -82,7 +82,7 @@ static ErrorOr oid_to_curve(Vector curve) else if (curve == curve_prime256) return SupportedGroup::SECP256R1; - return Error::from_string_view("Unknown curve oid"sv); + return Error::from_string_literal("Unknown curve oid"); } static ErrorOr parse_certificate_version(Crypto::ASN1::Decoder& decoder, Vector current_scope) diff --git a/Userland/Libraries/LibWeb/ARIA/RoleType.cpp b/Userland/Libraries/LibWeb/ARIA/RoleType.cpp index 30ec7bc74fb..d7832c34176 100644 --- a/Userland/Libraries/LibWeb/ARIA/RoleType.cpp +++ b/Userland/Libraries/LibWeb/ARIA/RoleType.cpp @@ -142,7 +142,7 @@ ErrorOr RoleType::serialize_as_json(JsonObjectSerializer& o ErrorOr> RoleType::build_role_object(Role role, bool focusable, AriaData const& data) { if (is_abstract_role(role)) - return Error::from_string_view("Cannot construct a role object for an abstract role."sv); + return Error::from_string_literal("Cannot construct a role object for an abstract role."); switch (role) { case Role::alert: diff --git a/Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp index 24cc8df153f..1d2b1d0ff9a 100644 --- a/Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp +++ b/Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp @@ -1045,7 +1045,7 @@ WebIDL::ExceptionOr, JS::NonnullGCPtr ErrorOr { return Error::from_string_view("noop error"sv); }, + [](Empty const&) -> ErrorOr { return Error::from_string_literal("noop error"); }, [](auto instance) { return instance.generate_private_key(); }); if (maybe_private_key_data.is_error()) @@ -1054,7 +1054,7 @@ WebIDL::ExceptionOr, JS::NonnullGCPtr ErrorOr { return Error::from_string_view("noop error"sv); }, + [](Empty const&) -> ErrorOr { return Error::from_string_literal("noop error"); }, [&](auto instance) { return instance.generate_public_key(private_key_data); }); if (maybe_public_key_data.is_error()) @@ -1233,7 +1233,7 @@ WebIDL::ExceptionOr ECDSA::verify(AlgorithmParams const& params, JS:: auto encoded_signature = encoder.finish(); auto maybe_result = curve.visit( - [](Empty const&) -> ErrorOr { return Error::from_string_view("Failed to create valid crypto instance"sv); }, + [](Empty const&) -> ErrorOr { return Error::from_string_literal("Failed to create valid crypto instance"); }, [&](auto instance) { return instance.verify(M, Q, encoded_signature); }); if (maybe_result.is_error()) { @@ -1411,7 +1411,7 @@ WebIDL::ExceptionOr> PBKDF2::derive_bits(Algor // the contents of the salt attribute of normalizedAlgorithm as the salt, S, // the value of the iterations attribute of normalizedAlgorithm as the iteration count, c, // and length divided by 8 as the intended key length, dkLen. - ErrorOr result = Error::from_string_view("noop error"sv); + ErrorOr result = Error::from_string_literal("noop error"); auto password = key->handle().visit( [](ByteBuffer data) -> ByteBuffer { diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 1c00a833817..848ede80d98 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1916,7 +1916,7 @@ ErrorOr Element::scroll_into_view(Optional> Response::location_url(Optional const& reque // 3. If location is a header value, then set location to the result of parsing location with response’s URL. auto location = DOMURL::parse(location_values.first(), url()); if (!location.is_valid()) - return Error::from_string_view("Invalid 'Location' header URL"sv); + return Error::from_string_literal("Invalid 'Location' header URL"); // 4. If location is a URL whose fragment is null, then set location’s fragment to requestFragment. if (!location.fragment().has_value()) diff --git a/Userland/Libraries/LibWeb/WebDriver/Capabilities.cpp b/Userland/Libraries/LibWeb/WebDriver/Capabilities.cpp index d084bc7eca0..dec68d01fd8 100644 --- a/Userland/Libraries/LibWeb/WebDriver/Capabilities.cpp +++ b/Userland/Libraries/LibWeb/WebDriver/Capabilities.cpp @@ -308,26 +308,26 @@ static JsonValue match_capabilities(JsonObject const& capabilities) if (name == "browserName"sv) { // If value is not a string equal to the "browserName" entry in matched capabilities, return success with data null. if (value.as_string() != matched_capabilities.get_byte_string(name).value()) - return AK::Error::from_string_view("browserName"sv); + return AK::Error::from_string_literal("browserName"); } // -> "browserVersion" else if (name == "browserVersion"sv) { // Compare value to the "browserVersion" entry in matched capabilities using an implementation-defined comparison algorithm. The comparison is to accept a value that places constraints on the version using the "<", "<=", ">", and ">=" operators. // If the two values do not match, return success with data null. if (!matches_browser_version(value.as_string(), matched_capabilities.get_byte_string(name).value())) - return AK::Error::from_string_view("browserVersion"sv); + return AK::Error::from_string_literal("browserVersion"); } // -> "platformName" else if (name == "platformName"sv) { // If value is not a string equal to the "platformName" entry in matched capabilities, return success with data null. if (!matches_platform_name(value.as_string(), matched_capabilities.get_byte_string(name).value())) - return AK::Error::from_string_view("platformName"sv); + return AK::Error::from_string_literal("platformName"); } // -> "acceptInsecureCerts" else if (name == "acceptInsecureCerts"sv) { // If value is true and the endpoint node does not support insecure TLS certificates, return success with data null. if (value.as_bool()) - return AK::Error::from_string_view("acceptInsecureCerts"sv); + return AK::Error::from_string_literal("acceptInsecureCerts"); } // -> "proxy" else if (name == "proxy"sv) { @@ -342,11 +342,11 @@ static JsonValue match_capabilities(JsonObject const& capabilities) if (name == "webSocketUrl"sv) { // 1. If value is false, return success with data null. if (!value.as_bool()) - return AK::Error::from_string_view("webSocketUrl"sv); + return AK::Error::from_string_literal("webSocketUrl"); // 2. Return success with data value. // FIXME: Remove this when we support BIDI communication. - return AK::Error::from_string_view("webSocketUrl"sv); + return AK::Error::from_string_literal("webSocketUrl"); } } diff --git a/Userland/Libraries/LibWebView/ViewImplementation.cpp b/Userland/Libraries/LibWebView/ViewImplementation.cpp index 2d8a0531327..eb66f0a16ce 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.cpp +++ b/Userland/Libraries/LibWebView/ViewImplementation.cpp @@ -509,7 +509,7 @@ void ViewImplementation::handle_web_content_process_crash() static ErrorOr save_screenshot(Gfx::ShareableBitmap const& bitmap) { if (!bitmap.is_valid()) - return Error::from_string_view("Failed to take a screenshot"sv); + return Error::from_string_literal("Failed to take a screenshot"); auto file = Core::DateTime::now().to_byte_string("screenshot-%Y-%m-%d-%H-%M-%S.png"sv); auto path = TRY(Application::the().path_for_downloaded_file(file)); diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp index 5b4e1a91f63..eb31329c272 100644 --- a/Userland/Services/WebDriver/Client.cpp +++ b/Userland/Services/WebDriver/Client.cpp @@ -23,7 +23,7 @@ HashMap> Client::s_sessions; ErrorOr> Client::try_create(NonnullOwnPtr socket, LaunchBrowserCallbacks callbacks, Core::EventReceiver* parent) { if (!callbacks.launch_browser || !callbacks.launch_headless_browser) - return Error::from_string_view("All callbacks to launch a browser must be provided"sv); + return Error::from_string_literal("All callbacks to launch a browser must be provided"); TRY(socket->set_blocking(true)); return adopt_nonnull_ref_or_enomem(new (nothrow) Client(move(socket), move(callbacks), parent)); diff --git a/Userland/Utilities/aconv.cpp b/Userland/Utilities/aconv.cpp index ca06af7825f..000e193cb4b 100644 --- a/Userland/Utilities/aconv.cpp +++ b/Userland/Utilities/aconv.cpp @@ -19,12 +19,12 @@ static ErrorOr guess_format_from_extension(StringView path) { if (path == "-"sv) - return Error::from_string_view("Cannot guess format for standard stream, please specify format manually"sv); + return Error::from_string_literal("Cannot guess format for standard stream, please specify format manually"); LexicalPath lexical_path { path }; auto extension = lexical_path.extension(); if (extension.is_empty()) - return Error::from_string_view("Cannot guess format for file without file extension"sv); + return Error::from_string_literal("Cannot guess format for file without file extension"); // Note: Do not return the `extension` StringView in any case, since that will possibly lead to UAF. if (extension == "wav"sv || extension == "wave"sv) @@ -36,7 +36,7 @@ static ErrorOr guess_format_from_extension(StringView path) if (extension == "qoa"sv) return "qoa"sv; - return Error::from_string_view("Cannot guess format for the given file extension"sv); + return Error::from_string_literal("Cannot guess format for the given file extension"); } static ErrorOr parse_sample_format(StringView textual_format) @@ -53,7 +53,7 @@ static ErrorOr parse_sample_format(StringView textual_fo return Audio::PcmSampleFormat::Float32; if (textual_format == "f64le"sv) return Audio::PcmSampleFormat::Float64; - return Error::from_string_view("Unknown sample format"sv); + return Error::from_string_literal("Unknown sample format"); } ErrorOr serenity_main(Main::Arguments arguments) @@ -76,10 +76,10 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); if (input.is_empty()) - return Error::from_string_view("Input file is required, use '-' to read from standard input"sv); + return Error::from_string_literal("Input file is required, use '-' to read from standard input"); if (output_format.is_empty() && output == "-"sv) - return Error::from_string_view("Output format must be specified manually when writing to standard output"sv); + return Error::from_string_literal("Output format must be specified manually when writing to standard output"); if (input != "-"sv) TRY(Core::System::unveil(TRY(FileSystem::absolute_path(input)), "r"sv)); diff --git a/Userland/Utilities/animation.cpp b/Userland/Utilities/animation.cpp index e91ba372a9f..319bc1d7bb0 100644 --- a/Userland/Utilities/animation.cpp +++ b/Userland/Utilities/animation.cpp @@ -28,7 +28,7 @@ static ErrorOr parse_options(Main::Arguments arguments) args_parser.parse(arguments); if (options.out_path.is_empty()) - return Error::from_string_view("-o is required "sv); + return Error::from_string_literal("-o is required "); return options; } @@ -42,7 +42,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = TRY(Core::MappedFile::map(options.in_path)); auto decoder = TRY(Gfx::ImageDecoder::try_create_for_raw_bytes(file->bytes())); if (!decoder) - return Error::from_string_view("Could not find decoder for input file"sv); + return Error::from_string_literal("Could not find decoder for input file"); auto output_file = TRY(Core::File::open(options.out_path, Core::File::OpenMode::Write)); auto output_stream = TRY(Core::OutputBufferedFile::create(move(output_file))); diff --git a/Userland/Utilities/image.cpp b/Userland/Utilities/image.cpp index 162eee83d0b..67711b33a36 100644 --- a/Userland/Utilities/image.cpp +++ b/Userland/Utilities/image.cpp @@ -46,7 +46,7 @@ static ErrorOr load_image(RefPtr const& decoder, static ErrorOr invert_cmyk(LoadedImage& image) { if (!image.bitmap.has>()) - return Error::from_string_view("Can't --invert-cmyk with RGB bitmaps"sv); + return Error::from_string_literal("Can't --invert-cmyk with RGB bitmaps"); auto& frame = image.bitmap.get>(); for (auto& pixel : *frame) { @@ -61,7 +61,7 @@ static ErrorOr invert_cmyk(LoadedImage& image) static ErrorOr crop_image(LoadedImage& image, Gfx::IntRect const& rect) { if (!image.bitmap.has>()) - return Error::from_string_view("Can't --crop CMYK bitmaps yet"sv); + return Error::from_string_literal("Can't --crop CMYK bitmaps yet"); auto& frame = image.bitmap.get>(); frame = TRY(frame->cropped(rect)); return {}; @@ -70,17 +70,17 @@ static ErrorOr crop_image(LoadedImage& image, Gfx::IntRect const& rect) static ErrorOr move_alpha_to_rgb(LoadedImage& image) { if (!image.bitmap.has>()) - return Error::from_string_view("Can't --move-alpha-to-rgb with CMYK bitmaps"sv); + return Error::from_string_literal("Can't --move-alpha-to-rgb with CMYK bitmaps"); auto& frame = image.bitmap.get>(); switch (frame->format()) { case Gfx::BitmapFormat::Invalid: - return Error::from_string_view("Can't --move-alpha-to-rgb with invalid bitmaps"sv); + return Error::from_string_literal("Can't --move-alpha-to-rgb with invalid bitmaps"); case Gfx::BitmapFormat::RGBA8888: // No image decoder currently produces bitmaps with this format. // If that ever changes, preferrably fix the image decoder to use BGRA8888 instead :) // If there's a good reason for not doing that, implement support for this, I suppose. - return Error::from_string_view("--move-alpha-to-rgb not implemented for RGBA8888"sv); + return Error::from_string_literal("--move-alpha-to-rgb not implemented for RGBA8888"); case Gfx::BitmapFormat::BGRA8888: case Gfx::BitmapFormat::BGRx8888: // FIXME: If BitmapFormat::Gray8 existed (and image encoders made use of it to write grayscale images), we could use it here. @@ -95,17 +95,17 @@ static ErrorOr move_alpha_to_rgb(LoadedImage& image) static ErrorOr strip_alpha(LoadedImage& image) { if (!image.bitmap.has>()) - return Error::from_string_view("Can't --strip-alpha with CMYK bitmaps"sv); + return Error::from_string_literal("Can't --strip-alpha with CMYK bitmaps"); auto& frame = image.bitmap.get>(); switch (frame->format()) { case Gfx::BitmapFormat::Invalid: - return Error::from_string_view("Can't --strip-alpha with invalid bitmaps"sv); + return Error::from_string_literal("Can't --strip-alpha with invalid bitmaps"); case Gfx::BitmapFormat::RGBA8888: // No image decoder currently produces bitmaps with this format. // If that ever changes, preferrably fix the image decoder to use BGRA8888 instead :) // If there's a good reason for not doing that, implement support for this, I suppose. - return Error::from_string_view("--strip-alpha not implemented for RGBA8888"sv); + return Error::from_string_literal("--strip-alpha not implemented for RGBA8888"); case Gfx::BitmapFormat::BGRA8888: case Gfx::BitmapFormat::BGRx8888: frame->strip_alpha_channel(); @@ -116,7 +116,7 @@ static ErrorOr strip_alpha(LoadedImage& image) static ErrorOr> convert_image_profile(LoadedImage& image, StringView convert_color_profile_path, OwnPtr maybe_source_icc_file) { if (!image.icc_data.has_value()) - return Error::from_string_view("No source color space embedded in image. Pass one with --assign-color-profile."sv); + return Error::from_string_literal("No source color space embedded in image. Pass one with --assign-color-profile."); auto source_icc_file = move(maybe_source_icc_file); auto source_icc_data = image.icc_data.value(); @@ -127,11 +127,11 @@ static ErrorOr> convert_image_profile(LoadedImage& imag auto destination_profile = TRY(Gfx::ICC::Profile::try_load_from_externally_owned_memory(icc_file->bytes())); if (destination_profile->data_color_space() != Gfx::ICC::ColorSpace::RGB) - return Error::from_string_view("Can only convert to RGB at the moment, but destination color space is not RGB"sv); + return Error::from_string_literal("Can only convert to RGB at the moment, but destination color space is not RGB"); if (image.bitmap.has>()) { if (source_profile->data_color_space() != Gfx::ICC::ColorSpace::CMYK) - return Error::from_string_view("Source image data is CMYK but source color space is not CMYK"sv); + return Error::from_string_literal("Source image data is CMYK but source color space is not CMYK"); auto& cmyk_frame = image.bitmap.get>(); auto rgb_frame = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, cmyk_frame->size())); @@ -180,7 +180,7 @@ static ErrorOr save_image(LoadedImage& image, StringView out_path, u8 jpeg } else if (out_path.ends_with(".png"sv, CaseSensitivity::CaseInsensitive)) { bytes = TRY(Gfx::PNGWriter::encode(*frame, { .icc_data = image.icc_data })); } else { - return Error::from_string_view("can only write .bmp, .gif, .jpg, .png, and .webp"sv); + return Error::from_string_literal("can only write .bmp, .gif, .jpg, .png, and .webp"); } TRY(TRY(stream())->write_until_depleted(bytes)); @@ -211,7 +211,7 @@ static ErrorOr> parse_comma_separated_numbers(StringView rect_string) for (size_t i = 0; i < parts.size(); ++i) { auto part = parts[i].to_number(); if (!part.has_value()) - return Error::from_string_view("comma-separated parts must be numbers"sv); + return Error::from_string_literal("comma-separated parts must be numbers"); TRY(part_numbers.try_append(part.value())); } return part_numbers; @@ -221,7 +221,7 @@ static ErrorOr parse_rect_string(StringView rect_string) { auto numbers = TRY(parse_comma_separated_numbers(rect_string)); if (numbers.size() != 4) - return Error::from_string_view("rect must have 4 comma-separated parts"sv); + return Error::from_string_literal("rect must have 4 comma-separated parts"); return Gfx::IntRect { numbers[0], numbers[1], numbers[2], numbers[3] }; } @@ -238,7 +238,7 @@ static ErrorOr parse_webp_allowed_transforms_string(StringView string) else if (part == "color-indexing" || part == "ci") allowed_transforms |= 1 << Gfx::COLOR_INDEXING_TRANSFORM; else - return Error::from_string_view("unknown WebP transform; valid values: predictor, p, color, c, subtract-green, sg, color-indexing, ci"sv); + return Error::from_string_literal("unknown WebP transform; valid values: predictor, p, color, c, subtract-green, sg, color-indexing, ci"); } return allowed_transforms; } @@ -265,7 +265,7 @@ static ErrorOr parse_options(Main::Arguments arguments) args_parser.parse(arguments); if (options.out_path.is_empty() ^ options.no_output) - return Error::from_string_view("exactly one of -o or --no-output is required"sv); + return Error::from_string_literal("exactly one of -o or --no-output is required"); if (!crop_rect_string.is_empty()) options.crop_rect = TRY(parse_rect_string(crop_rect_string)); @@ -282,7 +282,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = TRY(Core::MappedFile::map(options.in_path)); auto decoder = TRY(Gfx::ImageDecoder::try_create_for_raw_bytes(file->bytes())); if (!decoder) - return Error::from_string_view("Could not find decoder for input file"sv); + return Error::from_string_literal("Could not find decoder for input file"); LoadedImage image = TRY(load_image(*decoder, options.frame_index));