Re: [PATCH] sys/cdefs.h: Protect parameters to __builtin_is_aligned()

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Jul 22 23:45, Paul Cercueil wrote:
> The macro was not protecting properly its first parameter, which caused
> it to silently return an invalid value when passing a composed
> parameter, ie.
> 
> __builtin_is_aligned(src | dst | len, 32);
> 
> Signed-off-by: Paul Cercueil <[email protected]>
> ---
>  newlib/libc/include/sys/cdefs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
> index d13a92a79..20b3553dc 100644
> --- a/newlib/libc/include/sys/cdefs.h
> +++ b/newlib/libc/include/sys/cdefs.h
> @@ -736,7 +736,7 @@
>  /* Provide fallback versions for other compilers (GCC/Clang < 10): */
>  #if !__has_builtin(__builtin_is_aligned)
>  #define __builtin_is_aligned(x, align)	\
> -	(((__uintptr_t)x & ((align) - 1)) == 0)
> +	(((__uintptr_t)(x) & ((align) - 1)) == 0)
>  #endif
>  #if !__has_builtin(__builtin_align_up)
>  #define __builtin_align_up(x, align)	\
> -- 
> 2.47.2

Pushed.

Thanks,
Corinna
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.