Re: [PATCH] ide: avoid warning for timings calculation

From: Andy Shevchenko
Date: Sat May 27 2017 - 16:23:14 EST


On Thu, May 11, 2017 at 3:52 PM, Arnd Bergmann <arnd@xxxxxxxx> wrote:
> gcc-7 warns about the result of a constant multiplication used as
> a boolean:
>
> drivers/ide/ide-timings.c: In function 'ide_timing_quantize':
> drivers/ide/ide-timings.c:112:24: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> q->setup = EZ(t->setup * 1000, T);
>
> This slightly rearranges the macro to simplify the code and avoid
> the warning at the same time.

> #define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
> -#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
> +#define EZ(v, unit) ((v) ? ENOUGH(v * 1000, unit) : 0)

Perhaps
v -> (v) in the multiplication.

--
With Best Regards,
Andy Shevchenko