Skip to content

Commit 7dc872b

Browse files
authored
address coverity issues (#843)
1 parent 0394a7c commit 7dc872b

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

include/ada/url_components-inl.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ namespace ada {
2424
* `--------------------------------------------- protocol_end
2525
*/
2626
// These conditions can be made more strict.
27-
uint32_t index = 0;
28-
2927
if (protocol_end == url_components::omitted) {
3028
return false;
3129
}
32-
if (protocol_end < index) {
33-
return false;
34-
}
35-
index = protocol_end;
30+
uint32_t index = protocol_end;
3631

3732
if (username_end == url_components::omitted) {
3833
return false;

src/url.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ bool url::set_host_or_hostname(const std::string_view input) {
716716

717717
bool succeeded = parse_host(host_view);
718718
if (!succeeded) {
719-
host = previous_host;
719+
host = std::move(previous_host);
720720
update_base_port(previous_port);
721721
}
722722
return succeeded;
@@ -733,13 +733,13 @@ bool url::set_host_or_hostname(const std::string_view input) {
733733
} else {
734734
// Let host be the result of host parsing buffer with url is not special.
735735
if (!parse_host(new_host)) {
736-
host = previous_host;
736+
host = std::move(previous_host);
737737
update_base_port(previous_port);
738738
return false;
739739
}
740740

741741
// If host is "localhost", then set host to the empty string.
742-
if (host.has_value() && host.value() == "localhost") {
742+
if (host == "localhost") {
743743
host = "";
744744
}
745745
}
@@ -794,7 +794,7 @@ bool url::set_port(const std::string_view input) {
794794
if (is_valid) {
795795
return true;
796796
}
797-
port = previous_port;
797+
port = std::move(previous_port);
798798
is_valid = true;
799799
return false;
800800
}
@@ -835,7 +835,7 @@ bool url::set_pathname(const std::string_view input) {
835835
if (has_opaque_path) {
836836
return false;
837837
}
838-
path = "";
838+
path.clear();
839839
parse_path(input);
840840
return true;
841841
}

0 commit comments

Comments
 (0)