[PATCH 0/3] MR224: Fix GCC12 warnings
Fixes a couple of warnings emitted by GCC12 compiler -- https://gitlab.winehq.org/wine/wine/-/merge_requests/224
From: Eric Pouech <eric.pouech(a)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(a)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
From: Eric Pouech <eric.pouech(a)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(a)gmail.com> --- libs/wine/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/wine/mmap.c b/libs/wine/mmap.c index ad51153d039..5296d87e086 100644 --- a/libs/wine/mmap.c +++ b/libs/wine/mmap.c @@ -501,7 +501,7 @@ void wine_mmap_add_reserved_area_obsolete( 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 ) { @@ -560,7 +560,7 @@ void wine_mmap_remove_reserved_area_obsolete( void *addr, size_t size, int unmap 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
From: Eric Pouech <eric.pouech(a)gmail.com> GCC12 warns about env variable that could be not initialized (it could be the case when env copy malloc fails) This is very unlikely to happen, and there's not much that can be done if this fails anyway. Adding an assert (as done in same function for failing virtual alloc) makes the warning vanish. Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com> --- dlls/ntdll/unix/env.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index a71df03966f..88dbc4e07ae 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1892,6 +1892,7 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) NTSTATUS status; /* store the initial PATH value */ + assert( env ); path = get_env_var( env, env_pos, pathW, 4 ); add_dynamic_environment( &env, &env_pos, &env_size ); add_registry_environment( &env, &env_pos, &env_size ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/224
This merge request was closed by eric pouech. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/224
participants (2)
-
Eric Pouech -
eric pouech (@epo)