summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-12-22 14:28:23 +0000
committerTim Flynn <trflynn89@pm.me>2023-02-03 07:19:52 -0500
commitc1d3f39cc4a814e665e7c4744af3d612134b389f (patch)
tree56857dad20bc9b5ee741521998069f1a0578bb9c /Userland/Utilities
parente8ebbcdbc54b0276fd5d93462ccbd114c96b4d83 (diff)
downloadserenity-c1d3f39cc4a814e665e7c4744af3d612134b389f.zip
Utilities/lsusb: Replace uses of JsonObject::get_deprecated()/get_ptr()
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/lsusb.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/Userland/Utilities/lsusb.cpp b/Userland/Utilities/lsusb.cpp
index ef6b66bec4..5f4806b96c 100644
--- a/Userland/Utilities/lsusb.cpp
+++ b/Userland/Utilities/lsusb.cpp
@@ -70,9 +70,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
json.as_array().for_each([usb_db, print_verbose](auto& value) {
auto& device_descriptor = value.as_object();
- auto device_address = device_descriptor.get_deprecated("device_address"sv).to_u32();
- auto vendor_id = device_descriptor.get_deprecated("vendor_id"sv).to_u32();
- auto product_id = device_descriptor.get_deprecated("product_id"sv).to_u32();
+ auto device_address = device_descriptor.get_u32("device_address"sv).value_or(0);
+ auto vendor_id = device_descriptor.get_u32("vendor_id"sv).value_or(0);
+ auto product_id = device_descriptor.get_u32("product_id"sv).value_or(0);
if (usb_db) {
StringView vendor_string = usb_db->get_vendor(vendor_id);
@@ -87,52 +87,52 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (print_verbose) {
outln("Device Descriptor");
- outln(" bLength {}", device_descriptor.get_deprecated("length"sv).to_u32());
- outln(" bDescriptorType {}", device_descriptor.get_deprecated("descriptor_type"sv).to_u32());
- outln(" bcdUSB {}", device_descriptor.get_deprecated("usb_spec_compliance_bcd"sv).to_u32());
- outln(" bDeviceClass {}", device_descriptor.get_deprecated("device_class"sv).to_u32());
- outln(" bDeviceSubClass {}", device_descriptor.get_deprecated("device_sub_class"sv).to_u32());
- outln(" bDeviceProtocol {}", device_descriptor.get_deprecated("device_protocol"sv).to_u32());
- outln(" bMaxPacketSize {}", device_descriptor.get_deprecated("max_packet_size"sv).to_u32());
+ outln(" bLength {}", device_descriptor.get_u32("length"sv).value_or(0));
+ outln(" bDescriptorType {}", device_descriptor.get_u32("descriptor_type"sv).value_or(0));
+ outln(" bcdUSB {}", device_descriptor.get_u32("usb_spec_compliance_bcd"sv).value_or(0));
+ outln(" bDeviceClass {}", device_descriptor.get_u32("device_class"sv).value_or(0));
+ outln(" bDeviceSubClass {}", device_descriptor.get_u32("device_sub_class"sv).value_or(0));
+ outln(" bDeviceProtocol {}", device_descriptor.get_u32("device_protocol"sv).value_or(0));
+ outln(" bMaxPacketSize {}", device_descriptor.get_u32("max_packet_size"sv).value_or(0));
if (usb_db) {
StringView vendor_string = usb_db->get_vendor(vendor_id);
StringView device_string = usb_db->get_device(vendor_id, product_id);
- outln(" idVendor 0x{:04x} {}", device_descriptor.get_deprecated("vendor_id"sv).to_u32(), vendor_string);
- outln(" idProduct 0x{:04x} {}", device_descriptor.get_deprecated("product_id"sv).to_u32(), device_string);
+ outln(" idVendor 0x{:04x} {}", device_descriptor.get_u32("vendor_id"sv).value_or(0), vendor_string);
+ outln(" idProduct 0x{:04x} {}", device_descriptor.get_u32("product_id"sv).value_or(0), device_string);
} else {
- outln(" idVendor 0x{:04x}", device_descriptor.get_deprecated("vendor_id"sv).to_u32());
- outln(" idProduct 0x{:04x}", device_descriptor.get_deprecated("product_id"sv).to_u32());
+ outln(" idVendor 0x{:04x}", device_descriptor.get_u32("vendor_id"sv).value_or(0));
+ outln(" idProduct 0x{:04x}", device_descriptor.get_u32("product_id"sv).value_or(0));
}
- outln(" bcdDevice {}", device_descriptor.get_deprecated("device_release_bcd"sv).to_u32());
- outln(" iManufacturer {}", device_descriptor.get_deprecated("manufacturer_id_descriptor_index"sv).to_u32());
- outln(" iProduct {}", device_descriptor.get_deprecated("product_string_descriptor_index"sv).to_u32());
- outln(" iSerial {}", device_descriptor.get_deprecated("serial_number_descriptor_index"sv).to_u32());
- outln(" bNumConfigurations {}", device_descriptor.get_deprecated("num_configurations"sv).to_u32());
-
- auto const& configuration_descriptors = value.as_object().get_deprecated("configurations"sv);
- configuration_descriptors.as_array().for_each([&](auto& config_value) {
+ outln(" bcdDevice {}", device_descriptor.get_u32("device_release_bcd"sv).value_or(0));
+ outln(" iManufacturer {}", device_descriptor.get_u32("manufacturer_id_descriptor_index"sv).value_or(0));
+ outln(" iProduct {}", device_descriptor.get_u32("product_string_descriptor_index"sv).value_or(0));
+ outln(" iSerial {}", device_descriptor.get_u32("serial_number_descriptor_index"sv).value_or(0));
+ outln(" bNumConfigurations {}", device_descriptor.get_u32("num_configurations"sv).value_or(0));
+
+ auto const& configuration_descriptors = value.as_object().get_array("configurations"sv).value();
+ configuration_descriptors.for_each([&](auto& config_value) {
auto const& configuration_descriptor = config_value.as_object();
outln(" Configuration Descriptor:");
- outln(" bLength {}", configuration_descriptor.get_deprecated("length"sv).as_u32());
- outln(" bDescriptorType {}", configuration_descriptor.get_deprecated("descriptor_type"sv).as_u32());
- outln(" wTotalLength {}", configuration_descriptor.get_deprecated("total_length"sv).as_u32());
- outln(" bNumInterfaces {}", configuration_descriptor.get_deprecated("number_of_interfaces"sv).as_u32());
- outln(" bmAttributes 0x{:02x}", configuration_descriptor.get_deprecated("attributes_bitmap"sv).as_u32());
- outln(" MaxPower {}mA", configuration_descriptor.get_deprecated("max_power"sv).as_u32() * 2u);
-
- auto const& interface_descriptors = config_value.as_object().get_deprecated("interfaces"sv);
- interface_descriptors.as_array().for_each([&](auto& interface_value) {
+ outln(" bLength {}", configuration_descriptor.get_u32("length"sv).value_or(0));
+ outln(" bDescriptorType {}", configuration_descriptor.get_u32("descriptor_type"sv).value_or(0));
+ outln(" wTotalLength {}", configuration_descriptor.get_u32("total_length"sv).value_or(0));
+ outln(" bNumInterfaces {}", configuration_descriptor.get_u32("number_of_interfaces"sv).value_or(0));
+ outln(" bmAttributes 0x{:02x}", configuration_descriptor.get_u32("attributes_bitmap"sv).value_or(0));
+ outln(" MaxPower {}mA", configuration_descriptor.get_u32("max_power"sv).value_or(0) * 2u);
+
+ auto const& interface_descriptors = config_value.as_object().get_array("interfaces"sv).value();
+ interface_descriptors.for_each([&](auto& interface_value) {
auto const& interface_descriptor = interface_value.as_object();
- auto const interface_class_code = interface_descriptor.get_deprecated("interface_class_code"sv).to_u32();
- auto const interface_subclass_code = interface_descriptor.get_deprecated("interface_sub_class_code"sv).to_u32();
- auto const interface_protocol_code = interface_descriptor.get_deprecated("interface_protocol"sv).to_u32();
+ auto const interface_class_code = interface_descriptor.get_u32("interface_class_code"sv).value_or(0);
+ auto const interface_subclass_code = interface_descriptor.get_u32("interface_sub_class_code"sv).value_or(0);
+ auto const interface_protocol_code = interface_descriptor.get_u32("interface_protocol"sv).value_or(0);
outln(" Interface Descriptor:");
- outln(" bLength {}", interface_descriptor.get_deprecated("length"sv).to_u32());
- outln(" bDescriptorType {}", interface_descriptor.get_deprecated("descriptor_type"sv).to_u32());
- outln(" bInterfaceNumber {}", interface_descriptor.get_deprecated("interface_number"sv).to_u32());
- outln(" bAlternateSetting {}", interface_descriptor.get_deprecated("alternate_setting"sv).to_u32());
- outln(" bNumEndpoints {}", interface_descriptor.get_deprecated("num_endpoints"sv).to_u32());
+ outln(" bLength {}", interface_descriptor.get_u32("length"sv).value_or(0));
+ outln(" bDescriptorType {}", interface_descriptor.get_u32("descriptor_type"sv).value_or(0));
+ outln(" bInterfaceNumber {}", interface_descriptor.get_u32("interface_number"sv).value_or(0));
+ outln(" bAlternateSetting {}", interface_descriptor.get_u32("alternate_setting"sv).value_or(0));
+ outln(" bNumEndpoints {}", interface_descriptor.get_u32("num_endpoints"sv).value_or(0));
if (usb_db) {
auto const interface_class = usb_db->get_class(interface_class_code);
auto const interface_subclass = usb_db->get_subclass(interface_class_code, interface_subclass_code);
@@ -145,19 +145,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln(" bInterfaceSubClass {}", interface_subclass_code);
outln(" bInterfaceProtocol {}", interface_protocol_code);
}
- outln(" iInterface {}", interface_descriptor.get_deprecated("interface_string_desc_index"sv).to_u32());
+ outln(" iInterface {}", interface_descriptor.get_u32("interface_string_desc_index"sv).value_or(0));
- auto const& endpoint_descriptors = interface_value.as_object().get_deprecated("endpoints"sv);
- endpoint_descriptors.as_array().for_each([&](auto& endpoint_value) {
+ auto const& endpoint_descriptors = interface_value.as_object().get_array("endpoints"sv).value();
+ endpoint_descriptors.for_each([&](auto& endpoint_value) {
auto const& endpoint_descriptor = endpoint_value.as_object();
- auto const endpoint_address = endpoint_descriptor.get_deprecated("endpoint_address"sv).to_u32();
+ auto const endpoint_address = endpoint_descriptor.get_u32("endpoint_address"sv).value_or(0);
outln(" Endpoint Descriptor:");
- outln(" bLength {}", endpoint_descriptor.get_deprecated("length"sv).to_u32());
- outln(" bDescriptorType {}", endpoint_descriptor.get_deprecated("descriptor_type"sv).to_u32());
+ outln(" bLength {}", endpoint_descriptor.get_u32("length"sv).value_or(0));
+ outln(" bDescriptorType {}", endpoint_descriptor.get_u32("descriptor_type"sv).value_or(0));
outln(" bEndpointAddress 0x{:02x} EP {} {}", endpoint_address, (endpoint_address & 0xFu), ((endpoint_address & 0x80u) ? "IN" : "OUT"));
- outln(" bmAttributes 0x{:02x}", endpoint_descriptor.get_deprecated("attribute_bitmap"sv).to_u32());
- outln(" wMaxPacketSize 0x{:04x}", endpoint_descriptor.get_deprecated("max_packet_size"sv).to_u32());
- outln(" bInterval {}", endpoint_descriptor.get_deprecated("polling_interval"sv).to_u32());
+ outln(" bmAttributes 0x{:02x}", endpoint_descriptor.get_u32("attribute_bitmap"sv).value_or(0));
+ outln(" wMaxPacketSize 0x{:04x}", endpoint_descriptor.get_u32("max_packet_size"sv).value_or(0));
+ outln(" bInterval {}", endpoint_descriptor.get_u32("polling_interval"sv).value_or(0));
});
});
});