USIO: Always resize the response vector to the given size

This commit is contained in:
brian218 2023-01-26 21:42:21 +08:00 committed by Megamouse
parent 49455965c0
commit 71c3264ea7

View file

@ -384,7 +384,7 @@ void usb_device_usio::usio_read(u8 channel, u16 reg, u16 size)
case 0x7000: case 0x7000:
{ {
// Card reader check - 2 // Card reader check - 2
response.resize(size); // No data returned
break; break;
} }
case 0x1080: case 0x1080:
@ -444,13 +444,12 @@ void usb_device_usio::usio_read(u8 channel, u16 reg, u16 size)
case 0x1000: case 0x1000:
{ {
//ensure(size == 0x1000); //ensure(size == 0x1000);
response.resize(size); // No data returned
break; break;
} }
default: default:
{ {
usio_log.error("Unhandled read of sram(chip: %d, addr: 0x%04X)", channel - 2, reg); usio_log.error("Unhandled read of sram(chip: %d, addr: 0x%04X)", channel - 2, reg);
response.resize(size);
break; break;
} }
} }
@ -459,7 +458,6 @@ void usb_device_usio::usio_read(u8 channel, u16 reg, u16 size)
default: default:
{ {
usio_log.error("Unhandled read of sram(chip: %d, addr: 0x%04X)", channel - 2, reg); usio_log.error("Unhandled read of sram(chip: %d, addr: 0x%04X)", channel - 2, reg);
response.resize(size);
break; break;
} }
} }
@ -470,6 +468,8 @@ void usb_device_usio::usio_read(u8 channel, u16 reg, u16 size)
// We are not using any firmware since this is emulation. // We are not using any firmware since this is emulation.
usio_log.warning("Unsupported read operation(channel: 0x%02X, addr: 0x%04X)", channel, reg); usio_log.warning("Unsupported read operation(channel: 0x%02X, addr: 0x%04X)", channel, reg);
} }
response.resize(size); // Always resize the response vector to the given size
} }
void usb_device_usio::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, UsbTransfer* transfer) void usb_device_usio::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, UsbTransfer* transfer)