drivers/input: Fix warnings and enable Werror
Correct signedness for comparisons, remove unused code, remove unused variable, correct variable type for callbacks Part of #9460 Change-Id: Ie48e8498e0830ed8b175986aaf82b94a1d99b72f Reviewed-on: https://review.haiku-os.org/c/haiku/+/4570 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
d81238bf2f
commit
718fce997a
@@ -667,7 +667,7 @@ rule ArchitectureSetupWarnings architecture
|
|||||||
EnableWerror src add-ons kernel drivers dvb ;
|
EnableWerror src add-ons kernel drivers dvb ;
|
||||||
# EnableWerror src add-ons kernel drivers graphics ;
|
# EnableWerror src add-ons kernel drivers graphics ;
|
||||||
EnableWerror src add-ons kernel drivers graphics intel_extreme ;
|
EnableWerror src add-ons kernel drivers graphics intel_extreme ;
|
||||||
# EnableWerror src add-ons kernel drivers input ;
|
EnableWerror src add-ons kernel drivers input ;
|
||||||
EnableWerror src add-ons kernel drivers joystick ;
|
EnableWerror src add-ons kernel drivers joystick ;
|
||||||
EnableWerror src add-ons kernel drivers midi ;
|
EnableWerror src add-ons kernel drivers midi ;
|
||||||
EnableWerror src add-ons kernel drivers misc ;
|
EnableWerror src add-ons kernel drivers misc ;
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ HIDCollection::AddChild(HIDCollection *child)
|
|||||||
HIDCollection *
|
HIDCollection *
|
||||||
HIDCollection::ChildAt(uint32 index)
|
HIDCollection::ChildAt(uint32 index)
|
||||||
{
|
{
|
||||||
if (index >= fChildren.Count())
|
int32 count = fChildren.Count();
|
||||||
|
if (count < 0 || index >= (uint32)count)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return fChildren[index];
|
return fChildren[index];
|
||||||
@@ -129,7 +130,8 @@ HIDCollection::AddItem(HIDReportItem *item)
|
|||||||
HIDReportItem *
|
HIDReportItem *
|
||||||
HIDCollection::ItemAt(uint32 index)
|
HIDCollection::ItemAt(uint32 index)
|
||||||
{
|
{
|
||||||
if (index >= fItems.Count())
|
int32 count = fItems.Count();
|
||||||
|
if (count < 0 || index >= (uint32)count)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return fItems[index];
|
return fItems[index];
|
||||||
@@ -239,7 +241,8 @@ HIDCollection::_ChildAtFlat(uint8 type, uint32 &index)
|
|||||||
HIDReportItem *
|
HIDReportItem *
|
||||||
HIDCollection::_ItemAtFlat(uint32 &index)
|
HIDCollection::_ItemAtFlat(uint32 &index)
|
||||||
{
|
{
|
||||||
if (index < fItems.Count())
|
int32 count = fItems.Count();
|
||||||
|
if (count > 0 && index < (uint32)count)
|
||||||
return fItems[index];
|
return fItems[index];
|
||||||
|
|
||||||
index -= fItems.Count();
|
index -= fItems.Count();
|
||||||
|
|||||||
@@ -194,7 +194,8 @@ HIDReport::SendReport()
|
|||||||
HIDReportItem *
|
HIDReportItem *
|
||||||
HIDReport::ItemAt(uint32 index)
|
HIDReport::ItemAt(uint32 index)
|
||||||
{
|
{
|
||||||
if (index >= fItems.Count())
|
int32 count = fItems.Count();
|
||||||
|
if (count < 0 || index >= (uint32)count)
|
||||||
return NULL;
|
return NULL;
|
||||||
return fItems[index];
|
return fItems[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ struct VirtioInputHandle {
|
|||||||
|
|
||||||
device_manager_info* gDeviceManager;
|
device_manager_info* gDeviceManager;
|
||||||
|
|
||||||
|
#ifdef TRACE_VIRTIO_INPUT
|
||||||
static void
|
static void
|
||||||
WriteInputPacket(const VirtioInputPacket &pkt)
|
WriteInputPacket(const VirtioInputPacket &pkt)
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ WriteInputPacket(const VirtioInputPacket &pkt)
|
|||||||
TRACE(", %" B_PRId32, pkt.value);
|
TRACE(", %" B_PRId32, pkt.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
InitPackets(VirtioInputDevice* dev, uint32 count)
|
InitPackets(VirtioInputDevice* dev, uint32 count)
|
||||||
@@ -208,26 +208,6 @@ PacketPhysEntry(VirtioInputDevice* dev, Packet* pkt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Packet*
|
|
||||||
AllocPacket(VirtioInputDevice* dev)
|
|
||||||
{
|
|
||||||
int32 idx = dev->freePackets;
|
|
||||||
if (idx < 0)
|
|
||||||
return NULL;
|
|
||||||
dev->freePackets = dev->packets[idx].next;
|
|
||||||
|
|
||||||
return &dev->packets[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
FreePacket(VirtioInputDevice* dev, Packet* pkt)
|
|
||||||
{
|
|
||||||
pkt->next = dev->freePackets;
|
|
||||||
dev->freePackets = pkt - dev->packets;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ScheduleReadyPacket(VirtioInputDevice* dev, Packet* pkt)
|
ScheduleReadyPacket(VirtioInputDevice* dev, Packet* pkt)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -109,12 +109,12 @@ static wacom_device*
|
|||||||
add_device(usb_device dev)
|
add_device(usb_device dev)
|
||||||
{
|
{
|
||||||
wacom_device *device = NULL;
|
wacom_device *device = NULL;
|
||||||
int num, ifc, alt;
|
int num;
|
||||||
|
size_t ifc, alt;
|
||||||
const usb_interface_info *ii;
|
const usb_interface_info *ii;
|
||||||
status_t st;
|
status_t st;
|
||||||
const usb_device_descriptor* udd;
|
const usb_device_descriptor* udd;
|
||||||
const usb_configuration_info *conf;
|
const usb_configuration_info *conf;
|
||||||
bool setConfiguration = false;
|
|
||||||
|
|
||||||
// we need these four for a Wacom tablet
|
// we need these four for a Wacom tablet
|
||||||
size_t controlTransferLength;
|
size_t controlTransferLength;
|
||||||
@@ -137,7 +137,6 @@ add_device(usb_device dev)
|
|||||||
// see if the device has been configured already
|
// see if the device has been configured already
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
conf = usb->get_nth_configuration(dev, 0);
|
conf = usb->get_nth_configuration(dev, 0);
|
||||||
setConfiguration = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
@@ -184,8 +183,6 @@ got_one:
|
|||||||
device->notify_lock = -1;
|
device->notify_lock = -1;
|
||||||
device->data = NULL;
|
device->data = NULL;
|
||||||
|
|
||||||
// if (setConfiguration) {
|
|
||||||
// the configuration has to be set yet (was not the current one)
|
|
||||||
DPRINTF_INFO((ID "add_device() - setting configuration...\n"));
|
DPRINTF_INFO((ID "add_device() - setting configuration...\n"));
|
||||||
if ((st = usb->set_configuration(dev, conf)) != B_OK) {
|
if ((st = usb->set_configuration(dev, conf)) != B_OK) {
|
||||||
dprintf(ID "add_device() -> "
|
dprintf(ID "add_device() -> "
|
||||||
@@ -273,7 +270,6 @@ got_one:
|
|||||||
dprintf(ID "add_device() - set 'Wacom'-mode failed\n");
|
dprintf(ID "add_device() - set 'Wacom'-mode failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// configure the rest of the wacom_device
|
// configure the rest of the wacom_device
|
||||||
device->pipe = ii->endpoint[0].handle;
|
device->pipe = ii->endpoint[0].handle;
|
||||||
@@ -479,16 +475,16 @@ device_free(void *cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// device_interupt_callback
|
// device_interrupt_callback
|
||||||
static void
|
static void
|
||||||
device_interupt_callback(void* cookie, status_t status, void* data,
|
device_interrupt_callback(void* cookie, status_t status, void* data,
|
||||||
uint32 actualLength)
|
size_t actualLength)
|
||||||
{
|
{
|
||||||
wacom_device* device = (wacom_device*)cookie;
|
wacom_device* device = (wacom_device*)cookie;
|
||||||
uint32 length = min_c(actualLength, device->max_packet_size);
|
size_t length = min_c(actualLength, device->max_packet_size);
|
||||||
|
|
||||||
DPRINTF_INFO((ID "device_interupt_callback(%p) name = \"%s%d\" -> "
|
DPRINTF_INFO((ID "device_interrupt_callback(%p) name = \"%s%d\" -> "
|
||||||
"status: %ld, length: %ld\n", cookie, kBasePublishPath, device->number,
|
"status: %ld, length: %zu\n", cookie, kBasePublishPath, device->number,
|
||||||
status, actualLength));
|
status, actualLength));
|
||||||
|
|
||||||
device->status = status;
|
device->status = status;
|
||||||
@@ -502,7 +498,7 @@ device_interupt_callback(void* cookie, status_t status, void* data,
|
|||||||
release_sem(device->notify_lock);
|
release_sem(device->notify_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINTF_INFO((ID "device_interupt_callback() - done\n"));
|
DPRINTF_INFO((ID "device_interrupt_callback() - done\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// read_header
|
// read_header
|
||||||
@@ -548,7 +544,7 @@ device_read(void* cookie, off_t pos, void* buf, size_t* count)
|
|||||||
if (*count > sizeof(wacom_device_header)) {
|
if (*count > sizeof(wacom_device_header)) {
|
||||||
// queue the interrupt transfer
|
// queue the interrupt transfer
|
||||||
ret = usb->queue_interrupt(device->pipe, device->data,
|
ret = usb->queue_interrupt(device->pipe, device->data,
|
||||||
device->max_packet_size, device_interupt_callback, device);
|
device->max_packet_size, device_interrupt_callback, device);
|
||||||
if (ret >= B_OK) {
|
if (ret >= B_OK) {
|
||||||
// we will block here until the interrupt transfer has been done
|
// we will block here until the interrupt transfer has been done
|
||||||
ret = acquire_sem_etc(device->notify_lock, 1,
|
ret = acquire_sem_etc(device->notify_lock, 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user