summaryrefslogtreecommitdiff
path: root/Userland/Utilities/netstat.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-12-22 14:28:33 +0000
committerTim Flynn <trflynn89@pm.me>2023-02-03 07:19:52 -0500
commit39f3a150228aa645ee147d0c064e71c241e40377 (patch)
tree261b986336e650ae7578003deb80e163850c2033 /Userland/Utilities/netstat.cpp
parentf14a1da633468e28b1d16fd0c774a17ec7d247df (diff)
downloadserenity-39f3a150228aa645ee147d0c064e71c241e40377.zip
Utilities/netstat: Replace uses of JsonObject::get_deprecated()/get_ptr
Diffstat (limited to 'Userland/Utilities/netstat.cpp')
-rw-r--r--Userland/Utilities/netstat.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/Userland/Utilities/netstat.cpp b/Userland/Utilities/netstat.cpp
index f06ad1a166..8f7e5ca45d 100644
--- a/Userland/Utilities/netstat.cpp
+++ b/Userland/Utilities/netstat.cpp
@@ -163,16 +163,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<JsonValue> sorted_regions = json.as_array().values();
quick_sort(sorted_regions, [](auto& a, auto& b) {
- return a.as_object().get_deprecated("local_port"sv).to_u32() < b.as_object().get_deprecated("local_port"sv).to_u32();
+ return a.as_object().get_u32("local_port"sv).value_or(0) < b.as_object().get_u32("local_port"sv).value_or(0);
});
for (auto& value : sorted_regions) {
auto& if_object = value.as_object();
- auto bytes_in = if_object.get_deprecated("bytes_in"sv).to_deprecated_string();
- auto bytes_out = if_object.get_deprecated("bytes_out"sv).to_deprecated_string();
+ auto bytes_in = if_object.get_deprecated_string("bytes_in"sv).value_or({});
+ auto bytes_out = if_object.get_deprecated_string("bytes_out"sv).value_or({});
- auto peer_address = if_object.get_deprecated("peer_address"sv).to_deprecated_string();
+ auto peer_address = if_object.get_deprecated_string("peer_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(peer_address);
auto addr = from_string.value().to_in_addr_t();
@@ -184,9 +184,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto peer_port = if_object.get_deprecated("peer_port"sv).to_deprecated_string();
+ auto peer_port = if_object.get_deprecated_string("peer_port"sv).value_or({});
if (!flag_numeric) {
- auto service = getservbyport(htons(if_object.get_deprecated("peer_port"sv).to_u32()), "tcp");
+ auto service = getservbyport(htons(if_object.get_u32("peer_port"sv).value_or(0)), "tcp");
if (service != nullptr) {
auto s_name = StringView { service->s_name, strlen(service->s_name) };
if (!s_name.is_empty())
@@ -194,7 +194,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto local_address = if_object.get_deprecated("local_address"sv).to_deprecated_string();
+ auto local_address = if_object.get_deprecated_string("local_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(local_address);
auto addr = from_string.value().to_in_addr_t();
@@ -206,9 +206,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto local_port = if_object.get_deprecated("local_port"sv).to_deprecated_string();
+ auto local_port = if_object.get_deprecated_string("local_port"sv).value_or({});
if (!flag_numeric) {
- auto service = getservbyport(htons(if_object.get_deprecated("local_port"sv).to_u32()), "tcp");
+ auto service = getservbyport(htons(if_object.get_u32("local_port"sv).value_or(0)), "tcp");
if (service != nullptr) {
auto s_name = StringView { service->s_name, strlen(service->s_name) };
if (!s_name.is_empty())
@@ -216,8 +216,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto state = if_object.get_deprecated("state"sv).to_deprecated_string();
- auto origin_pid = (if_object.has("origin_pid"sv)) ? if_object.get_deprecated("origin_pid"sv).to_u32() : -1;
+ auto state = if_object.get_deprecated_string("state"sv).value_or({});
+ auto origin_pid = (if_object.has("origin_pid"sv)) ? if_object.get_u32("origin_pid"sv).value_or(0) : -1;
if (!flag_all && ((state == "Listen" && !flag_list) || (state != "Listen" && flag_list)))
continue;
@@ -250,13 +250,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<JsonValue> sorted_regions = json.as_array().values();
quick_sort(sorted_regions, [](auto& a, auto& b) {
- return a.as_object().get_deprecated("local_port"sv).to_u32() < b.as_object().get_deprecated("local_port"sv).to_u32();
+ return a.as_object().get_u32("local_port"sv).value_or(0) < b.as_object().get_u32("local_port"sv).value_or(0);
});
for (auto& value : sorted_regions) {
auto& if_object = value.as_object();
- auto local_address = if_object.get_deprecated("local_address"sv).to_deprecated_string();
+ auto local_address = if_object.get_deprecated_string("local_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(local_address);
auto addr = from_string.value().to_in_addr_t();
@@ -268,9 +268,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto local_port = if_object.get_deprecated("local_port"sv).to_deprecated_string();
+ auto local_port = if_object.get_deprecated_string("local_port"sv).value_or({});
if (!flag_numeric) {
- auto service = getservbyport(htons(if_object.get_deprecated("local_port"sv).to_u32()), "udp");
+ auto service = getservbyport(htons(if_object.get_u32("local_port"sv).value_or(0)), "udp");
if (service != nullptr) {
auto s_name = StringView { service->s_name, strlen(service->s_name) };
if (!s_name.is_empty())
@@ -278,7 +278,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto peer_address = if_object.get_deprecated("peer_address"sv).to_deprecated_string();
+ auto peer_address = if_object.get_deprecated_string("peer_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(peer_address);
auto addr = from_string.value().to_in_addr_t();
@@ -290,9 +290,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto peer_port = if_object.get_deprecated("peer_port"sv).to_deprecated_string();
+ auto peer_port = if_object.get_deprecated_string("peer_port"sv).value_or({});
if (!flag_numeric) {
- auto service = getservbyport(htons(if_object.get_deprecated("peer_port"sv).to_u32()), "udp");
+ auto service = getservbyport(htons(if_object.get_u32("peer_port"sv).value_or(0)), "udp");
if (service != nullptr) {
auto s_name = StringView { service->s_name, strlen(service->s_name) };
if (!s_name.is_empty())
@@ -300,7 +300,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
- auto origin_pid = (if_object.has("origin_pid"sv)) ? if_object.get_deprecated("origin_pid"sv).to_u32() : -1;
+ auto origin_pid = (if_object.has("origin_pid"sv)) ? if_object.get_u32("origin_pid"sv).value_or(0) : -1;
if (protocol_column != -1)
columns[protocol_column].buffer = "udp";