From ed6904e84774b0df1ba9aff1c37594159e3e4dd6 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Fri, 17 Jan 2025 15:30:37 -0500 Subject: [PATCH] address coverity issues --- include/ada/url_components-inl.h | 7 +------ src/url.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/ada/url_components-inl.h b/include/ada/url_components-inl.h index 77ab8874a..db814ca0d 100644 --- a/include/ada/url_components-inl.h +++ b/include/ada/url_components-inl.h @@ -24,15 +24,10 @@ namespace ada { * `--------------------------------------------- protocol_end */ // These conditions can be made more strict. - uint32_t index = 0; - if (protocol_end == url_components::omitted) { return false; } - if (protocol_end < index) { - return false; - } - index = protocol_end; + uint32_t index = protocol_end; if (username_end == url_components::omitted) { return false; diff --git a/src/url.cpp b/src/url.cpp index f7fa85197..07ca24fec 100644 --- a/src/url.cpp +++ b/src/url.cpp @@ -716,7 +716,7 @@ bool url::set_host_or_hostname(const std::string_view input) { bool succeeded = parse_host(host_view); if (!succeeded) { - host = previous_host; + host = std::move(previous_host); update_base_port(previous_port); } return succeeded; @@ -733,13 +733,13 @@ bool url::set_host_or_hostname(const std::string_view input) { } else { // Let host be the result of host parsing buffer with url is not special. if (!parse_host(new_host)) { - host = previous_host; + host = std::move(previous_host); update_base_port(previous_port); return false; } // If host is "localhost", then set host to the empty string. - if (host.has_value() && host.value() == "localhost") { + if (host == "localhost") { host = ""; } } @@ -794,7 +794,7 @@ bool url::set_port(const std::string_view input) { if (is_valid) { return true; } - port = previous_port; + port = std::move(previous_port); is_valid = true; return false; } @@ -835,7 +835,7 @@ bool url::set_pathname(const std::string_view input) { if (has_opaque_path) { return false; } - path = ""; + path.clear(); parse_path(input); return true; }