[PATCH 1/2] stdlib: Fix stdbit.h with -Wconversion for older gcc

Joseph Myers jsm@polyomino.org.uk
Thu Jan 4 20:04:31 GMT 2024


On Thu, 4 Jan 2024, Adhemerval Zanella wrote:

> @@ -748,13 +760,19 @@ __bc32_inline (uint32_t __x)
>  static __always_inline uint16_t
>  __bc16_inline (uint16_t __x)
>  {
> -  return __x <= 1 ? 1 : ((uint16_t) 2) << (__bw16_inline (__x - 1) - 1);
> +  return (uint16_t) (__x <= 1
> +		     ? 1
> +		     : ((uint16_t) 2)
> +			<< (__bw16_inline ((uint16_t) (__x - 1)) - 1));
>  }
>  
>  static __always_inline uint8_t
>  __bc8_inline (uint8_t __x)
>  {
> -  return __x <= 1 ? 1 : ((uint8_t) 2) << (__bw8_inline (__x - 1) - 1);
> +  return (uint8_t) (__x <= 1
> +		    ? 1
> +		    : ((uint8_t) 2)
> +		      << (__bw8_inline ((uint8_t) (__x - 1)) - 1));
>  }

Maybe these should use the __pacify macros as well?

-- 
Joseph S. Myers
jsm@polyomino.org.uk


More information about the Libc-alpha mailing list