Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752484AbdGYQaQ (ORCPT ); Tue, 25 Jul 2017 12:30:16 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:57070 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156AbdGYQaP (ORCPT ); Tue, 25 Jul 2017 12:30:15 -0400 From: Philippe CORNU To: Arnd Bergmann , Yannick FERTRE , Benjamin Gaignard , Vincent ABRIOU , David Airlie CC: Neil Armstrong , Archit Taneja , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] drm/stm: fix warning about multiplication in condition Thread-Topic: [PATCH] drm/stm: fix warning about multiplication in condition Thread-Index: AQHTBVyAMc8GgjV5qEioLFNqgn/XV6JkmkGA Date: Tue, 25 Jul 2017 16:29:57 +0000 Message-ID: References: <20170725154130.332221-1-arnd@arndb.de> In-Reply-To: <20170725154130.332221-1-arnd@arndb.de> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.45] Content-Type: text/plain; charset="utf-8" Content-ID: <8CECC9A55D796E48A0A73F0C48DCAE01@st.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-25_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v6PGUjTT012446 Content-Length: 1659 Lines: 50 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 Tested-by: Philippe Cornu Philippe :-) > > Fixes: b0f09a3c69d9 ("drm/stm: Add STM32 DSI controller driver") > Signed-off-by: Arnd Bergmann > --- > 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, >