From 733d7fb0e5898812480d5ef920d6a9e9cec60852 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Wed, 31 Jul 2024 22:42:52 -0500 Subject: [PATCH] Fix wstring to string conversion warning in Lenovo4ZoneUSBController.cpp --- .../Lenovo4ZoneUSBController.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBController.cpp b/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBController.cpp index 4b8a50f75..93d069656 100644 --- a/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBController.cpp +++ b/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBController.cpp @@ -10,23 +10,24 @@ #include #include "Lenovo4ZoneUSBController.h" #include "LogManager.h" +#include "StringUtils.h" Lenovo4ZoneUSBController::Lenovo4ZoneUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid) { - const uint8_t sz = HID_MAX_STR; - wchar_t tmp[sz]; - dev = dev_handle; location = path; pid = in_pid; - hid_get_manufacturer_string(dev, tmp, sz); - std::wstring w_tmp = std::wstring(tmp); - name = std::string(w_tmp.begin(), w_tmp.end()); + /*---------------------------------------------------------*\ + | Get device name from HID manufacturer and product strings | + \*---------------------------------------------------------*/ + wchar_t name_string[HID_MAX_STR]; - hid_get_product_string(dev, tmp, sz); - w_tmp = std::wstring(tmp); - name.append(" ").append(std::string(w_tmp.begin(), w_tmp.end())); + hid_get_manufacturer_string(dev, name_string, HID_MAX_STR); + name = StringUtils::wstring_to_string(name_string); + + hid_get_product_string(dev, name_string, HID_MAX_STR); + name.append(" ").append(StringUtils::wstring_to_string(name_string)); } Lenovo4ZoneUSBController::~Lenovo4ZoneUSBController()