From c76864dd4b75d47ee61ca75235eb8ac6251f065a Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 3 Mar 2026 11:05:11 -0600 Subject: [PATCH] Warning fixes and cleanups --- .../RGBController_LenovoK510.cpp | 2 +- .../RGBController_Lenovo_Gen7_8.cpp | 28 ++++++++-------- .../RGBController_LianLiUniHubSL.cpp | 2 +- .../RGBController_Mountain60Keyboard.cpp | 28 ++++++++-------- SPDAccessor/SPDAccessor.cpp | 33 +++++++++++-------- startup/startup.cpp | 8 +++-- 6 files changed, 54 insertions(+), 47 deletions(-) diff --git a/Controllers/LenovoControllers/LenovoLegionK510Controller/RGBController_LenovoK510.cpp b/Controllers/LenovoControllers/LenovoLegionK510Controller/RGBController_LenovoK510.cpp index 5cf6c53eb..0ba4fc921 100644 --- a/Controllers/LenovoControllers/LenovoLegionK510Controller/RGBController_LenovoK510.cpp +++ b/Controllers/LenovoControllers/LenovoLegionK510Controller/RGBController_LenovoK510.cpp @@ -318,7 +318,7 @@ void RGBController_LenovoK510::ReadAndUpdateCurrentDeviceState() current_active_mode.direction = current_active_mode.direction ? MODE_DIRECTION_UP : MODE_DIRECTION_DOWN; } - active_mode = i; + active_mode = (int)i; break; } } diff --git a/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/RGBController_Lenovo_Gen7_8.cpp b/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/RGBController_Lenovo_Gen7_8.cpp index ac7d2b65e..07e290309 100644 --- a/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/RGBController_Lenovo_Gen7_8.cpp +++ b/Controllers/LenovoControllers/LenovoUSBController_Gen7_8/RGBController_Lenovo_Gen7_8.cpp @@ -286,15 +286,15 @@ LenovoRGBController_Gen7_8::LenovoRGBController_Gen7_8(LenovoGen7And8USBControll SetupZones(); - /*-----------------*\ - | Initiliaze Static | - \*-----------------*/ + /*-----------------------------------------------------*\ + | Initiliaze Static | + \*-----------------------------------------------------*/ active_mode = 0; for(size_t i = 0; i < modes.size(); i++) { if(modes[i].value == LENOVO_LEGION_GEN7_8_MODE_STATIC) { - active_mode = i; + active_mode = (int)i; break; } } @@ -307,7 +307,6 @@ LenovoRGBController_Gen7_8::~LenovoRGBController_Gen7_8() delete controller; } - void LenovoRGBController_Gen7_8::SetupZones() { vector lenovo_zones; @@ -363,9 +362,9 @@ void LenovoRGBController_Gen7_8::SetupZones() new_led.value = lenovo_zones[i].id << 8 | lenovo_zones[i].leds[led_idx].led_num ; leds.push_back(new_led); - /*---------------------------------------------------------*\ - | create led id to index map for fast look up | - \*---------------------------------------------------------*/ + /*---------------------------------------------*\ + | create led id to index map for fast look up | + \*---------------------------------------------*/ led_id_to_index[new_led.value]=leds.size() - 1; } } @@ -449,9 +448,10 @@ void LenovoRGBController_Gen7_8::DeviceUpdateLEDs() { if(controller->getPid() == LEGION_7GEN10) { - /*---------------------------------------------------------*\ - | Gen10 may ignore A1 updates unless D0 is reasserted. | - \*---------------------------------------------------------*/ + /*---------------------------------------------*\ + | Gen10 may ignore A1 updates unless D0 is | + | reasserted. | + \*---------------------------------------------*/ controller->setLedsDirectOn(profile_id); direct_enabled = true; } @@ -585,9 +585,9 @@ std::vector LenovoRGBController_Gen7_8::GetLedGroups() size_t start = 0; size_t end = leds.size(); - /*---------------------------------------------------------*\ - | Riplle and Type only apply to keyboard | - \*---------------------------------------------------------*/ + /*-------------------------------------------------*\ + | Riplle and Type only apply to keyboard | + \*-------------------------------------------------*/ if(modes[active_mode].value == LENOVO_LEGION_GEN7_8_MODE_RIPPLE || modes[active_mode].value == LENOVO_LEGION_GEN7_8_MODE_TYPE) { diff --git a/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp b/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp index f22bc0c4f..c83d0eb50 100644 --- a/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp +++ b/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp @@ -321,7 +321,7 @@ void RGBController_LianLiUniHubSL::SetupZones() new_led.name = zones[zone_idx].name; new_led.name.append(", Fan "); new_led.name.append(std::to_string(led_idx + 1)); - new_led.value = zone_idx; + new_led.value = (unsigned int)zone_idx; leds.push_back(new_led); } diff --git a/Controllers/MountainKeyboardController/RGBController_Mountain60Keyboard.cpp b/Controllers/MountainKeyboardController/RGBController_Mountain60Keyboard.cpp index aaf6cdb61..90587e502 100644 --- a/Controllers/MountainKeyboardController/RGBController_Mountain60Keyboard.cpp +++ b/Controllers/MountainKeyboardController/RGBController_Mountain60Keyboard.cpp @@ -15,9 +15,9 @@ using namespace std::chrono_literals; -/*-------------------------------*\ -| TODO: Detect detached keypad | -\*-------------------------------*/ +/*---------------------------------------------------------*\ +| TODO: Detect detached keypad | +\*---------------------------------------------------------*/ std::vector mountain60_keyboard_key_id_values = { @@ -37,9 +37,9 @@ layout_values mountain60_layout = { mountain60_keyboard_key_id_values, { - /*------------------------------------------*\ - | No regional layout fix for the moment | - \*------------------------------------------*/ + /*---------------------------------------------*\ + | No regional layout fix for the moment | + \*---------------------------------------------*/ }, }; @@ -348,9 +348,9 @@ RGBController_Mountain60Keyboard::~RGBController_Mountain60Keyboard() mountain_thread->join(); delete mountain_thread; - /*---------------------------------------------------------*\ - | Delete the matrix map | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Delete the matrix map | + \*-----------------------------------------------------*/ for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++) { if(zones[zone_index].type == ZONE_TYPE_MATRIX) @@ -406,10 +406,10 @@ void RGBController_Mountain60Keyboard::DeviceUpdateLEDs() { unsigned char* color_data = new unsigned char[(leds.size()*4)]; - /*---------------------------------------------------------*\ - | Filling the color_data vector with progressive index | - | leaving space for RGB data | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Filling the color_data vector with progressive index | + | leaving space for RGB data | + \*-----------------------------------------------------*/ for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++) { const unsigned int idx = led_idx * 4; @@ -419,7 +419,7 @@ void RGBController_Mountain60Keyboard::DeviceUpdateLEDs() color_data[idx + 3] = RGBGetBValue(colors[led_idx]); } - controller->SendDirect(modes[active_mode].brightness, color_data, (leds.size()*4)); + controller->SendDirect(modes[active_mode].brightness, color_data, ((unsigned int)leds.size() * 4)); delete[] color_data; } diff --git a/SPDAccessor/SPDAccessor.cpp b/SPDAccessor/SPDAccessor.cpp index ea8dd90c3..4cd8d62ab 100644 --- a/SPDAccessor/SPDAccessor.cpp +++ b/SPDAccessor/SPDAccessor.cpp @@ -21,11 +21,12 @@ using namespace std::chrono_literals; - -// Sources for define values: -// - https://en.wikipedia.org/wiki/Serial_presence_detect -// - JEDEC DDR5 Serial Presence Detect (SPD): Table of contents - +/*---------------------------------------------------------*\ +| Sources for define values: | +| - https://en.wikipedia.org/wiki/Serial_presence_detect | +| - JEDEC DDR5 Serial Presence Detect (SPD): Table of | +| contents | +\*---------------------------------------------------------*/ #define BASIC_MEMORY_TYPE_ADDR (0x02) #define DDR4_JEDEC_ID_ADDR (0x140) @@ -121,17 +122,21 @@ std::string SPDAccessor::read_part_nr_at(uint16_t address, std::size_t len) part_number += (char)this->at(spd_addr); } - // Find the true end of string & truncate it to that point. - // Part number should be padded with 0x20 (space) for DDR4 (Source: Wikipedia) - // It may be padded with 0x00 (Source: real-life tests on DDR5 memory) - // Note: To prevent infinite loop, end_of_string_idx MUST be signed. - int end_of_string_idx = part_number.length()-1; + /*-----------------------------------------------------*\ + | Find the true end of string and truncate it to that | + | point. Part number should be padded with 0x20 | + | (space) for DDR4 (Source: Wikipedia). | + | It may be padded with 0x00 (Source: real-life tests | + | on DDR5 memory). | + | Note: To prevent infinite loop, end_of_string_idx | + | MUST be signed. | + \*-----------------------------------------------------*/ + std::size_t end_of_string_idx = part_number.length() - 1; + for(; end_of_string_idx >= 0; end_of_string_idx--) { - if( - part_number[end_of_string_idx] != '\0' && - part_number[end_of_string_idx] != ' ' - ) + if((part_number[end_of_string_idx] != '\0') + && (part_number[end_of_string_idx] != ' ')) { break; } diff --git a/startup/startup.cpp b/startup/startup.cpp index 46f48af50..3f8dfb505 100644 --- a/startup/startup.cpp +++ b/startup/startup.cpp @@ -62,10 +62,12 @@ int startup(int argc, char* argv[], unsigned int ret_flags) LOG_TRACE("[main] initializing GUI"); /*-------------------------------------------------*\ - | Enable high DPI scaling support | + | Enable high DPI scaling support (Qt5 only) | \*-------------------------------------------------*/ - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); + #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); + #endif /*-------------------------------------------------*\ | Enable high DPI fractional scaling support on |