[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 2/2] linux-user/mmap: Fix Clang 'type-limit-compare' warning
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 2/2] linux-user/mmap: Fix Clang 'type-limit-compare' warning |
Date: |
Sun, 3 May 2020 13:32:20 +0200 |
When building with Clang 10 on Fedora 32, we get:
CC linux-user/mmap.o
linux-user/mmap.c:720:49: error: result of comparison 'unsigned long' >
18446744073709551615 is always false [-Werror,-Wtautological-type-limit-compare]
if ((unsigned long)host_addr + new_size > (abi_ulong)-1) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
Fix by restricting the check for when target sizeof(abi_ulong) is
smaller than target sizeof(unsigned long).
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
linux-user/mmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index e378033797..b14652d894 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -714,6 +714,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong
old_size,
errno = ENOMEM;
host_addr = MAP_FAILED;
}
+#if TARGET_ABI_BITS < TARGET_LONG_BITS
/* Check if address fits target address space */
if ((unsigned long)host_addr + new_size > (abi_ulong)-1) {
/* Revert mremap() changes */
@@ -721,6 +722,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong
old_size,
errno = ENOMEM;
host_addr = MAP_FAILED;
}
+#endif /* TARGET_ABI_BITS < TARGET_LONG_BITS */
}
if (host_addr == MAP_FAILED) {
--
2.21.3