USB: make dev_index u32 for simpler check if it is valid

This commit is contained in:
jackun 2020-12-02 15:38:59 +02:00
parent 17cbb835ce
commit 91d4c4aa37
1 changed files with 4 additions and 8 deletions

View File

@ -54,8 +54,8 @@ typedef struct
struct usb_packet
{
USBEndpoint ep; //usb packet endpoint
int dev_index;
int data_size;
u32 dev_index;
u32 data_size;
} usb_packet;
} USBfreezeData;
@ -461,9 +461,9 @@ s32 USBfreeze(int mode, freezeData* data)
ptr += usbd.device[i].size;
}
int dev_index = usbd.usb_packet.dev_index;
u32 dev_index = usbd.usb_packet.dev_index;
if (usb_device[dev_index])
if (dev_index < countof(usb_device) && usb_device[dev_index])
{
USBPacket* p = &qemu_ohci->usb_packet;
p->actual_length = usbd.usb_packet.data_size;
@ -495,10 +495,6 @@ s32 USBfreeze(int mode, freezeData* data)
}
}
}
else
{
return -1;
}
}
//TODO straight copying of structs can break cross-platform/cross-compiler save states 'cause padding 'n' stuff