[Mesa-dev] [PATCH kmscube] texturator: Use !! for boolean assignment
Ian Romanick
idr at freedesktop.org
Tue Mar 31 19:51:13 UTC 2020
On 3/31/20 12:25 PM, Fabio Estevam wrote:
> The 'complemented' variable is a pointer to boolean. Use the !! operator
> to fix the following build warning:
>
> ../texturator.c:603:45: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
> *complemented = (((float)rgba[2]) / 255.0) / 0.25;
>
> Signed-off-by: Fabio Estevam <festevam at gmail.com>
> ---
> texturator.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/texturator.c b/texturator.c
> index a450dfe..d31b601 100644
> --- a/texturator.c
> +++ b/texturator.c
> @@ -602,7 +602,7 @@ static void extract_pix(uint8_t *rgba, int *slice, int *level, bool *complemente
> {
> *slice = (((float)rgba[0]) / 255.0) * 8.0;
> *level = (((float)rgba[1]) / 255.0) * 16.0;
> - *complemented = (((float)rgba[2]) / 255.0) / 0.25;
> + *complemented = !!(((float)rgba[2]) / 255.0) / 0.25;
I don't know how others feel, but I know Matt hates this idiom. I'm not
terribly fond of it either. I think we both prefer either casting to
bool or x != 0.0. But... I don't feel that strongly.
> }
>
> static bool probe_pix(int x, int y, int w, int h, int s, int m)
>
More information about the mesa-dev
mailing list