Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1727916

Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition

From Archit Taneja <architt@codeaurora.org>
Newsgroups linux.kernel
Subject Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition
Date 2017-09-07 07:40 +0200
Message-ID <umXHH-3QW-1@gated-at.bofh.it> (permalink)
References <umIpj-2iw-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Benjamin,

This should be pushed to drm-misc by you, right?

Thanks,
Archit

On 09/06/2017 06:43 PM, 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.
> 
> Fixes: b0f09a3c69d9 ("drm/stm: Add STM32 DSI controller driver")
> Acked-by: Philippe Cornu <philippe.cornu@st.com>
> Tested-by: Philippe Cornu <philippe.cornu@st.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Originally sent on July 25, but never made it into linux-next.
> The warning is currently disabled in mainline, but this seems
> to be a legitimate instance, and we may want to turn it back
> on in the future.
> ---
>   drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> index 568c5d0461ea..e5b6310240fe 100644
> --- 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,
> 

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] [RESEND] drm/stm: fix warning about multiplication in condition Arnd Bergmann <arnd@arndb.de> - 2017-09-06 15:20 +0200
  Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in  condition Archit Taneja <architt@codeaurora.org> - 2017-09-07 07:40 +0200
    Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in  condition Daniel Vetter <daniel@ffwll.ch> - 2017-09-08 08:40 +0200

csiph-web