diff options
author | hselasky <hselasky@FreeBSD.org> | 2012-04-02 10:50:42 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2012-04-02 10:50:42 +0000 |
commit | 126953ccbe190fe51094d1ccefda3226d1e5140c (patch) | |
tree | 70a9d586e75b3d8e087069f07020564df44b0b99 /sys/dev/usb | |
parent | 56216c3bc99342baf89a814301e85dffe7a62a9b (diff) | |
download | FreeBSD-src-126953ccbe190fe51094d1ccefda3226d1e5140c.zip FreeBSD-src-126953ccbe190fe51094d1ccefda3226d1e5140c.tar.gz |
Fix compiler warnings, mostly signed issues,
when USB modules are compiled with WARNS=9.
MFC after: 1 weeks
Diffstat (limited to 'sys/dev/usb')
59 files changed, 242 insertions, 255 deletions
diff --git a/sys/dev/usb/controller/at91dci.c b/sys/dev/usb/controller/at91dci.c index d325812..e7d5e6e 100644 --- a/sys/dev/usb/controller/at91dci.c +++ b/sys/dev/usb/controller/at91dci.c @@ -1725,14 +1725,13 @@ static const struct at91dci_config_desc at91dci_confd = { }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min at91dci_hubd = { .bDescLength = sizeof(at91dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ diff --git a/sys/dev/usb/controller/atmegadci.c b/sys/dev/usb/controller/atmegadci.c index 7db3bdb..700ca8f 100644 --- a/sys/dev/usb/controller/atmegadci.c +++ b/sys/dev/usb/controller/atmegadci.c @@ -1548,14 +1548,13 @@ static const struct atmegadci_config_desc atmegadci_confd = { }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min atmegadci_hubd = { .bDescLength = sizeof(atmegadci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ diff --git a/sys/dev/usb/controller/avr32dci.c b/sys/dev/usb/controller/avr32dci.c index 9494c30..9f9cd5d 100644 --- a/sys/dev/usb/controller/avr32dci.c +++ b/sys/dev/usb/controller/avr32dci.c @@ -1489,14 +1489,13 @@ static const struct avr32dci_config_desc avr32dci_confd = { }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min avr32dci_hubd = { .bDescLength = sizeof(avr32dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index fee1207..f3ef19a 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -2057,14 +2057,13 @@ static const struct dwc_otg_config_desc dwc_otg_confd = { }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min dwc_otg_hubd = { .bDescLength = sizeof(dwc_otg_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c index f59c801..da37954 100644 --- a/sys/dev/usb/controller/ehci.c +++ b/sys/dev/usb/controller/ehci.c @@ -3011,13 +3011,8 @@ static const struct ehci_config_desc ehci_confd = { static const struct usb_hub_descriptor ehci_hubd = { - 0, /* dynamic length */ - UDESC_HUB, - 0, - {0, 0}, - 0, - 0, - {0}, + .bDescLength = 0, /* dynamic length */ + .bDescriptorType = UDESC_HUB, }; static void diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c index d463052..db0d54f 100644 --- a/sys/dev/usb/controller/musb_otg.c +++ b/sys/dev/usb/controller/musb_otg.c @@ -2192,14 +2192,13 @@ static const struct musbotg_config_desc musbotg_confd = { }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min musbotg_hubd = { .bDescLength = sizeof(musbotg_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 16, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c index 93c2bb2..a3179f1 100644 --- a/sys/dev/usb/controller/ohci.c +++ b/sys/dev/usb/controller/ohci.c @@ -2080,13 +2080,8 @@ struct ohci_config_desc ohci_confd = static const struct usb_hub_descriptor ohci_hubd = { - 0, /* dynamic length */ - UDESC_HUB, - 0, - {0, 0}, - 0, - 0, - {0}, + .bDescLength = 0, /* dynamic length */ + .bDescriptorType = UDESC_HUB, }; static usb_error_t diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c index d9091c9..c7a8c19 100644 --- a/sys/dev/usb/controller/uhci.c +++ b/sys/dev/usb/controller/uhci.c @@ -2351,13 +2351,11 @@ static const struct uhci_config_desc uhci_confd = { static const struct usb_hub_descriptor_min uhci_hubd_piix = { - sizeof(uhci_hubd_piix), - UDESC_HUB, - 2, - {UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL, 0}, - 50, /* power on to power good */ - 0, - {0x00}, /* both ports are removable */ + .bDescLength = sizeof(uhci_hubd_piix), + .bDescriptorType = UDESC_HUB, + .bNbrPorts = 2, + .wHubCharacteristics = {UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL, 0}, + .bPwrOn2PwrGood = 50, }; /* diff --git a/sys/dev/usb/controller/uss820dci.c b/sys/dev/usb/controller/uss820dci.c index 612bc81..19229f8 100644 --- a/sys/dev/usb/controller/uss820dci.c +++ b/sys/dev/usb/controller/uss820dci.c @@ -1789,14 +1789,13 @@ static const struct uss820dci_config_desc uss820dci_confd = { }, }; +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_hub_descriptor_min uss820dci_hubd = { .bDescLength = sizeof(uss820dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, - .wHubCharacteristics[0] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF, - .wHubCharacteristics[1] = - (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, .DeviceRemovable = {0}, /* port is removable */ diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index a9690f9..aed7edf 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -821,7 +821,7 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci_trb *trb) offset = td_event - td->td_self; if (offset >= 0 && - offset < sizeof(td->td_trb)) { + offset < (int64_t)sizeof(td->td_trb)) { usb_pc_cpu_invalidate(td->page_cache); @@ -2805,7 +2805,7 @@ struct usb_pipe_methods xhci_device_generic_methods = * Simulate a hardware HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ -#define HSETW(ptr, val) ptr[0] = (uint8_t)(val), ptr[1] = (uint8_t)((val) >> 8) +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } static const struct usb_device_descriptor xhci_devd = @@ -2848,8 +2848,7 @@ struct xhci_bos_desc xhci_bosd = { HSETW(.wSpeedsSupported, 0x000C), .bFunctionalitySupport = 8, .bU1DevExitLat = 255, /* dummy - not used */ - .wU2DevExitLat[0] = 0x00, - .wU2DevExitLat[1] = 0x08, + .wU2DevExitLat = { 0x00, 0x08 }, }, .cidd = { .bLength = sizeof(xhci_bosd.cidd), diff --git a/sys/dev/usb/input/atp.c b/sys/dev/usb/input/atp.c index 6cfba78..8a55e32 100644 --- a/sys/dev/usb/input/atp.c +++ b/sys/dev/usb/input/atp.c @@ -761,7 +761,7 @@ atp_get_pressures(int *p, const int *cur, const int *base, int n) * threshold; this will reduce the contribution from * lower pressure readings. */ - if (p[i] <= atp_sensor_noise_threshold) + if ((u_int)p[i] <= atp_sensor_noise_threshold) p[i] = 0; /* filter away noise */ else p[i] -= atp_sensor_noise_threshold; @@ -887,7 +887,7 @@ atp_match_stroke_component(atp_stroke_component *component, delta_mickeys = pspan->loc - component->loc; - if (abs(delta_mickeys) > atp_max_delta_mickeys) + if ((u_int)abs(delta_mickeys) > atp_max_delta_mickeys) return (FALSE); /* the finger span is too far out; no match */ component->loc = pspan->loc; @@ -1164,9 +1164,10 @@ static void atp_add_new_strokes(struct atp_softc *sc, atp_pspan *pspans_x, u_int n_xpspans, atp_pspan *pspans_y, u_int n_ypspans) { - int i, j; atp_pspan spans[2][ATP_MAX_PSPANS_PER_AXIS]; - u_int nspans[2]; + u_int nspans[2]; + u_int i; + u_int j; /* Copy unmatched pspans into the local arrays. */ for (i = 0, nspans[X] = 0; i < n_xpspans; i++) { @@ -1373,9 +1374,9 @@ atp_terminate_stroke(struct atp_softc *sc, static __inline boolean_t atp_stroke_has_small_movement(const atp_stroke *stroke) { - return ((abs(stroke->components[X].delta_mickeys) <= + return (((u_int)abs(stroke->components[X].delta_mickeys) <= atp_small_movement_threshold) && - (abs(stroke->components[Y].delta_mickeys) <= + ((u_int)abs(stroke->components[Y].delta_mickeys) <= atp_small_movement_threshold)); } @@ -1388,7 +1389,7 @@ static __inline void atp_update_pending_mickeys(atp_stroke_component *component) { component->pending += component->delta_mickeys; - if (abs(component->pending) <= atp_small_movement_threshold) + if ((u_int)abs(component->pending) <= atp_small_movement_threshold) component->delta_mickeys = 0; else { /* @@ -1690,7 +1691,7 @@ atp_attach(device_t dev) if (usb_fifo_attach(sc->sc_usb_device, sc, &sc->sc_mutex, &atp_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644)) { goto detach; } @@ -1764,13 +1765,13 @@ atp_intr(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (len > sc->sc_params->data_len) { + if (len > (int)sc->sc_params->data_len) { DPRINTFN(ATP_LLEVEL_ERROR, "truncating large packet from %u to %u bytes\n", len, sc->sc_params->data_len); len = sc->sc_params->data_len; } - if (len < sc->sc_params->data_len) + if (len < (int)sc->sc_params->data_len) goto tr_setup; pc = usbd_xfer_get_frame(xfer, 0); @@ -2213,9 +2214,9 @@ static device_method_t atp_methods[] = { }; static driver_t atp_driver = { - ATP_DRIVER_NAME, - atp_methods, - sizeof(struct atp_softc) + .name = ATP_DRIVER_NAME, + .methods = atp_methods, + .size = sizeof(struct atp_softc) }; static devclass_t atp_devclass; diff --git a/sys/dev/usb/input/uep.c b/sys/dev/usb/input/uep.c index e534b27..b468c3d 100644 --- a/sys/dev/usb/input/uep.c +++ b/sys/dev/usb/input/uep.c @@ -202,7 +202,7 @@ uep_intr_callback(struct usb_xfer *xfer, usb_error_t error) u_char buf[17], *p; int pkt_len; - if (len > sizeof(buf)) { + if (len > (int)sizeof(buf)) { DPRINTF("bad input length %d\n", len); goto tr_setup; } @@ -329,7 +329,7 @@ uep_attach(device_t dev) } error = usb_fifo_attach(uaa->device, sc, &sc->mtx, &uep_fifo_methods, - &sc->fifo, device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + &sc->fifo, device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c index 929227b..a1050c6 100644 --- a/sys/dev/usb/input/uhid.c +++ b/sys/dev/usb/input/uhid.c @@ -170,10 +170,10 @@ uhid_intr_callback(struct usb_xfer *xfer, usb_error_t error) * If the ID byte is non zero we allow descriptors * having multiple sizes: */ - if ((actlen >= sc->sc_isize) || + if ((actlen >= (int)sc->sc_isize) || ((actlen > 0) && (sc->sc_iid != 0))) { /* limit report length to the maximum */ - if (actlen > sc->sc_isize) + if (actlen > (int)sc->sc_isize) actlen = sc->sc_isize; usb_fifo_put_data(sc->sc_fifo.fp[USB_FIFO_RX], pc, 0, actlen, 1); @@ -768,7 +768,7 @@ uhid_attach(device_t dev) error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &uhid_fifo_methods, &sc->sc_fifo, - unit, 0 - 1, uaa->info.bIfaceIndex, + unit, -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index eb7e1d9..7f8bfd4 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -2047,7 +2047,7 @@ ukbd_key2scan(struct ukbd_softc *sc, int code, int shift, int up) 0x5c, /* Keyboard Intl' 6 (Keypad ,) (For PC-9821 layout) */ }; - if ((code >= 89) && (code < (89 + (sizeof(scan) / sizeof(scan[0]))))) { + if ((code >= 89) && (code < (int)(89 + (sizeof(scan) / sizeof(scan[0]))))) { code = scan[code - 89]; } /* Pause/Break */ diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c index a910df4..2773144 100644 --- a/sys/dev/usb/input/ums.c +++ b/sys/dev/usb/input/ums.c @@ -201,7 +201,7 @@ ums_intr_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: DPRINTFN(6, "sc=%p actlen=%d\n", sc, len); - if (len > sizeof(sc->sc_temp)) { + if (len > (int)sizeof(sc->sc_temp)) { DPRINTFN(6, "truncating large packet to %zu bytes\n", sizeof(sc->sc_temp)); len = sizeof(sc->sc_temp); @@ -644,7 +644,7 @@ ums_attach(device_t dev) /* Some wheels need the Z axis reversed. */ info->sc_flags |= UMS_FLAG_REVZ; } - if (isize > usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT])) { + if (isize > (int)usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT])) { DPRINTF("WARNING: report size, %d bytes, is larger " "than interrupt size, %d bytes!\n", isize, usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT])); @@ -698,7 +698,7 @@ ums_attach(device_t dev) err = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &ums_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (err) { goto detach; diff --git a/sys/dev/usb/misc/ufm.c b/sys/dev/usb/misc/ufm.c index 11bea65..032b635 100644 --- a/sys/dev/usb/misc/ufm.c +++ b/sys/dev/usb/misc/ufm.c @@ -156,7 +156,7 @@ ufm_attach(device_t dev) error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &ufm_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; diff --git a/sys/dev/usb/net/if_aue.c b/sys/dev/usb/net/if_aue.c index fdee6b7..33ed236 100644 --- a/sys/dev/usb/net/if_aue.c +++ b/sys/dev/usb/net/if_aue.c @@ -740,7 +740,7 @@ aue_intr_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && - actlen >= sizeof(pkt)) { + actlen >= (int)sizeof(pkt)) { pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, &pkt, sizeof(pkt)); @@ -793,7 +793,7 @@ aue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) } } else { - if (actlen <= sizeof(stat) + ETHER_CRC_LEN) { + if (actlen <= (int)(sizeof(stat) + ETHER_CRC_LEN)) { ifp->if_ierrors++; goto tr_setup; } diff --git a/sys/dev/usb/net/if_axe.c b/sys/dev/usb/net/if_axe.c index 02bb358..2f9929f 100644 --- a/sys/dev/usb/net/if_axe.c +++ b/sys/dev/usb/net/if_axe.c @@ -1037,7 +1037,7 @@ axe_rx_frame(struct usb_ether *ue, struct usb_page_cache *pc, int actlen) error = 0; if ((sc->sc_flags & AXE_FLAG_STD_FRAME) != 0) { while (pos < actlen) { - if ((pos + sizeof(hdr)) > actlen) { + if ((int)(pos + sizeof(hdr)) > actlen) { /* too little data */ error = EINVAL; break; @@ -1061,7 +1061,7 @@ axe_rx_frame(struct usb_ether *ue, struct usb_page_cache *pc, int actlen) } } else if ((sc->sc_flags & AXE_FLAG_CSUM_FRAME) != 0) { while (pos < actlen) { - if ((pos + sizeof(csum_hdr)) > actlen) { + if ((int)(pos + sizeof(csum_hdr)) > actlen) { /* too little data */ error = EINVAL; break; diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c index eabf9c6..780efe8 100644 --- a/sys/dev/usb/net/if_cdce.c +++ b/sys/dev/usb/net/if_cdce.c @@ -303,8 +303,8 @@ cdce_ncm_init(struct cdce_softc *sc) int err; ufd = usbd_find_descriptor(sc->sc_ue.ue_udev, NULL, - sc->sc_ifaces_index[1], UDESC_CS_INTERFACE, 0 - 1, - UCDC_NCM_FUNC_DESC_SUBTYPE, 0 - 1); + sc->sc_ifaces_index[1], UDESC_CS_INTERFACE, 0xFF, + UCDC_NCM_FUNC_DESC_SUBTYPE, 0xFF); /* verify length of NCM functional descriptor */ if (ufd != NULL) { @@ -514,7 +514,7 @@ cdce_attach(device_t dev) ud = usbd_find_descriptor (uaa->device, NULL, uaa->info.bIfaceIndex, - UDESC_CS_INTERFACE, 0 - 1, UDESCSUB_CDC_UNION, 0 - 1); + UDESC_CS_INTERFACE, 0xFF, UDESCSUB_CDC_UNION, 0xFF); if ((ud == NULL) || (ud->bLength < sizeof(*ud)) || (sc->sc_flags & CDCE_FLAG_NO_UNION)) { @@ -598,7 +598,7 @@ alloc_transfers: ued = usbd_find_descriptor (uaa->device, NULL, uaa->info.bIfaceIndex, - UDESC_CS_INTERFACE, 0 - 1, UDESCSUB_CDC_ENF, 0 - 1); + UDESC_CS_INTERFACE, 0xFF, UDESCSUB_CDC_ENF, 0xFF); if ((ued == NULL) || (ued->bLength < sizeof(*ued))) { error = USB_ERR_INVAL; @@ -892,7 +892,9 @@ cdce_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) struct cdce_softc *sc = usbd_xfer_softc(xfer); struct mbuf *m; uint8_t x; - int actlen, aframes, len; + int actlen; + int aframes; + int len; usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL); @@ -911,7 +913,7 @@ cdce_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) if ((sc->sc_flags & CDCE_FLAG_ZAURUS) && len >= 14) len -= 4; - if (len < sizeof(struct ether_header)) { + if (len < (int)sizeof(struct ether_header)) { m_freem(m); continue; } @@ -1096,7 +1098,7 @@ cdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index) break; } - if (m->m_pkthdr.len > rem) { + if (m->m_pkthdr.len > (int)rem) { if (n == 0) { /* The frame won't fit in our buffer */ DPRINTFN(1, "Frame too big to be transmitted!\n"); @@ -1278,7 +1280,7 @@ cdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(1, "received %u bytes in %u frames\n", actlen, aframes); - if (actlen < (sizeof(sc->sc_ncm.hdr) + + if (actlen < (int)(sizeof(sc->sc_ncm.hdr) + sizeof(sc->sc_ncm.dpt))) { DPRINTFN(1, "frame too short\n"); goto tr_setup; @@ -1305,7 +1307,7 @@ cdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) goto tr_stall; } temp = UGETW(sc->sc_ncm.hdr.wDptIndex); - if ((temp + sizeof(sc->sc_ncm.dpt)) > actlen) { + if ((int)(temp + sizeof(sc->sc_ncm.dpt)) > actlen) { DPRINTFN(1, "invalid DPT index: 0x%04x\n", temp); goto tr_stall; } @@ -1354,7 +1356,7 @@ cdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) temp = UGETW(sc->sc_ncm.dp[x].wFrameLength); if ((offset == 0) || - (temp < sizeof(struct ether_header)) || + (temp < (int)sizeof(struct ether_header)) || (temp > (MCLBYTES - ETHER_ALIGN))) { DPRINTFN(1, "NULL frame detected at %d\n", x); m = NULL; @@ -1366,7 +1368,7 @@ cdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) m = NULL; /* silently ignore this frame */ continue; - } else if (temp > (MHLEN - ETHER_ALIGN)) { + } else if (temp > (int)(MHLEN - ETHER_ALIGN)) { m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); } else { m = m_gethdr(M_DONTWAIT, MT_DATA); diff --git a/sys/dev/usb/net/if_cue.c b/sys/dev/usb/net/if_cue.c index 7466ba9..30c5247a 100644 --- a/sys/dev/usb/net/if_cue.c +++ b/sys/dev/usb/net/if_cue.c @@ -457,7 +457,7 @@ cue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen <= (2 + sizeof(struct ether_header))) { + if (actlen <= (int)(2 + sizeof(struct ether_header))) { ifp->if_ierrors++; goto tr_setup; } diff --git a/sys/dev/usb/net/if_ipheth.c b/sys/dev/usb/net/if_ipheth.c index ad4b6f1..21db100 100644 --- a/sys/dev/usb/net/if_ipheth.c +++ b/sys/dev/usb/net/if_ipheth.c @@ -471,7 +471,7 @@ ipheth_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) sc->sc_rx_buf[x] = NULL; len = usbd_xfer_frame_len(xfer, x); - if (len < (sizeof(struct ether_header) + + if (len < (int)(sizeof(struct ether_header) + IPHETH_RX_ADJ)) { m_freem(m); continue; diff --git a/sys/dev/usb/net/if_kue.c b/sys/dev/usb/net/if_kue.c index 2d3fc42..791c73a 100644 --- a/sys/dev/usb/net/if_kue.c +++ b/sys/dev/usb/net/if_kue.c @@ -545,7 +545,7 @@ kue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen <= (2 + sizeof(struct ether_header))) { + if (actlen <= (int)(2 + sizeof(struct ether_header))) { ifp->if_ierrors++; goto tr_setup; } diff --git a/sys/dev/usb/net/if_rue.c b/sys/dev/usb/net/if_rue.c index a870676..894e368 100644 --- a/sys/dev/usb/net/if_rue.c +++ b/sys/dev/usb/net/if_rue.c @@ -638,7 +638,7 @@ rue_intr_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: if (ifp && (ifp->if_drv_flags & IFF_DRV_RUNNING) && - actlen >= sizeof(pkt)) { + actlen >= (int)sizeof(pkt)) { pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, &pkt, sizeof(pkt)); diff --git a/sys/dev/usb/net/if_udav.c b/sys/dev/usb/net/if_udav.c index 8160a3b..2507846 100644 --- a/sys/dev/usb/net/if_udav.c +++ b/sys/dev/usb/net/if_udav.c @@ -642,7 +642,7 @@ udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen < sizeof(stat) + ETHER_CRC_LEN) { + if (actlen < (int)(sizeof(stat) + ETHER_CRC_LEN)) { ifp->if_ierrors++; goto tr_setup; } diff --git a/sys/dev/usb/net/if_usie.c b/sys/dev/usb/net/if_usie.c index ed9054f..813a781 100644 --- a/sys/dev/usb/net/if_usie.c +++ b/sys/dev/usb/net/if_usie.c @@ -918,7 +918,7 @@ tr_setup: if (m == NULL) break; - if (m->m_pkthdr.len > (MCLBYTES - ETHER_HDR_LEN + + if (m->m_pkthdr.len > (int)(MCLBYTES - ETHER_HDR_LEN + ETHER_CRC_LEN - sizeof(sc->sc_txd))) { DPRINTF("packet len is too big: %d\n", m->m_pkthdr.len); diff --git a/sys/dev/usb/net/ruephy.c b/sys/dev/usb/net/ruephy.c index 839c022..bb9931e 100644 --- a/sys/dev/usb/net/ruephy.c +++ b/sys/dev/usb/net/ruephy.c @@ -67,9 +67,9 @@ static device_method_t ruephy_methods[] = { static devclass_t ruephy_devclass; static driver_t ruephy_driver = { - "ruephy", - ruephy_methods, - sizeof(struct mii_softc) + .name = "ruephy", + .methods = ruephy_methods, + .size = sizeof(struct mii_softc) }; DRIVER_MODULE(ruephy, miibus, ruephy_driver, ruephy_devclass, 0, 0); diff --git a/sys/dev/usb/net/uhso.c b/sys/dev/usb/net/uhso.c index 8211170..e741719 100644 --- a/sys/dev/usb/net/uhso.c +++ b/sys/dev/usb/net/uhso.c @@ -482,9 +482,9 @@ static device_method_t uhso_methods[] = { }; static driver_t uhso_driver = { - "uhso", - uhso_methods, - sizeof(struct uhso_softc) + .name = "uhso", + .methods = uhso_methods, + .size = sizeof(struct uhso_softc) }; static devclass_t uhso_devclass; @@ -1366,7 +1366,7 @@ uhso_bs_intr_callback(struct usb_xfer *xfer, usb_error_t error) UHSO_DPRINTF(0, "UCDC notification too short: %d\n", actlen); goto tr_setup; } - else if (actlen > sizeof(struct usb_cdc_notification)) { + else if (actlen > (int)sizeof(struct usb_cdc_notification)) { UHSO_DPRINTF(0, "UCDC notification too large: %d\n", actlen); actlen = sizeof(struct usb_cdc_notification); } diff --git a/sys/dev/usb/serial/ubsa.c b/sys/dev/usb/serial/ubsa.c index c29d75d..da96052 100644 --- a/sys/dev/usb/serial/ubsa.c +++ b/sys/dev/usb/serial/ubsa.c @@ -627,7 +627,7 @@ ubsa_intr_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen >= sizeof(buf)) { + if (actlen >= (int)sizeof(buf)) { pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, buf, sizeof(buf)); diff --git a/sys/dev/usb/serial/uchcom.c b/sys/dev/usb/serial/uchcom.c index 2b12029..b592497 100644 --- a/sys/dev/usb/serial/uchcom.c +++ b/sys/dev/usb/serial/uchcom.c @@ -846,9 +846,9 @@ static device_method_t uchcom_methods[] = { }; static driver_t uchcom_driver = { - "ucom", - uchcom_methods, - sizeof(struct uchcom_softc) + .name = "ucom", + .methods = uchcom_methods, + .size = sizeof(struct uchcom_softc) }; static devclass_t uchcom_devclass; diff --git a/sys/dev/usb/serial/ucycom.c b/sys/dev/usb/serial/ucycom.c index 4a35bf5..2607872 100644 --- a/sys/dev/usb/serial/ucycom.c +++ b/sys/dev/usb/serial/ucycom.c @@ -519,7 +519,7 @@ ucycom_intr_read_callback(struct usb_xfer *xfer, usb_error_t error) struct usb_page_cache *pc; uint8_t buf[2]; uint32_t offset; - uint32_t len; + int len; int actlen; usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); diff --git a/sys/dev/usb/serial/ufoma.c b/sys/dev/usb/serial/ufoma.c index 7233f90..2f5e756 100644 --- a/sys/dev/usb/serial/ufoma.c +++ b/sys/dev/usb/serial/ufoma.c @@ -684,7 +684,7 @@ ufoma_intr_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTF("too short message\n"); goto tr_setup; } - if (actlen > sizeof(pkt)) { + if (actlen > (int)sizeof(pkt)) { DPRINTF("truncating message\n"); actlen = sizeof(pkt); } diff --git a/sys/dev/usb/serial/ulpt.c b/sys/dev/usb/serial/ulpt.c index 063e297..1bb7385 100644 --- a/sys/dev/usb/serial/ulpt.c +++ b/sys/dev/usb/serial/ulpt.c @@ -543,7 +543,7 @@ ulpt_attach(device_t dev) /* search through all the descriptors looking for bidir mode */ id = usbd_get_interface_descriptor(uaa->iface); - alt_index = 0 - 1; + alt_index = 0xFF; while (1) { if (id == NULL) { break; @@ -631,14 +631,14 @@ found: error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &ulpt_fifo_methods, &sc->sc_fifo, - unit, 0 - 1, uaa->info.bIfaceIndex, + unit, -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; } error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &unlpt_fifo_methods, &sc->sc_fifo_noreset, - unit, 0 - 1, uaa->info.bIfaceIndex, + unit, -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; diff --git a/sys/dev/usb/serial/umodem.c b/sys/dev/usb/serial/umodem.c index 9289eec..2da5c05 100644 --- a/sys/dev/usb/serial/umodem.c +++ b/sys/dev/usb/serial/umodem.c @@ -317,7 +317,7 @@ umodem_attach(device_t dev) cud = usbd_find_descriptor(uaa->device, NULL, uaa->info.bIfaceIndex, UDESC_CS_INTERFACE, - 0 - 1, UDESCSUB_CDC_UNION, 0 - 1); + 0xFF, UDESCSUB_CDC_UNION, 0xFF); if ((cud == NULL) || (cud->bLength < sizeof(*cud))) { DPRINTF("Missing descriptor. " @@ -702,7 +702,7 @@ umodem_intr_callback(struct usb_xfer *xfer, usb_error_t error) "%d bytes\n", actlen); goto tr_setup; } - if (actlen > sizeof(pkt)) { + if (actlen > (int)sizeof(pkt)) { DPRINTF("truncating message\n"); actlen = sizeof(pkt); } @@ -842,7 +842,7 @@ static void * umodem_get_desc(struct usb_attach_arg *uaa, uint8_t type, uint8_t subtype) { return (usbd_find_descriptor(uaa->device, NULL, uaa->info.bIfaceIndex, - type, 0 - 1, subtype, 0 - 1)); + type, 0xFF, subtype, 0xFF)); } static usb_error_t diff --git a/sys/dev/usb/serial/uplcom.c b/sys/dev/usb/serial/uplcom.c index f868a53..37a91ae 100644 --- a/sys/dev/usb/serial/uplcom.c +++ b/sys/dev/usb/serial/uplcom.c @@ -606,7 +606,7 @@ uplcom_cfg_set_break(struct ucom_softc *ucom, uint8_t onoff) &req, NULL, 0, 1000); } -static const int32_t uplcom_rates[] = { +static const uint32_t uplcom_rates[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 14400, 19200, 28800, 38400, 57600, 115200, /* diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c index 08ce2ca..a2c1f97 100644 --- a/sys/dev/usb/serial/usb_serial.c +++ b/sys/dev/usb/serial/usb_serial.c @@ -236,14 +236,14 @@ ucom_unit_free(int unit) */ int ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc, - uint32_t subunits, void *parent, + int subunits, void *parent, const struct ucom_callback *callback, struct mtx *mtx) { - uint32_t subunit; + int subunit; int error = 0; if ((sc == NULL) || - (subunits == 0) || + (subunits <= 0) || (callback == NULL)) { return (EINVAL); } @@ -293,7 +293,7 @@ ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc, void ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc) { - uint32_t subunit; + int subunit; if (ssc->sc_subunits == 0) return; /* not initialized */ @@ -1089,11 +1089,6 @@ ucom_param(struct tty *tp, struct termios *t) DPRINTF("sc = %p\n", sc); /* Check requested parameters. */ - if (t->c_ospeed < 0) { - DPRINTF("negative ospeed\n"); - error = EINVAL; - goto done; - } if (t->c_ispeed && (t->c_ispeed != t->c_ospeed)) { DPRINTF("mismatch ispeed and ospeed\n"); error = EINVAL; diff --git a/sys/dev/usb/serial/usb_serial.h b/sys/dev/usb/serial/usb_serial.h index ffd2859..8809264 100644 --- a/sys/dev/usb/serial/usb_serial.h +++ b/sys/dev/usb/serial/usb_serial.h @@ -166,7 +166,7 @@ struct ucom_softc { struct tty *sc_tty; struct mtx *sc_mtx; void *sc_parent; - uint32_t sc_subunit; + int sc_subunit; uint16_t sc_portno; uint16_t sc_flag; #define UCOM_FLAG_RTS_IFLOW 0x01 /* use RTS input flow control */ @@ -194,7 +194,7 @@ struct ucom_softc { usbd_do_request_proc(udev,&(com)->sc_super->sc_tq,req,ptr,flags,NULL,timo) int ucom_attach(struct ucom_super_softc *, - struct ucom_softc *, uint32_t, void *, + struct ucom_softc *, int, void *, const struct ucom_callback *callback, struct mtx *); void ucom_detach(struct ucom_super_softc *, struct ucom_softc *); void ucom_set_pnpinfo_usb(struct ucom_super_softc *, device_t); diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index a2248ea..596a5ef 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -1452,7 +1452,7 @@ umass_t_bbb_status_callback(struct usb_xfer *xfer, usb_error_t error) /* Zero missing parts of the CSW: */ - if (actlen < sizeof(sc->csw)) + if (actlen < (int)sizeof(sc->csw)) memset(&sc->csw, 0, sizeof(sc->csw)); pc = usbd_xfer_get_frame(xfer, 0); @@ -1961,7 +1961,7 @@ umass_t_cbi_status_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (actlen < sizeof(sc->sbl)) { + if (actlen < (int)sizeof(sc->sbl)) { goto tr_setup; } pc = usbd_xfer_get_frame(xfer, 0); diff --git a/sys/dev/usb/storage/urio.c b/sys/dev/usb/storage/urio.c index e79ae87..39fcbe9 100644 --- a/sys/dev/usb/storage/urio.c +++ b/sys/dev/usb/storage/urio.c @@ -246,7 +246,7 @@ urio_attach(device_t dev) error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, &urio_fifo_methods, &sc->sc_fifo, - device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex, + device_get_unit(dev), -1, uaa->info.bIfaceIndex, UID_ROOT, GID_OPERATOR, 0644); if (error) { goto detach; diff --git a/sys/dev/usb/storage/ustorage_fs.c b/sys/dev/usb/storage/ustorage_fs.c index dd6b413..c874999 100644 --- a/sys/dev/usb/storage/ustorage_fs.c +++ b/sys/dev/usb/storage/ustorage_fs.c @@ -967,7 +967,7 @@ ustorage_fs_verify(struct ustorage_fs_softc *sc) } /* XXX TODO: verify that data is readable */ done: - return (ustorage_fs_min_len(sc, 0, 0 - 1)); + return (ustorage_fs_min_len(sc, 0, -1U)); } /*------------------------------------------------------------------------* @@ -989,7 +989,7 @@ ustorage_fs_inquiry(struct ustorage_fs_softc *sc) memset(buf, 0, 36); buf[0] = 0x7f; /* Unsupported, no device - type */ - return (ustorage_fs_min_len(sc, 36, 0 - 1)); + return (ustorage_fs_min_len(sc, 36, -1U)); } memset(buf, 0, 8); /* Non - removable, direct - access device */ @@ -1008,7 +1008,7 @@ ustorage_fs_inquiry(struct ustorage_fs_softc *sc) #if (USTORAGE_QDATA_MAX < 36) #error "(USTORAGE_QDATA_MAX < 36)" #endif - return (ustorage_fs_min_len(sc, 36, 0 - 1)); + return (ustorage_fs_min_len(sc, 36, -1U)); } /*------------------------------------------------------------------------* @@ -1077,7 +1077,7 @@ ustorage_fs_request_sense(struct ustorage_fs_softc *sc) #if (USTORAGE_QDATA_MAX < 18) #error "(USTORAGE_QDATA_MAX < 18)" #endif - return (ustorage_fs_min_len(sc, 18, 0 - 1)); + return (ustorage_fs_min_len(sc, 18, -1U)); } /*------------------------------------------------------------------------* @@ -1108,7 +1108,7 @@ ustorage_fs_read_capacity(struct ustorage_fs_softc *sc) #if (USTORAGE_QDATA_MAX < 8) #error "(USTORAGE_QDATA_MAX < 8)" #endif - return (ustorage_fs_min_len(sc, 8, 0 - 1)); + return (ustorage_fs_min_len(sc, 8, -1U)); } /*------------------------------------------------------------------------* @@ -1215,7 +1215,7 @@ ustorage_fs_mode_sense(struct ustorage_fs_softc *sc) #if (USTORAGE_QDATA_MAX < 24) #error "(USTORAGE_QDATA_MAX < 24)" #endif - return (ustorage_fs_min_len(sc, len, 0 - 1)); + return (ustorage_fs_min_len(sc, len, -1U)); } /*------------------------------------------------------------------------* @@ -1305,7 +1305,7 @@ ustorage_fs_read_format_capacities(struct ustorage_fs_softc *sc) #if (USTORAGE_QDATA_MAX < 12) #error "(USTORAGE_QDATA_MAX < 12)" #endif - return (ustorage_fs_min_len(sc, 12, 0 - 1)); + return (ustorage_fs_min_len(sc, 12, -1U)); } /*------------------------------------------------------------------------* @@ -1618,7 +1618,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) switch (sc->sc_cmd_data[0]) { case SC_INQUIRY: sc->sc_transfer.cmd_dir = DIR_WRITE; - error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], 0 - 1); + error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], -1U); if (error) { break; } @@ -1633,7 +1633,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) case SC_MODE_SELECT_6: sc->sc_transfer.cmd_dir = DIR_READ; - error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], 0 - 1); + error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], -1U); if (error) { break; } @@ -1649,7 +1649,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) case SC_MODE_SELECT_10: sc->sc_transfer.cmd_dir = DIR_READ; error = ustorage_fs_min_len(sc, - get_be16(&sc->sc_cmd_data[7]), 0 - 1); + get_be16(&sc->sc_cmd_data[7]), -1U); if (error) { break; } @@ -1664,7 +1664,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) case SC_MODE_SENSE_6: sc->sc_transfer.cmd_dir = DIR_WRITE; - error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], 0 - 1); + error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], -1U); if (error) { break; } @@ -1680,7 +1680,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) case SC_MODE_SENSE_10: sc->sc_transfer.cmd_dir = DIR_WRITE; error = ustorage_fs_min_len(sc, - get_be16(&sc->sc_cmd_data[7]), 0 - 1); + get_be16(&sc->sc_cmd_data[7]), -1U); if (error) { break; } @@ -1694,7 +1694,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) break; case SC_PREVENT_ALLOW_MEDIUM_REMOVAL: - error = ustorage_fs_min_len(sc, 0, 0 - 1); + error = ustorage_fs_min_len(sc, 0, -1U); if (error) { break; } @@ -1776,7 +1776,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) case SC_READ_FORMAT_CAPACITIES: sc->sc_transfer.cmd_dir = DIR_WRITE; error = ustorage_fs_min_len(sc, - get_be16(&sc->sc_cmd_data[7]), 0 - 1); + get_be16(&sc->sc_cmd_data[7]), -1U); if (error) { break; } @@ -1791,7 +1791,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) case SC_REQUEST_SENSE: sc->sc_transfer.cmd_dir = DIR_WRITE; - error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], 0 - 1); + error = ustorage_fs_min_len(sc, sc->sc_cmd_data[4], -1U); if (error) { break; } @@ -1805,7 +1805,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) break; case SC_START_STOP_UNIT: - error = ustorage_fs_min_len(sc, 0, 0 - 1); + error = ustorage_fs_min_len(sc, 0, -1U); if (error) { break; } @@ -1819,7 +1819,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) break; case SC_SYNCHRONIZE_CACHE: - error = ustorage_fs_min_len(sc, 0, 0 - 1); + error = ustorage_fs_min_len(sc, 0, -1U); if (error) { break; } @@ -1833,7 +1833,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) break; case SC_TEST_UNIT_READY: - error = ustorage_fs_min_len(sc, 0, 0 - 1); + error = ustorage_fs_min_len(sc, 0, -1U); if (error) { break; } @@ -1846,7 +1846,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) * We support a minimal version: BytChk must be 0. */ case SC_VERIFY: - error = ustorage_fs_min_len(sc, 0, 0 - 1); + error = ustorage_fs_min_len(sc, 0, -1U); if (error) { break; } @@ -1928,7 +1928,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_softc *sc) /* Fallthrough */ default: - error = ustorage_fs_min_len(sc, 0, 0 - 1); + error = ustorage_fs_min_len(sc, 0, -1U); if (error) { break; } diff --git a/sys/dev/usb/template/usb_template.c b/sys/dev/usb/template/usb_template.c index b929665..9934202 100644 --- a/sys/dev/usb/template/usb_template.c +++ b/sys/dev/usb/template/usb_template.c @@ -374,7 +374,7 @@ usb_make_config_desc(struct usb_temp_setup *temp, /* Reset some counters */ - temp->bInterfaceNumber = 0 - 1; + temp->bInterfaceNumber = 0xFF; temp->bAlternateSetting = 0; /* Scan all the USB interfaces */ diff --git a/sys/dev/usb/usb_busdma.c b/sys/dev/usb/usb_busdma.c index d31aeec..59dc8c1 100644 --- a/sys/dev/usb/usb_busdma.c +++ b/sys/dev/usb/usb_busdma.c @@ -108,7 +108,7 @@ usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset, res->length = USB_PAGE_SIZE - offset; res->physaddr = page->physaddr + offset; } else { - res->length = 0 - 1; + res->length = (usb_size_t)-1; res->physaddr = page->physaddr + offset; } if (!pc->buffer) { @@ -123,7 +123,7 @@ usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset, /* Case 2 - Plain PIO */ res->buffer = USB_ADD_BYTES(pc->buffer, offset); - res->length = 0 - 1; + res->length = (usb_size_t)-1; #if USB_HAVE_BUSDMA res->physaddr = 0; #endif diff --git a/sys/dev/usb/usb_compat_linux.c b/sys/dev/usb/usb_compat_linux.c index 2f78d9f..22bf1f4 100644 --- a/sys/dev/usb/usb_compat_linux.c +++ b/sys/dev/usb/usb_compat_linux.c @@ -880,7 +880,7 @@ usb_linux_create_usb_device(struct usb_device *udev, device_t dev) */ for (pass = 0; pass < 2; pass++) { - iface_no_curr = 0 - 1; + iface_no_curr = 0xFFFF; niface_total = 0; iface_index = 0; nedesc = 0; diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index 2b99036..a136dcd 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -1653,7 +1653,7 @@ usb_fifo_check_methods(struct usb_fifo_methods *pm) int usb_fifo_attach(struct usb_device *udev, void *priv_sc, struct mtx *priv_mtx, struct usb_fifo_methods *pm, - struct usb_fifo_sc *f_sc, uint16_t unit, uint16_t subunit, + struct usb_fifo_sc *f_sc, uint16_t unit, int16_t subunit, uint8_t iface_index, uid_t uid, gid_t gid, int mode) { struct usb_fifo *f_tx; @@ -1730,7 +1730,7 @@ usb_fifo_attach(struct usb_device *udev, void *priv_sc, if (pm->basename[n] == NULL) { continue; } - if (subunit == 0xFFFF) { + if (subunit < 0) { if (snprintf(devname, sizeof(devname), "%s%u%s", pm->basename[n], unit, pm->postfix[n] ? @@ -1739,7 +1739,7 @@ usb_fifo_attach(struct usb_device *udev, void *priv_sc, } } else { if (snprintf(devname, sizeof(devname), - "%s%u.%u%s", pm->basename[n], + "%s%u.%d%s", pm->basename[n], unit, subunit, pm->postfix[n] ? pm->postfix[n] : "")) { /* ignore */ diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index 726d7a7..1a7c1b6 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -1496,7 +1496,6 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *bus, struct usb_device *adev; struct usb_device *hub; uint8_t *scratch_ptr; - size_t scratch_size; usb_error_t err; uint8_t device_index; uint8_t config_index; @@ -1721,7 +1720,6 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *bus, * simply disable all USB strings. */ scratch_ptr = udev->bus->scratch[0].data; - scratch_size = sizeof(udev->bus->scratch[0].data); if (udev->ddesc.iManufacturer || udev->ddesc.iProduct || diff --git a/sys/dev/usb/usb_handle_request.c b/sys/dev/usb/usb_handle_request.c index 2d8d107..f5b226e 100644 --- a/sys/dev/usb/usb_handle_request.c +++ b/sys/dev/usb/usb_handle_request.c @@ -466,7 +466,6 @@ usb_handle_request(struct usb_xfer *xfer) uint16_t rem; /* data remainder */ uint16_t max_len; /* max fragment length */ uint16_t wValue; - uint16_t wIndex; uint8_t state; uint8_t is_complete = 1; usb_error_t err; @@ -532,11 +531,10 @@ usb_handle_request(struct usb_xfer *xfer) /* get some request fields decoded */ wValue = UGETW(req.wValue); - wIndex = UGETW(req.wIndex); DPRINTF("req 0x%02x 0x%02x 0x%04x 0x%04x " "off=0x%x rem=0x%x, state=%d\n", req.bmRequestType, - req.bRequest, wValue, wIndex, off, rem, state); + req.bRequest, wValue, UGETW(req.wIndex), off, rem, state); /* demultiplex the control request */ diff --git a/sys/dev/usb/usb_hid.c b/sys/dev/usb/usb_hid.c index 6bd51cd..165919b 100644 --- a/sys/dev/usb/usb_hid.c +++ b/sys/dev/usb/usb_hid.c @@ -612,7 +612,7 @@ hid_report_size(const void *buf, usb_size_t len, enum hid_kind k, uint8_t *id) * hid_locate *------------------------------------------------------------------------*/ int -hid_locate(const void *desc, usb_size_t size, uint32_t u, enum hid_kind k, +hid_locate(const void *desc, usb_size_t size, int32_t u, enum hid_kind k, uint8_t index, struct hid_location *loc, uint32_t *flags, uint8_t *id) { struct hid_data *d; @@ -742,7 +742,7 @@ hid_put_data_unsigned(uint8_t *buf, usb_size_t len, * hid_is_collection *------------------------------------------------------------------------*/ int -hid_is_collection(const void *desc, usb_size_t size, uint32_t usage) +hid_is_collection(const void *desc, usb_size_t size, int32_t usage) { struct hid_data *hd; struct hid_item hi; diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index fe40100..bc9d98c 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -1431,7 +1431,7 @@ static uint8_t usb_intr_find_best_slot(usb_size_t *ptr, uint8_t start, uint8_t end, uint8_t mask) { - usb_size_t min = 0 - 1; + usb_size_t min = (usb_size_t)-1; usb_size_t sum; uint8_t x; uint8_t y; @@ -2149,7 +2149,7 @@ usb_bus_powerd(struct usb_bus *bus) /* reset counters */ - mintime = 0 - 1; + mintime = (usb_ticks_t)-1; type_refs[0] = 0; type_refs[1] = 0; type_refs[2] = 0; @@ -2186,7 +2186,7 @@ usb_bus_powerd(struct usb_bus *bus) } } - if (mintime >= (1 * hz)) { + if (mintime >= (usb_ticks_t)(1 * hz)) { /* recompute power masks */ DPRINTF("Recomputing power masks\n"); bus->hw_power_state = 0; diff --git a/sys/dev/usb/usb_msctest.c b/sys/dev/usb/usb_msctest.c index a6b01b8..9952264 100644 --- a/sys/dev/usb/usb_msctest.c +++ b/sys/dev/usb/usb_msctest.c @@ -418,7 +418,8 @@ static void bbb_status_callback(struct usb_xfer *xfer, usb_error_t error) { struct bbb_transfer *sc = usbd_xfer_softc(xfer); - int actlen, sumlen; + int actlen; + int sumlen; usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL); @@ -427,7 +428,7 @@ bbb_status_callback(struct usb_xfer *xfer, usb_error_t error) /* very simple status check */ - if (actlen < sizeof(sc->csw)) { + if (actlen < (int)sizeof(sc->csw)) { bbb_done(sc, USB_ERR_SHORT_XFER); } else if (sc->csw.bCSWStatus == CSWSTATUS_GOOD) { bbb_done(sc, 0); /* success */ diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c index 3faebd3..f601154 100644 --- a/sys/dev/usb/usb_request.c +++ b/sys/dev/usb/usb_request.c @@ -1312,7 +1312,7 @@ usbd_req_get_config_desc(struct usb_device *udev, struct mtx *mtx, goto done; } /* Extra sanity checking */ - if (UGETW(d->wTotalLength) < sizeof(*d)) { + if (UGETW(d->wTotalLength) < (uint16_t)sizeof(*d)) { err = USB_ERR_INVAL; } done: diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index e948299..3e5398c 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -2700,7 +2700,8 @@ usbd_callback_wrapper_sub(struct usb_xfer *xfer) (bus->methods->start_dma_delay) (xfer); } else { usbd_transfer_timeout_ms(xfer, - (void *)&usb_dma_delay_done_cb, temp); + (void (*)(void *))&usb_dma_delay_done_cb, + temp); } USB_BUS_UNLOCK(bus); return (1); /* wait for new callback */ diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index 6446720e..653f395 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -567,7 +567,7 @@ void usbd_start_re_enumerate(struct usb_device *udev); int usb_fifo_attach(struct usb_device *udev, void *priv_sc, struct mtx *priv_mtx, struct usb_fifo_methods *pm, - struct usb_fifo_sc *f_sc, uint16_t unit, uint16_t subunit, + struct usb_fifo_sc *f_sc, uint16_t unit, int16_t subunit, uint8_t iface_index, uid_t uid, gid_t gid, int mode); void usb_fifo_detach(struct usb_fifo_sc *f_sc); int usb_fifo_alloc_buffer(struct usb_fifo *f, uint32_t bufsize, diff --git a/sys/dev/usb/usbhid.h b/sys/dev/usb/usbhid.h index 4816e87..f40232a 100644 --- a/sys/dev/usb/usbhid.h +++ b/sys/dev/usb/usbhid.h @@ -226,7 +226,7 @@ void hid_end_parse(struct hid_data *s); int hid_get_item(struct hid_data *s, struct hid_item *h); int hid_report_size(const void *buf, usb_size_t len, enum hid_kind k, uint8_t *id); -int hid_locate(const void *desc, usb_size_t size, uint32_t usage, +int hid_locate(const void *desc, usb_size_t size, int32_t usage, enum hid_kind kind, uint8_t index, struct hid_location *loc, uint32_t *flags, uint8_t *id); int32_t hid_get_data(const uint8_t *buf, usb_size_t len, @@ -235,7 +235,7 @@ uint32_t hid_get_data_unsigned(const uint8_t *buf, usb_size_t len, struct hid_location *loc); void hid_put_data_unsigned(uint8_t *buf, usb_size_t len, struct hid_location *loc, unsigned int value); -int hid_is_collection(const void *desc, usb_size_t size, uint32_t usage); +int hid_is_collection(const void *desc, usb_size_t size, int32_t usage); struct usb_hid_descriptor *hid_get_descriptor_from_usb( struct usb_config_descriptor *cd, struct usb_interface_descriptor *id); diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c index a809819..edd85cc 100644 --- a/sys/dev/usb/wlan/if_rum.c +++ b/sys/dev/usb/wlan/if_rum.c @@ -85,6 +85,8 @@ SYSCTL_INT(_hw_usb_rum, OID_AUTO, debug, CTLFLAG_RW, &rum_debug, 0, "Debug level"); #endif +#define N(a) ((int)(sizeof (a) / sizeof ((a)[0]))) + static const STRUCT_USB_HOST_ID rum_devs[] = { #define RUM_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } RUM_DEV(ABOCOM, HWU54DM), @@ -789,7 +791,7 @@ tr_setup: STAILQ_REMOVE_HEAD(&sc->tx_q, next); m = data->m; - if (m->m_pkthdr.len > (MCLBYTES + RT2573_TX_DESC_SIZE)) { + if (m->m_pkthdr.len > (int)(MCLBYTES + RT2573_TX_DESC_SIZE)) { DPRINTFN(0, "data overflow, %u bytes\n", m->m_pkthdr.len); m->m_pkthdr.len = (MCLBYTES + RT2573_TX_DESC_SIZE); @@ -875,7 +877,7 @@ rum_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(15, "rx done, actlen=%d\n", len); - if (len < RT2573_RX_DESC_SIZE + IEEE80211_MIN_LEN) { + if (len < (int)(RT2573_RX_DESC_SIZE + IEEE80211_MIN_LEN)) { DPRINTF("%s: xfer too short %d\n", device_get_nameunit(sc->sc_dev), len); ifp->if_ierrors++; @@ -1407,7 +1409,7 @@ rum_write_multi(struct rum_softc *sc, uint16_t reg, void *buf, size_t len) { struct usb_device_request req; usb_error_t error; - int offset; + size_t offset; req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = RT2573_WRITE_MULTI_MAC; @@ -1934,7 +1936,6 @@ rum_read_eeprom(struct rum_softc *sc) static int rum_bbp_init(struct rum_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) int i, ntries; /* wait for BBP to be ready */ @@ -1962,13 +1963,11 @@ rum_bbp_init(struct rum_softc *sc) } return 0; -#undef N } static void rum_init_locked(struct rum_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; uint32_t tmp; diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index 44bb12b..ddb7395 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -74,7 +74,7 @@ __FBSDID("$FreeBSD$"); #include <dev/usb/wlan/if_runreg.h> #include <dev/usb/wlan/if_runvar.h> -#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) +#define N(_a) ((int)(sizeof((_a)) / sizeof((_a)[0]))) #ifdef USB_DEBUG #define RUN_DEBUG @@ -658,7 +658,7 @@ run_attach(device_t self) sc->rf_rev == RT2860_RF_2850 || sc->rf_rev == RT3070_RF_3052) { /* set supported .11a rates */ - for (i = 14; i < nitems(rt2860_rf2850); i++) { + for (i = 14; i < N(rt2860_rf2850); i++) { uint8_t chan = rt2860_rf2850[i].chan; ic->ic_channels[ic->ic_nchans].ic_freq = ieee80211_ieee2mhz(chan, IEEE80211_CHAN_A); @@ -2574,8 +2574,8 @@ run_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(15, "rx done, actlen=%d\n", xferlen); - if (xferlen < sizeof (uint32_t) + - sizeof (struct rt2860_rxwi) + sizeof (struct rt2870_rxd)) { + if (xferlen < (int)(sizeof(uint32_t) + + sizeof(struct rt2860_rxwi) + sizeof(struct rt2870_rxd))) { DPRINTF("xfer too short %d\n", xferlen); goto tr_setup; } @@ -2640,11 +2640,12 @@ tr_setup: for(;;) { dmalen = le32toh(*mtod(m, uint32_t *)) & 0xffff; - if ((dmalen == 0) || ((dmalen & 3) != 0)) { + if ((dmalen >= (uint32_t)-8) || (dmalen == 0) || + ((dmalen & 3) != 0)) { DPRINTF("bad DMA length %u\n", dmalen); break; } - if ((dmalen + 8) > xferlen) { + if ((dmalen + 8) > (uint32_t)xferlen) { DPRINTF("bad DMA length %u > %d\n", dmalen + 8, xferlen); break; @@ -4306,7 +4307,7 @@ run_bbp_init(struct run_softc *sc) return (ETIMEDOUT); /* initialize BBP registers to default values */ - for (i = 0; i < nitems(rt2860_def_bbp); i++) { + for (i = 0; i < N(rt2860_def_bbp); i++) { run_bbp_write(sc, rt2860_def_bbp[i].reg, rt2860_def_bbp[i].val); } @@ -4341,12 +4342,12 @@ run_rt3070_rf_init(struct run_softc *sc) /* initialize RF registers to default value */ if (sc->mac_ver == 0x3572) { - for (i = 0; i < nitems(rt3572_def_rf); i++) { + for (i = 0; i < N(rt3572_def_rf); i++) { run_rt3070_rf_write(sc, rt3572_def_rf[i].reg, rt3572_def_rf[i].val); } } else { - for (i = 0; i < nitems(rt3070_def_rf); i++) { + for (i = 0; i < N(rt3070_def_rf); i++) { run_rt3070_rf_write(sc, rt3070_def_rf[i].reg, rt3070_def_rf[i].val); } @@ -4729,7 +4730,7 @@ run_init_locked(struct run_softc *sc) run_write(sc, RT2860_TX_PWR_CFG(ridx), sc->txpow20mhz[ridx]); } - for (i = 0; i < nitems(rt2870_def_mac); i++) + for (i = 0; i < N(rt2870_def_mac); i++) run_write(sc, rt2870_def_mac[i].reg, rt2870_def_mac[i].val); run_write(sc, RT2860_WMM_AIFSN_CFG, 0x00002273); run_write(sc, RT2860_WMM_CWMIN_CFG, 0x00002344); @@ -4949,9 +4950,9 @@ static device_method_t run_methods[] = { }; static driver_t run_driver = { - "run", - run_methods, - sizeof(struct run_softc) + .name = "run", + .methods = run_methods, + .size = sizeof(struct run_softc) }; static devclass_t run_devclass; diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index cfa8494..4e7ab0e 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -2309,6 +2309,11 @@ uath_cmdeof(struct uath_softc *sc, struct uath_cmd *cmd) /* reply to a read command */ default: dlen = hdr->len - sizeof(*hdr); + if (dlen < 0) { + device_printf(sc->sc_dev, + "Invalid header length %d\n", dlen); + return; + } DPRINTF(sc, UATH_DEBUG_RX_PROC | UATH_DEBUG_RECV_ALL, "%s: code %d data len %u\n", __func__, hdr->code & 0xff, dlen); @@ -2334,7 +2339,7 @@ uath_cmdeof(struct uath_softc *sc, struct uath_cmd *cmd) * number of bytes--unless it's 0 in which * case a single 32-bit word should be present. */ - if (dlen >= sizeof(uint32_t)) { + if (dlen >= (int)sizeof(uint32_t)) { olen = be32toh(rp[0]); dlen -= sizeof(uint32_t); if (olen == 0) { @@ -2346,7 +2351,7 @@ uath_cmdeof(struct uath_softc *sc, struct uath_cmd *cmd) olen = 0; if (cmd->odata != NULL) { /* NB: cmd->olen validated in uath_cmd */ - if (olen > cmd->olen) { + if (olen > (u_int)cmd->olen) { /* XXX complain? */ device_printf(sc->sc_dev, "%s: cmd 0x%x olen %u cmd olen %u\n", @@ -2354,7 +2359,7 @@ uath_cmdeof(struct uath_softc *sc, struct uath_cmd *cmd) cmd->olen); olen = cmd->olen; } - if (olen > dlen) { + if (olen > (u_int)dlen) { /* XXX complain, shouldn't happen */ device_printf(sc->sc_dev, "%s: cmd 0x%x olen %u dlen %u\n", @@ -2376,7 +2381,7 @@ uath_cmdeof(struct uath_softc *sc, struct uath_cmd *cmd) return; } dlen = hdr->len - sizeof(*hdr); - if (dlen != sizeof(uint32_t)) { + if (dlen != (int)sizeof(uint32_t)) { /* XXX something wrong */ return; } @@ -2423,7 +2428,7 @@ uath_intr_rx_callback(struct usb_xfer *xfer, usb_error_t error) STAILQ_INSERT_TAIL(&sc->sc_cmd_inactive, cmd, next); UATH_STAT_INC(sc, st_cmd_inactive); - KASSERT(actlen >= sizeof(struct uath_cmd_hdr), + KASSERT(actlen >= (int)sizeof(struct uath_cmd_hdr), ("short xfer error")); pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, cmd->buf, actlen); @@ -2542,7 +2547,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data, usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); - if (actlen < UATH_MIN_RXBUFSZ) { + if (actlen < (int)UATH_MIN_RXBUFSZ) { DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL, "%s: wrong xfer size (len=%d)\n", __func__, actlen); ifp->if_ierrors++; @@ -2888,9 +2893,9 @@ static device_method_t uath_methods[] = { { 0, 0 } }; static driver_t uath_driver = { - "uath", - uath_methods, - sizeof(struct uath_softc) + .name = "uath", + .methods = uath_methods, + .size = sizeof(struct uath_softc) }; static devclass_t uath_devclass; diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index 678e9c0..d9e9da2 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -1221,7 +1221,7 @@ upgt_eeprom_parse_freq3(struct upgt_softc *sc, uint8_t *data, int len) for (i = 0; i < elements; i++) { channel = ieee80211_mhz2ieee(le16toh(freq3[i].freq), 0); - if (!(channel >= 0 && channel < IEEE80211_CHAN_MAX)) + if (channel >= IEEE80211_CHAN_MAX) continue; sc->sc_eeprom_freq3[channel] = freq3[i]; @@ -1254,7 +1254,7 @@ upgt_eeprom_parse_freq4(struct upgt_softc *sc, uint8_t *data, int len) for (i = 0; i < elements; i++) { channel = ieee80211_mhz2ieee(le16toh(freq4_1[i].freq), 0); - if (!(channel >= 0 && channel < IEEE80211_CHAN_MAX)) + if (channel >= IEEE80211_CHAN_MAX) continue; freq4_2 = (struct upgt_eeprom_freq4_2 *)freq4_1[i].data; @@ -1282,7 +1282,7 @@ upgt_eeprom_parse_freq6(struct upgt_softc *sc, uint8_t *data, int len) for (i = 0; i < elements; i++) { channel = ieee80211_mhz2ieee(le16toh(freq6[i].freq), 0); - if (!(channel >= 0 && channel < IEEE80211_CHAN_MAX)) + if (channel >= IEEE80211_CHAN_MAX) continue; sc->sc_eeprom_freq6[channel] = freq6[i]; @@ -1403,7 +1403,7 @@ upgt_rxeof(struct usb_xfer *xfer, struct upgt_data *data, int *rssi) return (NULL); } - if (actlen < UPGT_RX_MINSZ) + if (actlen < (int)UPGT_RX_MINSZ) return (NULL); /* @@ -1461,7 +1461,7 @@ upgt_rxeof(struct usb_xfer *xfer, struct upgt_data *data, int *rssi) static uint32_t upgt_chksum_le(const uint32_t *buf, size_t size) { - int i; + size_t i; uint32_t crc = 0; for (i = 0; i < size; i += sizeof(uint32_t)) { @@ -1602,7 +1602,10 @@ upgt_fw_load(struct upgt_softc *sc) struct upgt_data *data_cmd; struct upgt_fw_x2_header *x2; char start_fwload_cmd[] = { 0x3c, 0x0d }; - int error = 0, offset, bsize, n; + int error = 0; + size_t offset; + int bsize; + int n; uint32_t crc32; fw = firmware_get(upgt_fwname); @@ -1783,7 +1786,9 @@ upgt_fw_verify(struct upgt_softc *sc) const uint8_t *p; const uint32_t *uc; uint32_t bra_option_type, bra_option_len; - int offset, bra_end = 0, error = 0; + size_t offset; + int bra_end = 0; + int error = 0; fw = firmware_get(upgt_fwname); if (fw == NULL) { @@ -2382,9 +2387,9 @@ static device_method_t upgt_methods[] = { }; static driver_t upgt_driver = { - "upgt", - upgt_methods, - sizeof(struct upgt_softc) + .name = "upgt", + .methods = upgt_methods, + .size = sizeof(struct upgt_softc) }; static devclass_t upgt_devclass; diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c index 945789f..d1cb91e 100644 --- a/sys/dev/usb/wlan/if_ural.c +++ b/sys/dev/usb/wlan/if_ural.c @@ -800,7 +800,7 @@ tr_setup: STAILQ_REMOVE_HEAD(&sc->tx_q, next); m = data->m; - if (m->m_pkthdr.len > (RAL_FRAME_SIZE + RAL_TX_DESC_SIZE)) { + if (m->m_pkthdr.len > (int)(RAL_FRAME_SIZE + RAL_TX_DESC_SIZE)) { DPRINTFN(0, "data overflow, %u bytes\n", m->m_pkthdr.len); m->m_pkthdr.len = (RAL_FRAME_SIZE + RAL_TX_DESC_SIZE); @@ -881,7 +881,7 @@ ural_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(15, "rx done, actlen=%d\n", len); - if (len < RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN) { + if (len < (int)(RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN)) { DPRINTF("%s: xfer too short %d\n", device_get_nameunit(sc->sc_dev), len); ifp->if_ierrors++; @@ -1950,7 +1950,7 @@ ural_read_eeprom(struct ural_softc *sc) static int ural_bbp_init(struct ural_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) +#define N(a) ((int)(sizeof (a) / sizeof ((a)[0]))) int i, ntries; /* wait for BBP to be ready */ @@ -2034,7 +2034,7 @@ ural_set_rxantenna(struct ural_softc *sc, int antenna) static void ural_init_locked(struct ural_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) +#define N(a) ((int)(sizeof (a) / sizeof ((a)[0]))) struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; uint16_t tmp; diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index 1259b2d..b1f5e0d 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -676,8 +676,8 @@ static void urtw_ledtask(void *, int); static void urtw_watchdog(void *); static void urtw_set_multi(void *); static int urtw_isbmode(uint16_t); -static uint16_t urtw_rate2rtl(int); -static uint16_t urtw_rtl2rate(int); +static uint16_t urtw_rate2rtl(uint32_t); +static uint16_t urtw_rtl2rate(uint32_t); static usb_error_t urtw_set_rate(struct urtw_softc *); static usb_error_t urtw_update_msr(struct urtw_softc *); static usb_error_t urtw_read8_c(struct urtw_softc *, int, uint8_t *); @@ -1092,7 +1092,7 @@ urtw_init(void *arg) static usb_error_t urtw_adapter_start_b(struct urtw_softc *sc) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) uint8_t data8; usb_error_t error; @@ -1939,9 +1939,9 @@ fail: } static uint16_t -urtw_rate2rtl(int rate) +urtw_rate2rtl(uint32_t rate) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; for (i = 0; i < N(urtw_ratetable); i++) { @@ -1954,9 +1954,9 @@ urtw_rate2rtl(int rate) } static uint16_t -urtw_rtl2rate(int rate) +urtw_rtl2rate(uint32_t rate) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; for (i = 0; i < N(urtw_ratetable); i++) { @@ -2481,7 +2481,7 @@ fail: static usb_error_t urtw_8225_rf_init(struct urtw_softc *sc) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; uint16_t data; usb_error_t error; @@ -2878,7 +2878,7 @@ fail: static usb_error_t urtw_8225v2_rf_init(struct urtw_softc *sc) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; uint16_t data; uint32_t data32; @@ -3212,7 +3212,7 @@ fail: static usb_error_t urtw_8225v2b_rf_init(struct urtw_softc *sc) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; uint8_t data8; usb_error_t error; @@ -3958,7 +3958,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p, usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); - if (actlen < URTW_MIN_RXBUFSZ) { + if (actlen < (int)URTW_MIN_RXBUFSZ) { ifp->if_ierrors++; return (NULL); } @@ -4434,9 +4434,9 @@ static device_method_t urtw_methods[] = { { 0, 0 } }; static driver_t urtw_driver = { - "urtw", - urtw_methods, - sizeof(struct urtw_softc) + .name = "urtw", + .methods = urtw_methods, + .size = sizeof(struct urtw_softc) }; static devclass_t urtw_devclass; diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c index 7e2cee9..0dac7ad 100644 --- a/sys/dev/usb/wlan/if_zyd.c +++ b/sys/dev/usb/wlan/if_zyd.c @@ -670,17 +670,18 @@ zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error) datalen -= 2; /* XXX: padding? */ STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { - int i, cnt; + int i; + int count; if (rqp->olen != datalen) continue; - cnt = rqp->olen / sizeof(struct zyd_pair); - for (i = 0; i < cnt; i++) { + count = rqp->olen / sizeof(struct zyd_pair); + for (i = 0; i < count; i++) { if (*(((const uint16_t *)rqp->idata) + i) != (((struct zyd_pair *)cmd->data) + i)->reg) break; } - if (i != cnt) + if (i != count) continue; /* copy answer into caller-supplied buffer */ memcpy(rqp->odata, cmd->data, rqp->olen); @@ -779,7 +780,7 @@ zyd_cmd(struct zyd_softc *sc, uint16_t code, const void *idata, int ilen, struct zyd_rq rq; int error; - if (ilen > sizeof(cmd.data)) + if (ilen > (int)sizeof(cmd.data)) return (EINVAL); cmd.code = htole16(code); @@ -929,7 +930,7 @@ fail: static int zyd_rfmd_init(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_RFMD_PHY; static const uint32_t rfini[] = ZYD_RFMD_RF; @@ -988,7 +989,7 @@ fail: static int zyd_al2230_init(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_AL2230_PHY; static const struct zyd_phy_pair phy2230s[] = ZYD_AL2230S_PHY_INIT; @@ -1046,7 +1047,7 @@ fail: static int zyd_al2230_fini(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy[] = ZYD_AL2230_PHY_FINI_PART1; @@ -1066,7 +1067,7 @@ fail: static int zyd_al2230_init_b(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy1[] = ZYD_AL2230_PHY_PART1; static const struct zyd_phy_pair phy2[] = ZYD_AL2230_PHY_PART2; @@ -1149,7 +1150,7 @@ fail: static int zyd_al2230_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy1[] = { @@ -1179,7 +1180,7 @@ fail: static int zyd_al2230_set_channel_b(struct zyd_rf *rf, uint8_t chan) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy1[] = ZYD_AL2230_PHY_PART1; @@ -1214,7 +1215,7 @@ fail: static int zyd_al2230_bandedge6(struct zyd_rf *rf, struct ieee80211_channel *c) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error = 0, i; struct zyd_softc *sc = rf->rf_sc; struct ifnet *ifp = sc->sc_ifp; @@ -1238,7 +1239,7 @@ fail: static int zyd_al7230B_init(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini_1[] = ZYD_AL7230B_PHY_1; static const struct zyd_phy_pair phyini_2[] = ZYD_AL7230B_PHY_2; @@ -1290,7 +1291,7 @@ fail: static int zyd_al7230B_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct { uint32_t r1, r2; @@ -1336,7 +1337,7 @@ fail: static int zyd_al2210_init(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_AL2210_PHY; static const uint32_t rfini[] = ZYD_AL2210_RF; @@ -1409,7 +1410,7 @@ static int zyd_gct_init(struct zyd_rf *rf) { #define ZYD_GCT_INTR_REG 0x85c1 -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_GCT_PHY; static const uint32_t rfini[] = ZYD_GCT_RF; @@ -1431,7 +1432,7 @@ zyd_gct_init(struct zyd_rf *rf) if (error != 0) return (error); - for (i = 0; i < N(vco) - 1; i++) { + for (i = 0; i < (int)(N(vco) - 1); i++) { error = zyd_gct_set_channel_synth(rf, 1, 0); if (error != 0) goto fail; @@ -1465,7 +1466,7 @@ fail: static int zyd_gct_mode(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const uint32_t mode[] = { 0x25f98, 0x25f9a, 0x25f94, 0x27fd4 @@ -1507,7 +1508,6 @@ zyd_gct_write(struct zyd_rf *rf, uint16_t value) static int zyd_gct_switch_radio(struct zyd_rf *rf, int on) { -#define N(a) (sizeof(a) / sizeof((a)[0])) int error; struct zyd_softc *sc = rf->rf_sc; @@ -1525,7 +1525,7 @@ fail: static int zyd_gct_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair cmd[] = { @@ -1579,7 +1579,7 @@ zyd_gct_txgain(struct zyd_rf *rf, uint8_t chan) static int zyd_maxim2_init(struct zyd_rf *rf) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY; static const uint32_t rfini[] = ZYD_MAXIM2_RF; @@ -1616,7 +1616,7 @@ zyd_maxim2_switch_radio(struct zyd_rf *rf, int on) static int zyd_maxim2_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) (sizeof(a) / sizeof((a)[0])) +#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY; static const uint32_t rfini[] = ZYD_MAXIM2_RF; @@ -2185,12 +2185,12 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len) sizeof(struct zyd_rx_stat) - IEEE80211_CRC_LEN; /* allocate a mbuf to store the frame */ - if (rlen > MCLBYTES) { + if (rlen > (int)MCLBYTES) { DPRINTF(sc, ZYD_DEBUG_RECV, "%s: frame too long (length=%d)\n", device_get_nameunit(sc->sc_dev), rlen); ifp->if_ierrors++; return; - } else if (rlen > MHLEN) + } else if (rlen > (int)MHLEN) m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); else m = m_gethdr(M_DONTWAIT, MT_DATA); @@ -2391,7 +2391,7 @@ tr_setup: STAILQ_REMOVE_HEAD(&sc->tx_q, next); m = data->m; - if (m->m_pkthdr.len > ZYD_MAX_TXBUFSZ) { + if (m->m_pkthdr.len > (int)ZYD_MAX_TXBUFSZ) { DPRINTF(sc, ZYD_DEBUG_ANY, "data overflow, %u bytes\n", m->m_pkthdr.len); m->m_pkthdr.len = ZYD_MAX_TXBUFSZ; @@ -2933,9 +2933,9 @@ static device_method_t zyd_methods[] = { }; static driver_t zyd_driver = { - "zyd", - zyd_methods, - sizeof(struct zyd_softc) + .name = "zyd", + .methods = zyd_methods, + .size = sizeof(struct zyd_softc) }; static devclass_t zyd_devclass; |