lib/memory: Use uintptr_t for pointer comparisons in memmove
diff --git a/common/lib/memory.s2.c b/common/lib/memory.s2.c
index 37ce5b74..a5353b2b 100644
--- a/common/lib/memory.s2.c
+++ b/common/lib/memory.s2.c
@@ -26,11 +26,11 @@ void *memmove(void *dest, const void *src, size_t n) {
uint8_t *pdest = (uint8_t *)dest;
const uint8_t *psrc = (const uint8_t *)src;
- if (src > dest) {
+ if ((uintptr_t)src > (uintptr_t)dest) {
for (size_t i = 0; i < n; i++) {
pdest[i] = psrc[i];
}
- } else if (src < dest) {
+ } else if ((uintptr_t)src < (uintptr_t)dest) {
for (size_t i = n; i > 0; i--) {
pdest[i-1] = psrc[i-1];
}
diff --git a/decompressor/memory.c b/decompressor/memory.c
index 37ce5b74..a5353b2b 100644
--- a/decompressor/memory.c
+++ b/decompressor/memory.c
@@ -26,11 +26,11 @@ void *memmove(void *dest, const void *src, size_t n) {
uint8_t *pdest = (uint8_t *)dest;
const uint8_t *psrc = (const uint8_t *)src;
- if (src > dest) {
+ if ((uintptr_t)src > (uintptr_t)dest) {
for (size_t i = 0; i < n; i++) {
pdest[i] = psrc[i];
}
- } else if (src < dest) {
+ } else if ((uintptr_t)src < (uintptr_t)dest) {
for (size_t i = n; i > 0; i--) {
pdest[i-1] = psrc[i-1];
}
diff --git a/test/memory.c b/test/memory.c
index 9a58e46d..d5978079 100644
--- a/test/memory.c
+++ b/test/memory.c
@@ -26,11 +26,11 @@ void *memmove(void *dest, const void *src, size_t n) {
uint8_t *pdest = dest;
const uint8_t *psrc = src;
- if (src > dest) {
+ if ((uintptr_t)src > (uintptr_t)dest) {
for (size_t i = 0; i < n; i++) {
pdest[i] = psrc[i];
}
- } else if (src < dest) {
+ } else if ((uintptr_t)src < (uintptr_t)dest) {
for (size_t i = n; i > 0; i--) {
pdest[i-1] = psrc[i-1];
}
