[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1500997958.6516.7.camel@perches.com>
Date: Tue, 25 Jul 2017 08:52:38 -0700
From: Joe Perches <joe@...ches.com>
To: Arnd Bergmann <arnd@...db.de>,
Yannick Fertre <yannick.fertre@...com>,
Philippe Cornu <philippe.cornu@...com>,
Benjamin Gaignard <benjamin.gaignard@...aro.org>,
Vincent Abriou <vincent.abriou@...com>,
David Airlie <airlied@...ux.ie>
Cc: Neil Armstrong <narmstrong@...libre.com>,
Archit Taneja <architt@...eaurora.org>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/stm: fix warning about multiplication in condition
On Tue, 2017-07-25 at 17:40 +0200, Arnd Bergmann wrote:
> gcc-7 complains about multiplying within a condition being
> suspicious:
>
> drivers/gpu/drm/stm/dw_mipi_dsi-stm.c: In function 'dsi_pll_get_clkout_khz':
> drivers/gpu/drm/stm/dw_mipi_dsi-stm.c:117:10: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
>
> The code here is correct, but can be easily rephrased to make
> that more obvious. I also swap out the error handling and the normal
> code path for clarity.
Thanks, the new code does read much better.
> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
[]
> @@ -113,11 +113,13 @@ static enum dsi_color dsi_color_from_mipi(enum mipi_dsi_pixel_format fmt)
>
> static int dsi_pll_get_clkout_khz(int clkin_khz, int idf, int ndiv, int odf)
> {
> + int divisor = idf * odf;
> +
> /* prevent from division by 0 */
> - if (idf * odf)
> - return DIV_ROUND_CLOSEST(clkin_khz * ndiv, idf * odf);
> + if (!divisor)
> + return 0;
>
> - return 0;
> + return DIV_ROUND_CLOSEST(clkin_khz * ndiv, divisor);
> }
>
> static int dsi_pll_get_params(int clkin_khz, int clkout_khz,
Powered by blists - more mailing lists