Fix some compile warnings.

MFC after:	1 week
This commit is contained in:
hselasky 2012-04-20 14:29:45 +00:00
parent 433fc8eeff
commit 3463f3d087
6 changed files with 29 additions and 30 deletions

View File

@ -651,17 +651,17 @@ libusb_set_interface_alt_setting(struct libusb20_device *pdev,
static struct libusb20_transfer *
libusb10_get_transfer(struct libusb20_device *pdev,
uint8_t endpoint, uint8_t index)
uint8_t endpoint, uint8_t xfer_index)
{
index &= 1; /* double buffering */
xfer_index &= 1; /* double buffering */
index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4;
xfer_index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4;
if (endpoint & LIBUSB20_ENDPOINT_DIR_MASK) {
/* this is an IN endpoint */
index |= 2;
xfer_index |= 2;
}
return (libusb20_tr_get_pointer(pdev, index));
return (libusb20_tr_get_pointer(pdev, xfer_index));
}
int

View File

@ -390,8 +390,8 @@ libusb_parse_bos_descriptor(const void *buf, int len,
struct libusb_bos_descriptor **bos)
{
struct libusb_bos_descriptor *ptr;
struct libusb_usb_2_0_device_capability_descriptor *dcap_20;
struct libusb_ss_usb_device_capability_descriptor *ss_cap;
struct libusb_usb_2_0_device_capability_descriptor *dcap_20 = NULL;
struct libusb_ss_usb_device_capability_descriptor *ss_cap = NULL;
if (buf == NULL || bos == NULL || len < 1)
return (LIBUSB_ERROR_INVALID_PARAM);
@ -438,7 +438,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
dtype == LIBUSB_DT_DEVICE_CAPABILITY) {
switch (((const uint8_t *)buf)[2]) {
case LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY:
if (ptr->usb_2_0_ext_cap != NULL)
if (ptr->usb_2_0_ext_cap != NULL || dcap_20 == NULL)
break;
if (dlen < LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE)
break;
@ -455,7 +455,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
break;
case LIBUSB_SS_USB_DEVICE_CAPABILITY:
if (ptr->ss_usb_cap != NULL)
if (ptr->ss_usb_cap != NULL || ss_cap == NULL)
break;
if (dlen < LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE)
break;

View File

@ -481,7 +481,7 @@ libusb10_do_transfer(libusb_device_handle *devh,
{
libusb_context *ctx;
struct libusb_transfer *xfer;
volatile int complet;
int done;
int ret;
if (devh == NULL)
@ -502,15 +502,15 @@ libusb10_do_transfer(libusb_device_handle *devh,
xfer->timeout = timeout;
xfer->buffer = data;
xfer->length = length;
xfer->user_data = (void *)&complet;
xfer->user_data = (void *)&done;
xfer->callback = libusb10_do_transfer_cb;
complet = 0;
done = 0;
if ((ret = libusb_submit_transfer(xfer)) < 0) {
libusb_free_transfer(xfer);
return (ret);
}
while (complet == 0) {
while (done == 0) {
if ((ret = libusb_handle_events(ctx)) < 0) {
libusb_cancel_transfer(xfer);
usleep(1000); /* nice it */
@ -581,7 +581,7 @@ libusb_interrupt_transfer(libusb_device_handle *devh,
}
uint8_t *
libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index)
libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t off)
{
uint8_t *ptr;
uint32_t n;
@ -589,35 +589,35 @@ libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index)
if (transfer->num_iso_packets < 0)
return (NULL);
if (index >= (uint32_t)transfer->num_iso_packets)
if (off >= (uint32_t)transfer->num_iso_packets)
return (NULL);
ptr = transfer->buffer;
if (ptr == NULL)
return (NULL);
for (n = 0; n != index; n++) {
for (n = 0; n != off; n++) {
ptr += transfer->iso_packet_desc[n].length;
}
return (ptr);
}
uint8_t *
libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t index)
libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t off)
{
uint8_t *ptr;
if (transfer->num_iso_packets < 0)
return (NULL);
if (index >= (uint32_t)transfer->num_iso_packets)
if (off >= (uint32_t)transfer->num_iso_packets)
return (NULL);
ptr = transfer->buffer;
if (ptr == NULL)
return (NULL);
ptr += transfer->iso_packet_desc[0].length * index;
ptr += transfer->iso_packet_desc[0].length * off;
return (ptr);
}

View File

@ -948,9 +948,8 @@ libusb20_dev_get_config_index(struct libusb20_device *pdev)
}
error = pdev->methods->get_config_index(pdev, &cfg_index);
if (error) {
cfg_index = 0 - 1; /* current config index */
}
if (error)
cfg_index = 0xFF; /* current config index */
if (do_close) {
if (libusb20_dev_close(pdev)) {
/* ignore */

View File

@ -69,7 +69,7 @@ libusb20_parse_config_desc(const void *config_desc)
uint16_t niface_no_alt;
uint16_t niface;
uint16_t nendpoint;
uint8_t iface_no;
uint16_t iface_no;
ptr = config_desc;
if (ptr[1] != LIBUSB20_DT_CONFIG) {
@ -82,7 +82,7 @@ libusb20_parse_config_desc(const void *config_desc)
niface_no_alt = 0;
nendpoint = 0;
niface = 0;
iface_no = 0 - 1;
iface_no = 0xFFFF;
ptr = NULL;
/* get "wTotalLength" and setup "pcdesc" */
@ -155,7 +155,7 @@ libusb20_parse_config_desc(const void *config_desc)
/* reset states */
niface = 0;
iface_no = 0 - 1;
iface_no = 0xFFFF;
ptr = NULL;
lub_interface--;
lub_endpoint--;
@ -450,7 +450,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
* and should be
* correct:
*/
ps->len = 0 - 1;
ps->len = 0xFFFF;
}
src_len = libusb20_me_get_1(pd, 0);
src_ptr = LIBUSB20_ADD_BYTES(ps->ptr, 1);
@ -465,7 +465,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
case LIBUSB20_ME_IS_DECODED:
/* reserve 3 length bytes */
src_len = libusb20_me_encode(NULL,
0 - 1 - 3, ps->ptr);
0xFFFF - 3, ps->ptr);
src_ptr = NULL;
break;
@ -476,7 +476,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
}
if (src_len > 0xFE) {
if (src_len > (uint16_t)(0 - 1 - 3))
if (src_len > (0xFFFF - 3))
/* overflow */
goto done;
@ -516,7 +516,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
uint16_t dummy;
dummy = libusb20_me_encode(buf,
0 - 1 - 3, ps->ptr);
0xFFFF - 3, ps->ptr);
} else {
bcopy(src_ptr, buf, src_len);
}

View File

@ -104,7 +104,7 @@ ugen20_path_convert_one(const char **pp)
temp += (*ptr - '0');
if (temp >= 1000000) {
/* catch overflow early */
return (0 - 1);
return (0xFFFFFFFF);
}
ptr++;
}