More warning fixes

This commit is contained in:
Adam Honse 2024-04-29 18:08:33 -05:00
parent f39409b7aa
commit d3c81d3306
18 changed files with 68 additions and 69 deletions

View file

@ -213,7 +213,7 @@ void RGBController_CorsairVengeancePro::ResizeZone(int /*zone*/, int /*new_size*
void RGBController_CorsairVengeancePro::DeviceUpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
for(unsigned int led = 0; led < (unsigned int)colors.size(); led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);

View file

@ -97,7 +97,7 @@ void CorsairWirelessController::SetName(std::string device_name)
void CorsairWirelessController::EnterDirectMode()
{
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -118,13 +118,13 @@ void CorsairWirelessController::EnterDirectMode()
| Send packet using feature reports, as headset stand |
| seems to not update completely using HID writes |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
}
void CorsairWirelessController::StartDirectMode()
{
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -144,13 +144,13 @@ void CorsairWirelessController::StartDirectMode()
| Send packet using feature reports, as headset stand |
| seems to not update completely using HID writes |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
}
void CorsairWirelessController::ExitDirectMode()
{
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -171,13 +171,13 @@ void CorsairWirelessController::ExitDirectMode()
| Send packet using feature reports, as headset stand |
| seems to not update completely using HID writes |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
}
void CorsairWirelessController::SendDirectFrame(bool first_frame, unsigned char* data)
{
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -214,5 +214,5 @@ void CorsairWirelessController::SendDirectFrame(bool first_frame, unsigned char*
| Send packet using feature reports, as headset stand |
| seems to not update completely using HID writes |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
}

View file

@ -137,11 +137,11 @@ void CougarKeyboardController::SetMode(uint8_t mode, uint8_t speed, uint8_t brig
case COUGARKEYBOARDCONTROLLER_MODE_RIPPLE:
case COUGARKEYBOARDCONTROLLER_MODE_SCAN:
{
uint8_t count = colours.size();
uint8_t count = (uint8_t)colours.size();
uint8_t timer = 100 / count;
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 1] = count;
for(size_t i = 0; i < count; i++)
for(uint8_t i = 0; i < count; i++)
{
uint8_t offset = 11 + (i * 4);
@ -169,7 +169,7 @@ void CougarKeyboardController::SetMode(uint8_t mode, uint8_t speed, uint8_t brig
void CougarKeyboardController::SetLedsDirect(std::vector<RGBColor> colours)
{
uint8_t max_leds = 14;
uint8_t leds_remaining = colours.size();
uint8_t leds_remaining = (uint8_t)colours.size();
uint8_t packet_flag = COUGARKEYBOARDCONTROLLER_DIRECTION_BYTE;
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x14, 0x2C, 0x0B, 0x00, 0xFF, 0x64, 0x00, 0x01 };
@ -177,7 +177,7 @@ void CougarKeyboardController::SetLedsDirect(std::vector<RGBColor> colours)
| Set up Direct packet |
| keyvalue_map is the index of the Key from full_matrix_map |
\*-----------------------------------------------------------------*/
for(size_t leds2send = 0; leds2send < leds_remaining; leds2send += max_leds)
for(uint8_t leds2send = 0; leds2send < leds_remaining; leds2send += max_leds)
{
/*-----------------------------------------------------------------*\
| Check if there is enough leds for another pass |
@ -192,7 +192,7 @@ void CougarKeyboardController::SetLedsDirect(std::vector<RGBColor> colours)
buffer[packet_flag] = 3;
}
for(size_t i = 0; i < max_leds; i++)
for(uint8_t i = 0; i < max_leds; i++)
{
uint8_t offset = COUGARKEYBOARDCONTROLLER_DATA_BYTE + (i * 4);
uint8_t led_num = leds2send + i;

View file

@ -79,12 +79,12 @@ void CryorigH7QuadLumiController::SetChannelEffect
\*-----------------------------------------------------*/
else if(num_colors <= 8)
{
for(std::size_t color_idx = 0; color_idx < num_colors; color_idx++)
for(unsigned int color_idx = 0; color_idx < num_colors; color_idx++)
{
/*-----------------------------------------------------*\
| Fill in color data (5 entries per color) |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < 40; idx++)
for(int idx = 0; idx < 40; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[color_idx];
@ -96,7 +96,7 @@ void CryorigH7QuadLumiController::SetChannelEffect
/*-----------------------------------------------------*\
| Send mode and color data |
\*-----------------------------------------------------*/
SendPacket(channel, mode, direction, color_idx, speed, 5, &color_data[0]);
SendPacket(channel, mode, direction, (unsigned char)color_idx, speed, 5, &color_data[0]);
}
}
/*-----------------------------------------------------*\
@ -107,7 +107,7 @@ void CryorigH7QuadLumiController::SetChannelEffect
/*-----------------------------------------------------*\
| Fill in color data (up to 40 colors) |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < num_colors; idx++)
for(int idx = 0; idx < num_colors; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
@ -135,7 +135,7 @@ void CryorigH7QuadLumiController::SetChannelLEDs
/*-----------------------------------------------------*\
| Fill in color data (up to 40 colors) |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < num_colors; idx++)
for(int idx = 0; idx < num_colors; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];

View file

@ -187,7 +187,7 @@ void RGBController_CryorigH7QuadLumi::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_CryorigH7QuadLumi::DeviceUpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
for(unsigned char zone_idx = 0; zone_idx < (unsigned char)zones.size(); zone_idx++)
{
controller->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
@ -218,7 +218,7 @@ void RGBController_CryorigH7QuadLumi::DeviceUpdateMode()
}
else
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
for(unsigned char zone_idx = 0; zone_idx < (unsigned char)zones.size(); zone_idx++)
{
RGBColor* colors = NULL;
bool direction = false;

View file

@ -29,7 +29,7 @@ DasKeyboardController::~DasKeyboardController()
std::string DasKeyboardController::GetDeviceLocation()
{
return "HID: " + location;
return("HID: " + location);
}
std::string DasKeyboardController::GetSerialString()
@ -49,14 +49,14 @@ std::string DasKeyboardController::GetSerialString()
return_string = version;
}
return return_string;
return(return_string);
}
std::string DasKeyboardController::GetVersionString()
{
if(version.length() < 17)
{
return version;
return(version);
}
std::string fw_version = "V";
@ -65,7 +65,7 @@ std::string DasKeyboardController::GetVersionString()
fw_version += version.substr(15, 2);
fw_version += ".0";
return fw_version;
return(fw_version);
}
std::string DasKeyboardController::GetLayoutString()
@ -76,16 +76,16 @@ std::string DasKeyboardController::GetLayoutString()
\*-----------------------------------------------------*/
if(version.length() < 17)
{
return "NONE";
return("NONE");
}
std::string layout_id = version.substr(3, 2);
if(layout_id == "16")
{
return "US";
return("US");
}
return "EU";
return("EU");
}
void DasKeyboardController::SendColors(unsigned char key_id, unsigned char mode,
@ -322,16 +322,16 @@ int DasKeyboardController::ReceiveData(unsigned char *data, const unsigned int m
\*-----------------------------------------------------*/
if(chk_sum)
{
return -1;
return(-1);
}
size_t response_size = 0;
int response_size = 0;
if(receive_buf.size() > 1)
{
response_size = receive_buf.at(1);
if(response_size + 2 > receive_buf.size())
{
return -1;
return(-1);
}
if(response_size > max_length)
{
@ -347,5 +347,5 @@ int DasKeyboardController::ReceiveData(unsigned char *data, const unsigned int m
}
}
return response_size;
return(response_size);
}

View file

@ -247,7 +247,7 @@ RGBController_DasKeyboard::~RGBController_DasKeyboard()
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
unsigned int zone_size = zones.size();
unsigned int zone_size = (unsigned int)zones.size();
for(unsigned int zone_index = 0; zone_index < zone_size; zone_index++)
{

View file

@ -311,7 +311,6 @@ void DetectDebugControllers()
std::vector<keyboard_led> change;
const char* change_keys = "change_keys";
const char* ins_key = "ins_key";
const char* ins_row = "ins_row";
const char* rmv_key = "rmv_key";
const char* rmv_row = "rmv_row";
@ -402,7 +401,7 @@ void DetectDebugControllers()
dummy_keyboard->zones.push_back(dummy_keyboard_matrix_zone);
for(std::size_t led_idx = 0; led_idx < dummy_keyboard_matrix_zone.leds_count; led_idx++)
for(unsigned int led_idx = 0; led_idx < dummy_keyboard_matrix_zone.leds_count; led_idx++)
{
led dummy_keyboard_led;
dummy_keyboard_led.name = new_kb.GetKeyNameAt(led_idx);

View file

@ -74,7 +74,7 @@ void DuckyKeyboardController::SendColors
void DuckyKeyboardController::SendInitialize()
{
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -91,13 +91,13 @@ void DuckyKeyboardController::SendInitialize()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
void DuckyKeyboardController::SendInitializeColorPacket()
{
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -120,7 +120,7 @@ void DuckyKeyboardController::SendInitializeColorPacket()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
@ -132,7 +132,7 @@ unsigned int DuckyKeyboardController::SendColorDataPacket
)
{
unsigned int bytes_sent;
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -188,7 +188,7 @@ unsigned int DuckyKeyboardController::SendColorDataPacket
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
return(bytes_sent);
@ -196,7 +196,7 @@ unsigned int DuckyKeyboardController::SendColorDataPacket
void DuckyKeyboardController::SendTerminateColorPacket()
{
char usb_buf[65];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -214,6 +214,6 @@ void DuckyKeyboardController::SendTerminateColorPacket()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}

View file

@ -71,8 +71,8 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
for(unsigned int device_idx = 0; device_idx < devices.size(); device_idx++)
{
float universe_size = devices[device_idx].universe_size;
unsigned int total_universes = ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / universe_size );
float universe_size = (float)devices[device_idx].universe_size;
unsigned int total_universes = (unsigned int)ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / universe_size );
for(unsigned int univ_idx = 0; univ_idx < total_universes; univ_idx++)
{
@ -157,8 +157,8 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
/*-----------------------------------------*\
| Add Universes |
\*-----------------------------------------*/
float universe_size = devices[device_idx].universe_size;
unsigned int total_universes = ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / universe_size );
float universe_size = (float)devices[device_idx].universe_size;
unsigned int total_universes = (unsigned int)ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / universe_size );
for (unsigned int univ_idx = 0; univ_idx < total_universes; univ_idx++)
{
@ -178,7 +178,7 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
e131_packet_t packet;
e131_addr_t dest_addr;
e131_pkt_init(&packet, universe, universe_size);
e131_pkt_init(&packet, (uint16_t)universe, (uint16_t)universe_size);
if(multicast)
{
@ -384,8 +384,8 @@ void RGBController_E131::DeviceUpdateLEDs()
for(std::size_t device_idx = 0; device_idx < devices.size(); device_idx++)
{
float universe_size = devices[device_idx].universe_size;
unsigned int total_universes = ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / universe_size );
float universe_size = (float)devices[device_idx].universe_size;
unsigned int total_universes = (unsigned int)ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / universe_size );
unsigned int channel_idx = devices[device_idx].start_channel;
unsigned int led_idx = 0;
unsigned int rgb_idx = 0;

View file

@ -235,7 +235,7 @@ int RGBController_ENESMBus::GetDeviceMode()
break;
}
for(std::size_t mode = 0; mode < modes.size(); mode++)
for(int mode = 0; mode < (int)modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
@ -342,7 +342,7 @@ void RGBController_ENESMBus::SetupZones()
| Search through all LEDs and create zones for each channel |
| type |
\*---------------------------------------------------------*/
for(std::size_t cfg_zone_idx = 0; cfg_zone_idx < ENE_NUM_ZONES; cfg_zone_idx++)
for(unsigned int cfg_zone_idx = 0; cfg_zone_idx < ENE_NUM_ZONES; cfg_zone_idx++)
{
/*---------------------------------------------------------*\
| Get the number of LEDs in the zone |
@ -423,7 +423,7 @@ void RGBController_ENESMBus::SetupZones()
/*---------------------------------------------------------*\
| Create LED entries for each zone |
\*---------------------------------------------------------*/
std::size_t led_idx = 0;
unsigned int led_idx = 0;
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(std::size_t zone_led_idx = 0; zone_led_idx < zones[zone_idx].leds_count; zone_led_idx++)

View file

@ -48,7 +48,7 @@ int Search(wchar_t *dev_name)
return 1;
}
i += wcslen(buff + i);
i += (int)wcslen(buff + i);
}
return 0;

View file

@ -133,15 +133,15 @@ RGBController_EVGAGPUv2::~RGBController_EVGAGPUv2()
int RGBController_EVGAGPUv2::getModeIndex(unsigned char mode_value)
{
for(std::size_t mode_index = 0; mode_index < modes.size(); mode_index++)
for(int mode_index = 0; mode_index < (int)modes.size(); mode_index++)
{
if (modes[mode_index].value == mode_value)
if(modes[mode_index].value == mode_value)
{
return mode_index;
return(mode_index);
}
}
return 0;
return(0);
}
void RGBController_EVGAGPUv2::SetupZones()

View file

@ -248,7 +248,7 @@ void EVGAKeyboardController::SendColour(uint8_t mode, uint16_t speed, uint8_t br
| Static, Breathing and Star modes have fixed colour sizes |
| buffer[26] will be overwritten for these modes |
\*-----------------------------------------------------------------*/
buffer[EVGA_KB_COLORS_SZ] = colors.size();
buffer[EVGA_KB_COLORS_SZ] = (uint8_t)colors.size();
switch(mode)
{
@ -259,7 +259,7 @@ void EVGAKeyboardController::SendColour(uint8_t mode, uint16_t speed, uint8_t br
case EVGA_KEYBOARD_CONTROLLER_MODE_BREATHING:
for(size_t i = 0; i < colors.size(); i++)
{
uint8_t offset = 26 + (i * 5);
uint8_t offset = (uint8_t)(26 + (i * 5));
buffer[offset + 0] = 0x0A;
buffer[offset + 1] = brightness;
@ -316,7 +316,7 @@ void EVGAKeyboardController::FillColours(uint8_t * buffer, uint8_t brightness, s
{
for(size_t i = 0; i < colors.size(); i++)
{
uint8_t offset = (i * 4);
uint8_t offset = (uint8_t)(i * 4);
buffer[offset + 0] = brightness;
buffer[offset + 1] = RGBGetRValue(colors[i]);
@ -365,7 +365,7 @@ uint8_t EVGAKeyboardController::FindColours(uint8_t * data, uint8_t count, std::
for(size_t i = 0; i < count; i++)
{
uint8_t offset = (i * 4);
uint8_t offset = (uint8_t)(i * 4);
colors.push_back(ToRGBColor(data[offset + 1],data[offset + 2],data[offset + 3]));
}

View file

@ -207,7 +207,7 @@ void EVGAMouseController::SetLed(uint8_t index, uint8_t brightness, uint8_t spee
/*-----------------------------------------------------------------------*\
| 7 is the maximum number of colors that can be set from the vendor's UI. |
\*-----------------------------------------------------------------------*/
unsigned char color_count = std::min(colors.size(), static_cast<std::vector<RGBColor>::size_type>(7));
unsigned char color_count = (unsigned char)std::min(colors.size(), static_cast<std::vector<RGBColor>::size_type>(7));
buffer[EVGA_PERIPHERAL_COLOR_COUNT_BYTE] = color_count;
for(unsigned char i = 0; i < color_count; i++)
{

View file

@ -59,7 +59,7 @@ void ElgatoKeyLightController::SetColor(hsv_t hsv_color)
port.tcp_client_connect();
std::string buf = GetRequest(hsv_color.value, k_value);
port.tcp_client_write((char *)buf.c_str(), buf.length() + 1);
port.tcp_client_write((char *)buf.c_str(), (int)buf.length() + 1);
port.tcp_close();
}

View file

@ -32,7 +32,7 @@ ElgatoLightStripController::ElgatoLightStripController(std::string ip)
\*-----------------------------------------------------------*/
port.tcp_client_connect();
std::string buf = "GET /elgato/accessory-info HTTP/1.1\r\nContent-Type: application/json\r\nConnection: close\r\n\r\n";
port.tcp_client_write((char *)buf.c_str(), buf.length() + 1);
port.tcp_client_write((char *)buf.c_str(), (int)buf.length() + 1);
char recv_buf[1024];
int size = port.tcp_listen(recv_buf, sizeof(recv_buf));
@ -116,7 +116,7 @@ void ElgatoLightStripController::SetColor(hsv_t hsv_color)
port.tcp_client_connect();
std::string buf = GetRequest(hsv_color.hue, hsv_color.saturation, GetBrightness());
port.tcp_client_write((char *)buf.c_str(), buf.length() + 1);
port.tcp_client_write((char *)buf.c_str(), (int)buf.length() + 1);
port.tcp_close();
}

View file

@ -26,9 +26,9 @@ void EspurnaController::Initialize(char* ledstring)
LPSTR source = NULL;
LPSTR udpport_baud = NULL;
LPSTR next = NULL;
source = strtok_s(ledstring, ",", &next);
//Check for either the UDP port or the serial baud rate
if (strlen(next))
{
@ -68,7 +68,7 @@ void EspurnaController::SetLEDs(std::vector<RGBColor> colors)
char get_request[1024];
snprintf(get_request, 1024, "GET /api/rgb?apikey=%s&value=%%23%02X%02X%02X HTTP/1.1\r\nHost: %s\r\n\r\n", espurna_apikey, RGBGetRValue(color), RGBGetGValue(color), RGBGetBValue(color), client_name.c_str());
tcpport->tcp_client_connect();
tcpport->tcp_client_write(get_request, strlen(get_request));
tcpport->tcp_client_write(get_request, (int)strlen(get_request));
tcpport->tcp_close();
}
}