diff mbox series

[1/3] malloc: Fix set-freeres.c with gcc 6

Message ID 20230724171524.2687112-2-adhemerval.zanella@linaro.org
State New
Headers show
Series Build fixes for older gcc | expand

Commit Message

Adhemerval Zanella Netto July 24, 2023, 5:15 p.m. UTC
Old GCC might trigger the the comparison will always evaluate as ‘true’
warnig for static build:

set-freeres.c:87:14: error: the comparison will always evaluate as
‘true’ for the address of ‘__libc_getgrgid_freemem_ptr’ will never be
NULL [-Werror=address]
   if (&__ptr != NULL)      \

So add pragma weak for all affected usages.

Checked on x86_64 and i686 with gcc 6 and 13.
---
 malloc/set-freeres.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

Comments

Carlos O'Donell July 26, 2023, 2:26 a.m. UTC | #1
On 7/24/23 13:15, Adhemerval Zanella via Libc-alpha wrote:
> Old GCC might trigger the the comparison will always evaluate as ‘true’
> warnig for static build:
> 
> set-freeres.c:87:14: error: the comparison will always evaluate as
> ‘true’ for the address of ‘__libc_getgrgid_freemem_ptr’ will never be
> NULL [-Werror=address]
>    if (&__ptr != NULL)      \
> 
> So add pragma weak for all affected usages.

Agreed, if these work for older gcc we should put prama weak for them.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

 
> Checked on x86_64 and i686 with gcc 6 and 13.
> ---
>  malloc/set-freeres.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
> 
> diff --git a/malloc/set-freeres.c b/malloc/set-freeres.c
> index 1aab34b586..41ef9c2dd6 100644
> --- a/malloc/set-freeres.c
> +++ b/malloc/set-freeres.c
> @@ -63,6 +63,52 @@
>  # pragma weak __libpthread_freeres
>  # pragma weak __libc_dlerror_result_free
>  # pragma weak __check_pf_freemem
> +# pragma weak __libc_fgetgrent_freemem_ptr
> +# pragma weak __libc_fgetsgent_freeres_ptr
> +# pragma weak __libc_getnetgrent_freemem_ptr
> +# pragma weak __libc_rcmd_freemem_ptr
> +# pragma weak __libc_rexec_freemem_ptr
> +# pragma weak __libc_mntent_freemem_ptr
> +# pragma weak __libc_fgetpwent_freemem_ptr
> +# pragma weak __libc_getspent_freemem_ptr
> +# pragma weak __libc_resolv_res_hconf_freemem_ptr
> +# pragma weak __libc_fgetspent_freemem_ptr
> +# pragma weak __libc_tzfile_freemem_ptr
> +# pragma weak __libc_getnameinfo_freemem_ptr
> +# pragma weak __libc_getutent_freemem_ptr
> +# pragma weak __libc_getutid_freemem_ptr
> +# pragma weak __libc_getutline_freemem_ptr
> +# pragma weak __libc_reg_printf_freemem_ptr
> +# pragma weak __libc_reg_type_freemem_ptr
> +# pragma weak __libc_getgrgid_freemem_ptr
> +# pragma weak __libc_getgrnam_freemem_ptr
> +# pragma weak __libc_getpwnam_freemem_ptr
> +# pragma weak __libc_getpwuid_freemem_ptr
> +# pragma weak __libc_getspnam_freemem_ptr
> +# pragma weak __libc_getaliasbyname_freemem_ptr
> +# pragma weak __libc_gethostbyaddr_freemem_ptr
> +# pragma weak __libc_gethostbyname_freemem_ptr
> +# pragma weak __libc_gethostbyname2_freemem_ptr
> +# pragma weak __libc_getnetbyaddr_freemem_ptr
> +# pragma weak __libc_getnetbyname_freemem_ptr
> +# pragma weak __libc_getprotobynumber_freemem_ptr
> +# pragma weak __libc_getprotobyname_freemem_ptr
> +# pragma weak __libc_getrpcbyname_freemem_ptr
> +# pragma weak __libc_getrpcbynumber_freemem_ptr
> +# pragma weak __libc_getservbyname_freemem_ptr
> +# pragma weak __libc_getservbyport_freemem_ptr
> +# pragma weak __libc_getgrent_freemem_ptr
> +# pragma weak __libc_getpwent_freemem_ptr
> +# pragma weak __libc_getaliasent_freemem_ptr
> +# pragma weak __libc_gethostent_freemem_ptr
> +# pragma weak __libc_getnetent_freemem_ptr
> +# pragma weak __libc_getprotoent_freemem_ptr
> +# pragma weak __libc_getrpcent_freemem_ptr
> +# pragma weak __libc_getservent_freemem_ptr
> +# pragma weak __libc_efgcvt_freemem_ptr
> +# pragma weak __libc_qefgcvt_freemem_ptr
> +# pragma weak __libc_qefgcvt_freemem_ptr
> +# pragma weak __ttyname_freemem_ptr
>  #endif
>  
>  #ifdef SHARED
diff mbox series

