The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Philippe CORNU <philippe.cornu@st.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Yannick FERTRE <yannick.fertre@st.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Vincent ABRIOU <vincent.abriou@st.com>,
	David Airlie <airlied@linux.ie>
Cc: Neil Armstrong <narmstrong@baylibre.com>,
	Archit Taneja <architt@codeaurora.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/stm: fix warning about multiplication in condition
Date: Tue, 25 Jul 2017 16:29:57 +0000	[thread overview]
Message-ID: <dfb5b8e9-6f00-1a5a-9fca-5cd83da79288@st.com> (raw)
In-Reply-To: <20170725154130.332221-1-arnd@arndb.de>



On 07/25/2017 05:40 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.

Hi Arnd,
And many thanks for this new & much better code.

Acked-by: Philippe Cornu <philippe.cornu@st.com>
Tested-by: Philippe Cornu <philippe.cornu@st.com>

Philippe :-)

> 
> Fixes: b0f09a3c69d9 ("drm/stm: Add STM32 DSI controller driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   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,
> 

      parent reply	other threads:[~2017-07-25 16:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 15:40 [PATCH] drm/stm: fix warning about multiplication in condition Arnd Bergmann
2017-07-25 15:52 ` Joe Perches
2017-07-25 16:29 ` Philippe CORNU [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dfb5b8e9-6f00-1a5a-9fca-5cd83da79288@st.com \
    --to=philippe.cornu@st.com \
    --cc=airlied@linux.ie \
    --cc=architt@codeaurora.org \
    --cc=arnd@arndb.de \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narmstrong@baylibre.com \
    --cc=vincent.abriou@st.com \
    --cc=yannick.fertre@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox