All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition
@ 2017-09-06 13:13 Arnd Bergmann
  2017-09-07  5:29   ` Archit Taneja
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2017-09-06 13:13 UTC (permalink / raw)
  To: Yannick Fertre, Philippe Cornu, Benjamin Gaignard,
	Vincent Abriou, David Airlie
  Cc: Arnd Bergmann, Archit Taneja, Neil Armstrong, dri-devel, linux-kernel

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,
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition
  2017-09-06 13:13 [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition Arnd Bergmann
@ 2017-09-07  5:29   ` Archit Taneja
  0 siblings, 0 replies; 5+ messages in thread
From: Archit Taneja @ 2017-09-07  5:29 UTC (permalink / raw)
  To: Arnd Bergmann, Yannick Fertre, Philippe Cornu, Benjamin Gaignard,
	Vincent Abriou, David Airlie
  Cc: Neil Armstrong, dri-devel, linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition
@ 2017-09-07  5:29   ` Archit Taneja
  0 siblings, 0 replies; 5+ messages in thread
From: Archit Taneja @ 2017-09-07  5:29 UTC (permalink / raw)
  To: Arnd Bergmann, Yannick Fertre, Philippe Cornu, Benjamin Gaignard,
	Vincent Abriou, David Airlie
  Cc: linux-kernel, dri-devel, Neil Armstrong

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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition
  2017-09-07  5:29   ` Archit Taneja
@ 2017-09-08  6:30     ` Daniel Vetter
  -1 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2017-09-08  6:30 UTC (permalink / raw)
  To: Archit Taneja
  Cc: Arnd Bergmann, Yannick Fertre, Philippe Cornu, Benjamin Gaignard,
	Vincent Abriou, David Airlie, linux-kernel, dri-devel,
	Neil Armstrong

On Thu, Sep 07, 2017 at 10:59:49AM +0530, Archit Taneja wrote:
> Hi Benjamin,
> 
> This should be pushed to drm-misc by you, right?

I applied it. I guess Philippe Cornu should also become drm-misc committer
instead of just acking a patch and hoping fairies will pick it up.
-Daniel

> 
> 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
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition
@ 2017-09-08  6:30     ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2017-09-08  6:30 UTC (permalink / raw)
  To: Archit Taneja
  Cc: Arnd Bergmann, Neil Armstrong, Philippe Cornu, dri-devel,
	linux-kernel, Yannick Fertre, Vincent Abriou

On Thu, Sep 07, 2017 at 10:59:49AM +0530, Archit Taneja wrote:
> Hi Benjamin,
> 
> This should be pushed to drm-misc by you, right?

I applied it. I guess Philippe Cornu should also become drm-misc committer
instead of just acking a patch and hoping fairies will pick it up.
-Daniel

> 
> 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
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-08  6:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 13:13 [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition Arnd Bergmann
2017-09-07  5:29 ` Archit Taneja
2017-09-07  5:29   ` Archit Taneja
2017-09-08  6:30   ` Daniel Vetter
2017-09-08  6:30     ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.