Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753032AbdGYPwn (ORCPT ); Tue, 25 Jul 2017 11:52:43 -0400 Received: from smtprelay0236.hostedemail.com ([216.40.44.236]:58663 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752483AbdGYPwm (ORCPT ); Tue, 25 Jul 2017 11:52:42 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3870:3871:3874:4321:4362:5007:7903:7974:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12048:12296:12438:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21433:21627:30012:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: mom13_8b9f7394af212 X-Filterd-Recvd-Size: 2231 Message-ID: <1500997958.6516.7.camel@perches.com> Subject: Re: [PATCH] drm/stm: fix warning about multiplication in condition From: Joe Perches To: Arnd Bergmann , Yannick Fertre , Philippe Cornu , Benjamin Gaignard , Vincent Abriou , David Airlie Cc: Neil Armstrong , Archit Taneja , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Tue, 25 Jul 2017 08:52:38 -0700 In-Reply-To: <20170725154130.332221-1-arnd@arndb.de> References: <20170725154130.332221-1-arnd@arndb.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1165 Lines: 32 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,