[PATCH 1/3] dlls/ntdll: suppress GCC12 warning (from -Waddress)

Eric Pouech wine at gitlab.winehq.org
Fri Jun 10 05:13:54 CDT 2022


From: Eric Pouech <eric.pouech at gmail.com>

GCC12 warns about testing ptr + delta against 0/NULL when -Waddress is enabled
as it's 'most always wrong'.
It's not wrong here :-(
GCC docs suggests casting to (u)intptr_t to get rid of the warning

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
---
 dlls/ntdll/unix/virtual.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 6ecca9cb98a..b37ab44c5dc 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -238,7 +238,7 @@ static void mmap_add_reserved_area( void *addr, SIZE_T size )
     struct reserved_area *area;
     struct list *ptr;
 
-    if (!((char *)addr + size)) size--;  /* avoid wrap-around */
+    if (!(intptr_t)((char *)addr + size)) size--;  /* avoid wrap-around */
 
     LIST_FOR_EACH( ptr, &reserved_areas )
     {
@@ -287,7 +287,7 @@ static void mmap_remove_reserved_area( void *addr, SIZE_T size )
     struct reserved_area *area;
     struct list *ptr;
 
-    if (!((char *)addr + size)) size--;  /* avoid wrap-around */
+    if (!(intptr_t)((char *)addr + size)) size--;  /* avoid wrap-around */
 
     ptr = list_head( &reserved_areas );
     /* find the first area covering address */
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/224



More information about the wine-devel mailing list