Address a bunch of warnings
This commit is contained in:
parent
e7c385bd71
commit
03d99d135c
12 changed files with 157 additions and 103 deletions
|
|
@ -58,7 +58,7 @@ enum
|
|||
POLYCHROME_USB_ZONE_UNAVAILABLE = 0x1E, // Value from LEDCOUNT CFG if zone not present
|
||||
};
|
||||
|
||||
static const char* polychrome_USB_zone_names[] =
|
||||
const char* polychrome_USB_zone_names[] =
|
||||
{
|
||||
"RGB LED 1 Header",
|
||||
"RGB LED 2 Header",
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ void AlienwareAW510KController::SendInitialize()
|
|||
|
||||
void AlienwareAW510KController::SetDirect
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char /*zone*/,
|
||||
unsigned char r,
|
||||
unsigned char g,
|
||||
unsigned char b
|
||||
|
|
@ -222,7 +222,7 @@ void AlienwareAW510KController::SendDirectOn
|
|||
| To Guarantee the data are always %4 =0 append |
|
||||
| zeros at end of last packet |
|
||||
\*-----------------------------------------------*/
|
||||
for(int i = 0; i < (frame_data.size() % 4); i++)
|
||||
for(unsigned int i = 0; i < (frame_data.size() % 4); i++)
|
||||
{
|
||||
SelectedKeys key;
|
||||
key.idx = 0x00;
|
||||
|
|
@ -358,7 +358,7 @@ void AlienwareAW510KController::UpdateSingleLED
|
|||
}
|
||||
void AlienwareAW510KController::SendMode
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char /*zone*/,
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char direction,
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ void RGBController_AlienwareAW510K::DeviceUpdateLEDs()
|
|||
|
||||
void RGBController_AlienwareAW510K::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
controller->SetDirect((unsigned char) zone, RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
|
||||
controller->SetDirect( RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
|
||||
}
|
||||
|
||||
void RGBController_AlienwareAW510K::UpdateSingleLED(int led)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAsusAuraCoreControllers(hid_device_info* info, const std::string&)
|
||||
void DetectAsusAuraCoreControllers(hid_device_info* info, const std::string& /*name*/)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ void DetectAsusAuraCoreControllers(hid_device_info* info, const std::string&)
|
|||
}
|
||||
}
|
||||
|
||||
void DetectAsusAuraCoreLaptopControllers(hid_device_info* info, const std::string& name)
|
||||
void DetectAsusAuraCoreLaptopControllers(hid_device_info* info, const std::string& /*name*/)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ void AuraMousematController::UpdateDevice
|
|||
usb_buf[0x08] = pattern;
|
||||
usb_buf[0x09] = 0x00;
|
||||
|
||||
for(int i = 0; i < colors.size(); i++)
|
||||
for(unsigned int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
usb_buf[0x0a + i * 3] = RGBGetRValue(colors[i]);
|
||||
usb_buf[0x0b + i * 3] = RGBGetGValue(colors[i]);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ std::string AsusAuraRyuoAIOController::GetLocation()
|
|||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void AsusAuraRyuoAIOController::SetMode(unsigned char channel, unsigned char mode, unsigned char red, unsigned char grn, unsigned char blu)
|
||||
void AsusAuraRyuoAIOController::SetMode(unsigned char /*channel*/, unsigned char /*mode*/, unsigned char /*red*/, unsigned char /*grn*/, unsigned char /*blu*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This interface is not used in this controller however is |
|
||||
|
|
@ -56,7 +56,7 @@ void AsusAuraRyuoAIOController::SetMode(unsigned char mode, unsigned char speed,
|
|||
}
|
||||
}
|
||||
|
||||
void AsusAuraRyuoAIOController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
void AsusAuraRyuoAIOController::SetChannelLEDs(unsigned char /*channel*/, RGBColor* /*colors*/, unsigned int /*num_colors*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This interface is not used in this controller however is |
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ void RGBController_AsusAuraRyuoAIO::SetupZones()
|
|||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AsusAuraRyuoAIO::ResizeZone(int zone, int new_size)
|
||||
void RGBController_AsusAuraRyuoAIO::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ void RGBController_ROGStrixLC_Controller::SetupZones()
|
|||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_ROGStrixLC_Controller::ResizeZone(int zone, int new_size)
|
||||
void RGBController_ROGStrixLC_Controller::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ std::string ROGStrixLC_Controller::GetLocation()
|
|||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void ROGStrixLC_Controller::SetMode(unsigned char channel, unsigned char mode, unsigned char red, unsigned char grn, unsigned char blu)
|
||||
void ROGStrixLC_Controller::SetMode(unsigned char /*channel*/, unsigned char /*mode*/, unsigned char /*red*/, unsigned char /*grn*/, unsigned char /*blu*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This interface is not used in this controller however is |
|
||||
|
|
@ -58,7 +58,7 @@ void ROGStrixLC_Controller::SetMode(unsigned char mode, unsigned char speed, uns
|
|||
}
|
||||
}
|
||||
|
||||
void ROGStrixLC_Controller::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
void ROGStrixLC_Controller::SetChannelLEDs(unsigned char /*channel*/, RGBColor* /*colors*/, unsigned int /*num_colors*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This interface is not used in this controller however is |
|
||||
|
|
|
|||
|
|
@ -1348,7 +1348,7 @@ void OpenRGBDialog2::UpdateDevicesList()
|
|||
| Remove all remaining device information tabs, leaving |
|
||||
| other information tabs alone |
|
||||
\*-----------------------------------------------------*/
|
||||
for(std::size_t tab_idx = controllers.size(); tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||
for(int tab_idx = controllers.size(); tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||
{
|
||||
std::string type_str = ui->InformationTabBar->widget(base_tab)->metaObject()->className();
|
||||
if(type_str == "Ui::OpenRGBDeviceInfoPage")
|
||||
|
|
|
|||
|
|
@ -26,18 +26,23 @@ static mdns_string_t ipv4_address_to_string(char* buffer, size_t capacity, const
|
|||
{
|
||||
char host[NI_MAXHOST] = {0};
|
||||
char service[NI_MAXSERV] = {0};
|
||||
int ret = getnameinfo((const struct sockaddr*)addr, (socklen_t)addrlen, host, NI_MAXHOST,
|
||||
service, NI_MAXSERV, NI_NUMERICSERV | NI_NUMERICHOST);
|
||||
int ret = getnameinfo((const struct sockaddr*)addr, (socklen_t)addrlen, host, NI_MAXHOST, service, NI_MAXSERV, NI_NUMERICSERV | NI_NUMERICHOST);
|
||||
int len = 0;
|
||||
if (ret == 0)
|
||||
|
||||
if(ret == 0)
|
||||
{
|
||||
len = snprintf(buffer, capacity, "%s", host);
|
||||
}
|
||||
if (len >= (int)capacity)
|
||||
|
||||
if(len >= (int)capacity)
|
||||
{
|
||||
len = (int)capacity - 1;
|
||||
}
|
||||
|
||||
mdns_string_t str;
|
||||
str.str = buffer;
|
||||
str.length = len;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
@ -45,21 +50,30 @@ static mdns_string_t ipv6_address_to_string(char* buffer, size_t capacity, const
|
|||
{
|
||||
char host[NI_MAXHOST] = {0};
|
||||
char service[NI_MAXSERV] = {0};
|
||||
int ret = getnameinfo((const struct sockaddr*)addr, (socklen_t)addrlen, host, NI_MAXHOST,
|
||||
service, NI_MAXSERV, NI_NUMERICSERV | NI_NUMERICHOST);
|
||||
int ret = getnameinfo((const struct sockaddr*)addr, (socklen_t)addrlen, host, NI_MAXHOST, service, NI_MAXSERV, NI_NUMERICSERV | NI_NUMERICHOST);
|
||||
int len = 0;
|
||||
if (ret == 0)
|
||||
|
||||
if(ret == 0)
|
||||
{
|
||||
if (addr->sin6_port != 0)
|
||||
if(addr->sin6_port != 0)
|
||||
{
|
||||
len = snprintf(buffer, capacity, "[%s]:%s", host, service);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = snprintf(buffer, capacity, "%s", host);
|
||||
}
|
||||
}
|
||||
if (len >= (int)capacity)
|
||||
|
||||
if(len >= (int)capacity)
|
||||
{
|
||||
len = (int)capacity - 1;
|
||||
}
|
||||
|
||||
mdns_string_t str;
|
||||
str.str = buffer;
|
||||
str.length = len;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
@ -86,9 +100,9 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
do
|
||||
{
|
||||
adapter_address = (IP_ADAPTER_ADDRESSES*)malloc(address_size);
|
||||
ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_ANYCAST, 0,
|
||||
adapter_address, &address_size);
|
||||
if (ret == ERROR_BUFFER_OVERFLOW)
|
||||
ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_ANYCAST, 0, adapter_address, &address_size);
|
||||
|
||||
if(ret == ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
free(adapter_address);
|
||||
adapter_address = 0;
|
||||
|
|
@ -99,9 +113,9 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
break;
|
||||
}
|
||||
}
|
||||
while (num_retries-- > 0);
|
||||
while(num_retries-- > 0);
|
||||
|
||||
if (!adapter_address || (ret != NO_ERROR))
|
||||
if(!adapter_address || (ret != NO_ERROR))
|
||||
{
|
||||
free(adapter_address);
|
||||
return num_sockets;
|
||||
|
|
@ -109,37 +123,42 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
|
||||
int first_ipv4 = 1;
|
||||
int first_ipv6 = 1;
|
||||
for (PIP_ADAPTER_ADDRESSES adapter = adapter_address; adapter; adapter = adapter->Next)
|
||||
{
|
||||
if (adapter->TunnelType == TUNNEL_TYPE_TEREDO)
|
||||
continue;
|
||||
if (adapter->OperStatus != IfOperStatusUp)
|
||||
continue;
|
||||
|
||||
for (IP_ADAPTER_UNICAST_ADDRESS* unicast = adapter->FirstUnicastAddress; unicast;
|
||||
unicast = unicast->Next)
|
||||
for(PIP_ADAPTER_ADDRESSES adapter = adapter_address; adapter; adapter = adapter->Next)
|
||||
{
|
||||
if(adapter->TunnelType == TUNNEL_TYPE_TEREDO)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(adapter->OperStatus != IfOperStatusUp)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for(IP_ADAPTER_UNICAST_ADDRESS* unicast = adapter->FirstUnicastAddress; unicast; unicast = unicast->Next)
|
||||
{
|
||||
if (unicast->Address.lpSockaddr->sa_family == AF_INET)
|
||||
if(unicast->Address.lpSockaddr->sa_family == AF_INET)
|
||||
{
|
||||
struct sockaddr_in* saddr = (struct sockaddr_in*)unicast->Address.lpSockaddr;
|
||||
if ((saddr->sin_addr.S_un.S_un_b.s_b1 != 127) ||
|
||||
(saddr->sin_addr.S_un.S_un_b.s_b2 != 0) ||
|
||||
(saddr->sin_addr.S_un.S_un_b.s_b3 != 0) ||
|
||||
(saddr->sin_addr.S_un.S_un_b.s_b4 != 1))
|
||||
if((saddr->sin_addr.S_un.S_un_b.s_b1 != 127) ||
|
||||
(saddr->sin_addr.S_un.S_un_b.s_b2 != 0) ||
|
||||
(saddr->sin_addr.S_un.S_un_b.s_b3 != 0) ||
|
||||
(saddr->sin_addr.S_un.S_un_b.s_b4 != 1))
|
||||
{
|
||||
int log_addr = 0;
|
||||
if (first_ipv4)
|
||||
if(first_ipv4)
|
||||
{
|
||||
service_address_ipv4 = *saddr;
|
||||
first_ipv4 = 0;
|
||||
log_addr = 1;
|
||||
}
|
||||
has_ipv4 = 1;
|
||||
if (num_sockets < max_sockets)
|
||||
if(num_sockets < max_sockets)
|
||||
{
|
||||
saddr->sin_port = htons((unsigned short)port);
|
||||
int sock = mdns_socket_open_ipv4(saddr);
|
||||
if (sock >= 0)
|
||||
if(sock >= 0)
|
||||
{
|
||||
sockets[num_sockets++] = sock;
|
||||
log_addr = 1;
|
||||
|
|
@ -149,38 +168,37 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
log_addr = 0;
|
||||
}
|
||||
}
|
||||
if (log_addr)
|
||||
if(log_addr)
|
||||
{
|
||||
char buffer[128];
|
||||
mdns_string_t addr = ipv4_address_to_string(buffer, sizeof(buffer), saddr,
|
||||
sizeof(struct sockaddr_in));
|
||||
ipv4_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (unicast->Address.lpSockaddr->sa_family == AF_INET6)
|
||||
else if(unicast->Address.lpSockaddr->sa_family == AF_INET6)
|
||||
{
|
||||
struct sockaddr_in6* saddr = (struct sockaddr_in6*)unicast->Address.lpSockaddr;
|
||||
static const unsigned char localhost[] = {0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1};
|
||||
static const unsigned char localhost_mapped[] = {0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0xff, 0xff, 0x7f, 0, 0, 1};
|
||||
if ((unicast->DadState == NldsPreferred) &&
|
||||
memcmp(saddr->sin6_addr.s6_addr, localhost, 16) &&
|
||||
memcmp(saddr->sin6_addr.s6_addr, localhost_mapped, 16))
|
||||
if((unicast->DadState == NldsPreferred) &&
|
||||
memcmp(saddr->sin6_addr.s6_addr, localhost, 16) &&
|
||||
memcmp(saddr->sin6_addr.s6_addr, localhost_mapped, 16))
|
||||
{
|
||||
int log_addr = 0;
|
||||
if (first_ipv6)
|
||||
if(first_ipv6)
|
||||
{
|
||||
service_address_ipv6 = *saddr;
|
||||
first_ipv6 = 0;
|
||||
log_addr = 1;
|
||||
}
|
||||
has_ipv6 = 1;
|
||||
if (num_sockets < max_sockets)
|
||||
if(num_sockets < max_sockets)
|
||||
{
|
||||
saddr->sin6_port = htons((unsigned short)port);
|
||||
int sock = mdns_socket_open_ipv6(saddr);
|
||||
if (sock >= 0)
|
||||
if(sock >= 0)
|
||||
{
|
||||
sockets[num_sockets++] = sock;
|
||||
log_addr = 1;
|
||||
|
|
@ -190,11 +208,10 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
log_addr = 0;
|
||||
}
|
||||
}
|
||||
if (log_addr)
|
||||
if(log_addr)
|
||||
{
|
||||
char buffer[128];
|
||||
mdns_string_t addr = ipv6_address_to_string(buffer, sizeof(buffer), saddr,
|
||||
sizeof(struct sockaddr_in6));
|
||||
ipv6_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -212,29 +229,32 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
|
||||
int first_ipv4 = 1;
|
||||
int first_ipv6 = 1;
|
||||
for (ifa = ifaddr; ifa; ifa = ifa->ifa_next)
|
||||
{
|
||||
if (!ifa->ifa_addr)
|
||||
continue;
|
||||
|
||||
if (ifa->ifa_addr->sa_family == AF_INET)
|
||||
for(ifa = ifaddr; ifa; ifa = ifa->ifa_next)
|
||||
{
|
||||
if(!ifa->ifa_addr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(ifa->ifa_addr->sa_family == AF_INET)
|
||||
{
|
||||
struct sockaddr_in* saddr = (struct sockaddr_in*)ifa->ifa_addr;
|
||||
if (saddr->sin_addr.s_addr != htonl(INADDR_LOOPBACK))
|
||||
if(saddr->sin_addr.s_addr != htonl(INADDR_LOOPBACK))
|
||||
{
|
||||
int log_addr = 0;
|
||||
if (first_ipv4)
|
||||
if(first_ipv4)
|
||||
{
|
||||
service_address_ipv4 = *saddr;
|
||||
first_ipv4 = 0;
|
||||
log_addr = 1;
|
||||
}
|
||||
has_ipv4 = 1;
|
||||
if (num_sockets < max_sockets)
|
||||
if(num_sockets < max_sockets)
|
||||
{
|
||||
saddr->sin_port = htons(port);
|
||||
int sock = mdns_socket_open_ipv4(saddr);
|
||||
if (sock >= 0)
|
||||
if(sock >= 0)
|
||||
{
|
||||
sockets[num_sockets++] = sock;
|
||||
log_addr = 1;
|
||||
|
|
@ -244,15 +264,14 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
log_addr = 0;
|
||||
}
|
||||
}
|
||||
if (log_addr)
|
||||
if(log_addr)
|
||||
{
|
||||
char buffer[128];
|
||||
mdns_string_t addr = ipv4_address_to_string(buffer, sizeof(buffer), saddr,
|
||||
sizeof(struct sockaddr_in));
|
||||
ipv4_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ifa->ifa_addr->sa_family == AF_INET6)
|
||||
else if(ifa->ifa_addr->sa_family == AF_INET6)
|
||||
{
|
||||
struct sockaddr_in6* saddr = (struct sockaddr_in6*)ifa->ifa_addr;
|
||||
static const unsigned char localhost[] = {0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
@ -263,14 +282,14 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
memcmp(saddr->sin6_addr.s6_addr, localhost_mapped, 16))
|
||||
{
|
||||
int log_addr = 0;
|
||||
if (first_ipv6)
|
||||
if(first_ipv6)
|
||||
{
|
||||
service_address_ipv6 = *saddr;
|
||||
first_ipv6 = 0;
|
||||
log_addr = 1;
|
||||
}
|
||||
has_ipv6 = 1;
|
||||
if (num_sockets < max_sockets)
|
||||
if(num_sockets < max_sockets)
|
||||
{
|
||||
saddr->sin6_port = htons(port);
|
||||
int sock = mdns_socket_open_ipv6(saddr);
|
||||
|
|
@ -284,11 +303,10 @@ static int open_client_sockets(int* sockets, int max_sockets, int port)
|
|||
log_addr = 0;
|
||||
}
|
||||
}
|
||||
if (log_addr)
|
||||
if(log_addr)
|
||||
{
|
||||
char buffer[128];
|
||||
mdns_string_t addr = ipv6_address_to_string(buffer, sizeof(buffer), saddr,
|
||||
sizeof(struct sockaddr_in6));
|
||||
ipv6_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -326,18 +344,17 @@ static int query_callback(
|
|||
(void)sizeof(name_length);
|
||||
(void)sizeof(user_data);
|
||||
|
||||
if (rtype == MDNS_RECORDTYPE_A)
|
||||
if(rtype == MDNS_RECORDTYPE_A)
|
||||
{
|
||||
struct sockaddr_in address;
|
||||
mdns_record_parse_a(data, size, record_offset, record_length, &address);
|
||||
|
||||
if (address.sin_port == 0)
|
||||
if(address.sin_port == 0)
|
||||
{
|
||||
address.sin_port = 16021; // Default Nanoleaf port.
|
||||
}
|
||||
|
||||
mdns_string_t addrstr =
|
||||
ipv4_address_to_string(namebuffer, sizeof(namebuffer), &address, sizeof(address));
|
||||
|
||||
// printf("A %.*s:%u\n", MDNS_STRING_FORMAT(addrstr), address.sin_port);
|
||||
mdns_string_t addrstr = ipv4_address_to_string(namebuffer, sizeof(namebuffer), &address, sizeof(address));
|
||||
|
||||
(static_cast<OpenRGBNanoleafScanningThread*>(user_data))->EmitDeviceFound(addrstr.str, address.sin_port);
|
||||
}
|
||||
|
|
@ -370,20 +387,27 @@ int OpenRGBNanoleafScanningThread::SendMDNSQuery()
|
|||
void* buffer = malloc(capacity);
|
||||
size_t records;
|
||||
|
||||
const char* record_name = "PTR";
|
||||
if (record == MDNS_RECORDTYPE_SRV)
|
||||
const char* record_name;
|
||||
if(record == MDNS_RECORDTYPE_SRV)
|
||||
{
|
||||
record_name = "SRV";
|
||||
else if (record == MDNS_RECORDTYPE_A)
|
||||
}
|
||||
else if(record == MDNS_RECORDTYPE_A)
|
||||
{
|
||||
record_name = "A";
|
||||
else if (record == MDNS_RECORDTYPE_AAAA)
|
||||
}
|
||||
else if(record == MDNS_RECORDTYPE_AAAA)
|
||||
{
|
||||
record_name = "AAAA";
|
||||
}
|
||||
else
|
||||
{
|
||||
record = MDNS_RECORDTYPE_PTR;
|
||||
}
|
||||
|
||||
for (int isock = 0; isock < num_sockets; ++isock)
|
||||
for(int isock = 0; isock < num_sockets; ++isock)
|
||||
{
|
||||
query_id[isock] =
|
||||
mdns_query_send(sockets[isock], record, service, strlen(service), buffer, capacity, 0);
|
||||
query_id[isock] = mdns_query_send(sockets[isock], record, service, strlen(service), buffer, capacity, 0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -400,24 +424,27 @@ int OpenRGBNanoleafScanningThread::SendMDNSQuery()
|
|||
int nfds = 0;
|
||||
fd_set readfs;
|
||||
FD_ZERO(&readfs);
|
||||
for (int isock = 0; isock < num_sockets; ++isock)
|
||||
for(int isock = 0; isock < num_sockets; ++isock)
|
||||
{
|
||||
if (sockets[isock] >= nfds)
|
||||
if(sockets[isock] >= nfds)
|
||||
{
|
||||
nfds = sockets[isock] + 1;
|
||||
}
|
||||
|
||||
FD_SET(sockets[isock], &readfs);
|
||||
}
|
||||
|
||||
records = 0;
|
||||
res = select(nfds, &readfs, 0, 0, &timeout);
|
||||
if (res > 0)
|
||||
if(res > 0)
|
||||
{
|
||||
for (int isock = 0; isock < num_sockets; ++isock)
|
||||
for(int isock = 0; isock < num_sockets; ++isock)
|
||||
{
|
||||
if (FD_ISSET(sockets[isock], &readfs))
|
||||
if(FD_ISSET(sockets[isock], &readfs))
|
||||
{
|
||||
records += mdns_query_recv(sockets[isock], buffer, capacity, query_callback,
|
||||
this, query_id[isock]);
|
||||
records += mdns_query_recv(sockets[isock], buffer, capacity, query_callback, this, query_id[isock]);
|
||||
}
|
||||
|
||||
FD_SET(sockets[isock], &readfs);
|
||||
}
|
||||
}
|
||||
|
|
@ -426,8 +453,10 @@ int OpenRGBNanoleafScanningThread::SendMDNSQuery()
|
|||
|
||||
free(buffer);
|
||||
|
||||
for (int isock = 0; isock < num_sockets; ++isock)
|
||||
for(int isock = 0; isock < num_sockets; ++isock)
|
||||
{
|
||||
mdns_socket_close(sockets[isock]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,17 @@ void superio_enter(int ioreg)
|
|||
if (dev_port_fd >= 0)
|
||||
{
|
||||
lseek(dev_port_fd, ioreg, SEEK_SET);
|
||||
write(dev_port_fd, &temp, 1);
|
||||
if(write(dev_port_fd, &temp, 1) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lseek(dev_port_fd, ioreg, SEEK_SET);
|
||||
write(dev_port_fd, &temp, 1);
|
||||
if(write(dev_port_fd, &temp, 1) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
close(dev_port_fd);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -67,8 +75,16 @@ void superio_outb(int ioreg, int reg, int val)
|
|||
if (dev_port_fd >= 0)
|
||||
{
|
||||
lseek(dev_port_fd, ioreg, SEEK_SET);
|
||||
write(dev_port_fd, ®, 1);
|
||||
write(dev_port_fd, &val, 1);
|
||||
if(write(dev_port_fd, ®, 1) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(write(dev_port_fd, &val, 1) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
close(dev_port_fd);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -95,9 +111,18 @@ int superio_inb(int ioreg, int reg)
|
|||
if (dev_port_fd >= 0)
|
||||
{
|
||||
lseek(dev_port_fd, ioreg, SEEK_SET);
|
||||
write(dev_port_fd, ®, 1);
|
||||
read(dev_port_fd, &temp, 1);
|
||||
if(write(dev_port_fd, ®, 1) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(read(dev_port_fd, &temp, 1) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(dev_port_fd);
|
||||
|
||||
return((int)temp);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue