mirror of
https://github.com/cathery/sys-con.git
synced 2024-11-16 14:09:51 +00:00
Use memcpy
This commit is contained in:
parent
03dac32574
commit
54de7050bd
@ -44,10 +44,7 @@ Result SwitchUSBEndpoint::Write(const void *inBuffer, size_t bufferSize)
|
||||
return -1;
|
||||
u32 transferredSize = 0;
|
||||
|
||||
for (size_t byte = 0; byte != bufferSize; ++byte)
|
||||
{
|
||||
static_cast<uint8_t *>(m_buffer)[byte] = static_cast<const uint8_t *>(inBuffer)[byte];
|
||||
}
|
||||
memcpy(m_buffer, inBuffer, bufferSize);
|
||||
|
||||
Result rc = usbHsEpPostBuffer(&m_epSession, m_buffer, bufferSize, &transferredSize);
|
||||
|
||||
@ -69,10 +66,7 @@ Result SwitchUSBEndpoint::Read(void *outBuffer, size_t bufferSize)
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
for (u32 byte = 0; byte != transferredSize; ++byte)
|
||||
{
|
||||
static_cast<uint8_t *>(outBuffer)[byte] = static_cast<uint8_t *>(m_buffer)[byte];
|
||||
}
|
||||
memcpy(outBuffer, m_buffer, transferredSize);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -72,20 +72,13 @@ Result SwitchUSBInterface::ControlTransfer(u8 bmRequestType, u8 bmRequest, u16 w
|
||||
|
||||
u32 transferredSize;
|
||||
|
||||
for (u16 byte = 0; byte != wLength; ++byte)
|
||||
{
|
||||
static_cast<uint8_t *>(temp_buffer)[byte] = static_cast<uint8_t *>(buffer)[byte];
|
||||
}
|
||||
memcpy(temp_buffer, buffer, wLength);
|
||||
|
||||
Result rc = usbHsIfCtrlXfer(&m_session, bmRequestType, bmRequest, wValue, wIndex, wLength, temp_buffer, &transferredSize);
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
memset(buffer, 0, wLength);
|
||||
for (u32 byte = 0; byte != transferredSize; ++byte)
|
||||
{
|
||||
static_cast<uint8_t *>(buffer)[byte] = static_cast<uint8_t *>(temp_buffer)[byte];
|
||||
}
|
||||
memcpy(buffer, temp_buffer, transferredSize);
|
||||
}
|
||||
free(temp_buffer);
|
||||
return rc;
|
||||
@ -99,10 +92,7 @@ Result SwitchUSBInterface::ControlTransfer(u8 bmRequestType, u8 bmRequest, u16 w
|
||||
|
||||
u32 transferredSize;
|
||||
|
||||
for (u16 byte = 0; byte != wLength; ++byte)
|
||||
{
|
||||
static_cast<uint8_t *>(temp_buffer)[byte] = static_cast<const uint8_t *>(buffer)[byte];
|
||||
}
|
||||
memcpy(temp_buffer, buffer, wLength);
|
||||
|
||||
Result rc = usbHsIfCtrlXfer(&m_session, bmRequestType, bmRequest, wValue, wIndex, wLength, temp_buffer, &transferredSize);
|
||||
free(temp_buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user