stm32/st_usbfs_v2: Fixed the use of pointer maths on void pointers in the packet I/O code

This commit is contained in:
dragonmux
2024-01-14 05:41:34 +00:00
committed by Piotr Esden-Tempski
parent d7d6c3742c
commit 547b7c0e72

View File

@@ -69,20 +69,22 @@ void st_usbfs_copy_from_pm(void *buf, const volatile void *vPM, uint16_t len)
uint8_t odd = len & 1;
len >>= 1;
if (((uintptr_t) buf) & 0x01) {
if (((uintptr_t)buf) & 0x01) {
uint8_t *dest = (uint8_t *)buf;
for (; len; PM++, len--) {
uint16_t value = *PM;
*(uint8_t *) buf++ = value;
*(uint8_t *) buf++ = value >> 8;
*(uint8_t *)dest++ = value;
*(uint8_t *)dest++ = value >> 8;
}
} else {
for (; len; PM++, buf += 2, len--) {
*(uint16_t *) buf = *PM;
uint16_t *dest = (uint16_t *)buf;
for (; len; PM++, dest++, len--) {
*dest = *PM;
}
}
if (odd) {
*(uint8_t *) buf = *(uint8_t *) PM;
*(uint8_t *)buf = *(uint8_t *)PM;
}
}