From b98081771cb0f3276f3dca5aca6525055a113bd5 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 1 Aug 2024 11:29:28 -0500 Subject: [PATCH] Fix wstring to string conversion warning in LenovoUSBController_Gen7_8.cpp --- .../LenovoUSBController_Gen7_8.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/LenovoUSBController_Gen7_8.cpp b/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/LenovoUSBController_Gen7_8.cpp index 9bd90c4c..0597c88e 100644 --- a/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/LenovoUSBController_Gen7_8.cpp +++ b/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/LenovoUSBController_Gen7_8.cpp @@ -10,25 +10,26 @@ #include #include #include "LenovoUSBController_Gen7_8.h" +#include "StringUtils.h" using namespace std; LenovoGen7And8USBController::LenovoGen7And8USBController(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 = wstring(tmp); - name = 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 = wstring(tmp); - name.append(" ").append(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)); } LenovoGen7And8USBController::~LenovoGen7And8USBController()