Skip to content

Commit 7018586

Browse files
committed
Fix USB transfers on Windows by using unsigned bitfield types for enums
1 parent 57db3b0 commit 7018586

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

core/usb/device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ typedef struct usb_transfer_info {
5151
uint16_t length, max_pkt_size;
5252
usb_transfer_status_t status : 8;
5353
uint8_t address : 7, : 1, endpoint : 4;
54-
usb_transfer_type_t type : 3;
54+
uint8_t type : 3; /* usb_transfer_type_t */
5555
bool direction : 1;
5656
} usb_transfer_info_t;
5757

@@ -72,7 +72,7 @@ typedef struct usb_event {
7272
usb_progress_handler_t *progress_handler;
7373
void *progress_context, *context;
7474
bool host : 1;
75-
usb_speed_t speed : 2;
75+
uint8_t speed : 2; /* usb_speed_t */
7676
usb_event_type_t type;
7777
union {
7878
usb_init_info_t init;

core/usb/physical.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,18 @@ struct hub {
114114
port_t ports[];
115115
};
116116

117+
enum device_state {
118+
DEVICE_STATE_ATTACHED,
119+
DEVICE_STATE_POWERED,
120+
DEVICE_STATE_DEFAULT_OR_ADDRESS,
121+
DEVICE_STATE_CONFIGURED,
122+
};
123+
117124
struct device {
118125
node_t node;
119126
libusb_device_handle *handle;
120127
endpoint_t endpoints[0x20];
121-
enum device_state {
122-
DEVICE_STATE_ATTACHED,
123-
DEVICE_STATE_POWERED,
124-
DEVICE_STATE_DEFAULT_OR_ADDRESS,
125-
DEVICE_STATE_CONFIGURED,
126-
} state : 2;
128+
uint8_t state : 2; /* enum device_state */
127129
uint8_t address : 7, numPorts : 7;
128130
hub_t hub;
129131
};

0 commit comments

Comments
 (0)