Patch

diff --git a/malloc/set-freeres.c b/malloc/set-freeres.c
index 1aab34b586..41ef9c2dd6 100644
--- a/malloc/set-freeres.c
+++ b/malloc/set-freeres.c
@@ -63,6 +63,52 @@ 
 # pragma weak __libpthread_freeres
 # pragma weak __libc_dlerror_result_free
 # pragma weak __check_pf_freemem
+# pragma weak __libc_fgetgrent_freemem_ptr
+# pragma weak __libc_fgetsgent_freeres_ptr
+# pragma weak __libc_getnetgrent_freemem_ptr
+# pragma weak __libc_rcmd_freemem_ptr
+# pragma weak __libc_rexec_freemem_ptr
+# pragma weak __libc_mntent_freemem_ptr
+# pragma weak __libc_fgetpwent_freemem_ptr
+# pragma weak __libc_getspent_freemem_ptr
+# pragma weak __libc_resolv_res_hconf_freemem_ptr
+# pragma weak __libc_fgetspent_freemem_ptr
+# pragma weak __libc_tzfile_freemem_ptr
+# pragma weak __libc_getnameinfo_freemem_ptr
+# pragma weak __libc_getutent_freemem_ptr
+# pragma weak __libc_getutid_freemem_ptr
+# pragma weak __libc_getutline_freemem_ptr
+# pragma weak __libc_reg_printf_freemem_ptr
+# pragma weak __libc_reg_type_freemem_ptr
+# pragma weak __libc_getgrgid_freemem_ptr
+# pragma weak __libc_getgrnam_freemem_ptr
+# pragma weak __libc_getpwnam_freemem_ptr
+# pragma weak __libc_getpwuid_freemem_ptr
+# pragma weak __libc_getspnam_freemem_ptr
+# pragma weak __libc_getaliasbyname_freemem_ptr
+# pragma weak __libc_gethostbyaddr_freemem_ptr
+# pragma weak __libc_gethostbyname_freemem_ptr
+# pragma weak __libc_gethostbyname2_freemem_ptr
+# pragma weak __libc_getnetbyaddr_freemem_ptr
+# pragma weak __libc_getnetbyname_freemem_ptr
+# pragma weak __libc_getprotobynumber_freemem_ptr
+# pragma weak __libc_getprotobyname_freemem_ptr
+# pragma weak __libc_getrpcbyname_freemem_ptr
+# pragma weak __libc_getrpcbynumber_freemem_ptr
+# pragma weak __libc_getservbyname_freemem_ptr
+# pragma weak __libc_getservbyport_freemem_ptr
+# pragma weak __libc_getgrent_freemem_ptr
+# pragma weak __libc_getpwent_freemem_ptr
+# pragma weak __libc_getaliasent_freemem_ptr
+# pragma weak __libc_gethostent_freemem_ptr
+# pragma weak __libc_getnetent_freemem_ptr
+# pragma weak __libc_getprotoent_freemem_ptr
+# pragma weak __libc_getrpcent_freemem_ptr
+# pragma weak __libc_getservent_freemem_ptr
+# pragma weak __libc_efgcvt_freemem_ptr
+# pragma weak __libc_qefgcvt_freemem_ptr
+# pragma weak __libc_qefgcvt_freemem_ptr
+# pragma weak __ttyname_freemem_ptr
 #endif
 
 #ifdef SHARED