All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-05 20:09 ` Wolfram Sang
  0 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-05 20:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dan Carpenter, linux-renesas-soc, Wolfram Sang, dri-devel,
	linux-arm-kernel, linux-media, linux-samsung-soc, netdev

In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
similar patterns. This small patch series is the outcome.

Buildbot and checkpatch are happy. Only compile-tested. To be applied
individually per sub-system, I think. I'd think only the net: amd: patch needs
to be conisdered for stable, but I leave this to people who actually know this
driver.

CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
cppcheck reported a 'coding style' issue with a low prio.

Wolfram Sang (4):
  v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
  drm/exynos: fix comparison to bitshift when dealing with a mask
  v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing
    with a mask
  net: amd-xgbe: fix comparison to bitshift when dealing with a mask

 drivers/gpu/drm/exynos/regs-fimc.h        | 2 +-
 drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
 drivers/media/platform/vsp1/vsp1_regs.h   | 2 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c  | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.11.0

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-05 20:09 ` Wolfram Sang
  0 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-05 20:09 UTC (permalink / raw)
  To: linux-arm-kernel

In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
similar patterns. This small patch series is the outcome.

Buildbot and checkpatch are happy. Only compile-tested. To be applied
individually per sub-system, I think. I'd think only the net: amd: patch needs
to be conisdered for stable, but I leave this to people who actually know this
driver.

CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
cppcheck reported a 'coding style' issue with a low prio.

Wolfram Sang (4):
  v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
  drm/exynos: fix comparison to bitshift when dealing with a mask
  v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing
    with a mask
  net: amd-xgbe: fix comparison to bitshift when dealing with a mask

 drivers/gpu/drm/exynos/regs-fimc.h        | 2 +-
 drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
 drivers/media/platform/vsp1/vsp1_regs.h   | 2 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c  | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.11.0

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

* [PATCH 1/4] v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
  2018-02-05 20:09 ` Wolfram Sang
  (?)
@ 2018-02-05 20:09 ` Wolfram Sang
  2018-02-22 16:07   ` Laurent Pinchart
  -1 siblings, 1 reply; 37+ messages in thread
From: Wolfram Sang @ 2018-02-05 20:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dan Carpenter, linux-renesas-soc, Wolfram Sang, Laurent Pinchart,
	Mauro Carvalho Chehab, linux-media

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift. No regression since the mask has not been used yet.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Only build tested. To be applied individually per subsystem.

 drivers/media/platform/vsp1/vsp1_regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_regs.h b/drivers/media/platform/vsp1/vsp1_regs.h
index 26c4ffad2f4656..b1912c83a1dae2 100644
--- a/drivers/media/platform/vsp1/vsp1_regs.h
+++ b/drivers/media/platform/vsp1/vsp1_regs.h
@@ -225,7 +225,7 @@
 #define VI6_RPF_MULT_ALPHA_P_MMD_RATIO	(1 << 8)
 #define VI6_RPF_MULT_ALPHA_P_MMD_IMAGE	(2 << 8)
 #define VI6_RPF_MULT_ALPHA_P_MMD_BOTH	(3 << 8)
-#define VI6_RPF_MULT_ALPHA_RATIO_MASK	(0xff < 0)
+#define VI6_RPF_MULT_ALPHA_RATIO_MASK	(0xff << 0)
 #define VI6_RPF_MULT_ALPHA_RATIO_SHIFT	0
 
 /* -----------------------------------------------------------------------------
-- 
2.11.0

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

* [PATCH 2/4] drm/exynos: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:09 ` Wolfram Sang
@ 2018-02-05 20:09   ` Wolfram Sang
  -1 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-05 20:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dan Carpenter, linux-renesas-soc, Wolfram Sang, Inki Dae,
	Joonyoung Shim, Seung-Woo Kim, Kyungmin Park, David Airlie,
	Kukjin Kim, Krzysztof Kozlowski, dri-devel, linux-arm-kernel,
	linux-samsung-soc

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Only build tested. To be applied individually per subsystem.

 drivers/gpu/drm/exynos/regs-fimc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/regs-fimc.h b/drivers/gpu/drm/exynos/regs-fimc.h
index 30496134a3d072..d7cbe53c4c01f4 100644
--- a/drivers/gpu/drm/exynos/regs-fimc.h
+++ b/drivers/gpu/drm/exynos/regs-fimc.h
@@ -569,7 +569,7 @@
 #define EXYNOS_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
 #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE		(5 << 26)
 #define EXYNOS_CIIMGEFF_FIN_MASK			(7 << 26)
-#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff < 13) | (0xff < 0))
+#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff << 13) | (0xff << 0))
 
 /* Real input DMA size register */
 #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE	(1 << 31)
-- 
2.11.0

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

* [PATCH 2/4] drm/exynos: fix comparison to bitshift when dealing with a mask
@ 2018-02-05 20:09   ` Wolfram Sang
  0 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-05 20:09 UTC (permalink / raw)
  To: linux-arm-kernel

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Only build tested. To be applied individually per subsystem.

 drivers/gpu/drm/exynos/regs-fimc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/regs-fimc.h b/drivers/gpu/drm/exynos/regs-fimc.h
index 30496134a3d072..d7cbe53c4c01f4 100644
--- a/drivers/gpu/drm/exynos/regs-fimc.h
+++ b/drivers/gpu/drm/exynos/regs-fimc.h
@@ -569,7 +569,7 @@
 #define EXYNOS_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
 #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE		(5 << 26)
 #define EXYNOS_CIIMGEFF_FIN_MASK			(7 << 26)
-#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff < 13) | (0xff < 0))
+#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff << 13) | (0xff << 0))
 
 /* Real input DMA size register */
 #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE	(1 << 31)
-- 
2.11.0

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

* [PATCH 3/4] v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:09 ` Wolfram Sang
                   ` (2 preceding siblings ...)
  (?)
@ 2018-02-05 20:10 ` Wolfram Sang
  -1 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-05 20:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dan Carpenter, linux-renesas-soc, Wolfram Sang,
	Mauro Carvalho Chehab, linux-media

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Only build tested. To be applied individually per subsystem.

 drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/stb0899_reg.h b/drivers/media/dvb-frontends/stb0899_reg.h
index ba1ed56304a0f4..f564269249a682 100644
--- a/drivers/media/dvb-frontends/stb0899_reg.h
+++ b/drivers/media/dvb-frontends/stb0899_reg.h
@@ -374,22 +374,22 @@
 
 #define STB0899_OFF0_IF_AGC_GAIN		0xf30c
 #define STB0899_BASE_IF_AGC_GAIN		0x00000000
-#define STB0899_IF_AGC_GAIN			(0x3fff < 0)
+#define STB0899_IF_AGC_GAIN			(0x3fff << 0)
 #define STB0899_OFFST_IF_AGC_GAIN		0
 #define STB0899_WIDTH_IF_AGC_GAIN		14
 
 #define STB0899_OFF0_BB_AGC_GAIN		0xf310
 #define STB0899_BASE_BB_AGC_GAIN		0x00000000
-#define STB0899_BB_AGC_GAIN			(0x3fff < 0)
+#define STB0899_BB_AGC_GAIN			(0x3fff << 0)
 #define STB0899_OFFST_BB_AGC_GAIN		0
 #define STB0899_WIDTH_BB_AGC_GAIN		14
 
 #define STB0899_OFF0_DC_OFFSET			0xf314
 #define STB0899_BASE_DC_OFFSET			0x00000000
-#define STB0899_I				(0xff < 8)
+#define STB0899_I				(0xff << 8)
 #define STB0899_OFFST_I				8
 #define STB0899_WIDTH_I				8
-#define STB0899_Q				(0xff < 0)
+#define STB0899_Q				(0xff << 0)
 #define STB0899_OFFST_Q				8
 #define STB0899_WIDTH_Q				8
 
-- 
2.11.0

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

* [PATCH 4/4] net: amd-xgbe: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:09 ` Wolfram Sang
                   ` (3 preceding siblings ...)
  (?)
@ 2018-02-05 20:10 ` Wolfram Sang
  2018-02-05 22:35   ` Tom Lendacky
  2018-02-06 16:25   ` David Miller
  -1 siblings, 2 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-05 20:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dan Carpenter, linux-renesas-soc, Wolfram Sang, Tom Lendacky, netdev

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Only build tested. To be applied individually per subsystem.

 drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 7a3ebfd236f5eb..100adee778dfd6 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -595,7 +595,7 @@ static void xgbe_isr_task(unsigned long data)
 
 		reissue_mask = 1 << 0;
 		if (!pdata->per_channel_irq)
-			reissue_mask |= 0xffff < 4;
+			reissue_mask |= 0xffff << 4;
 
 		XP_IOWRITE(pdata, XP_INT_REISSUE_EN, reissue_mask);
 	}
-- 
2.11.0

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

* Re: [PATCH 4/4] net: amd-xgbe: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:10 ` [PATCH 4/4] net: amd-xgbe: " Wolfram Sang
@ 2018-02-05 22:35   ` Tom Lendacky
  2018-02-06 16:25   ` David Miller
  1 sibling, 0 replies; 37+ messages in thread
From: Tom Lendacky @ 2018-02-05 22:35 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: Dan Carpenter, linux-renesas-soc, netdev, David Miller

On 2/5/2018 2:10 PM, Wolfram Sang wrote:
> Due to a typo, the mask was destroyed by a comparison instead of a bit
> shift.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Excellent find.

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

David, this should also be applied to the 4.14 and 4.15 stable releases.

Thanks,
Tom

> ---
> Only build tested. To be applied individually per subsystem.
> 
>  drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
> index 7a3ebfd236f5eb..100adee778dfd6 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
> @@ -595,7 +595,7 @@ static void xgbe_isr_task(unsigned long data)
>  
>  		reissue_mask = 1 << 0;
>  		if (!pdata->per_channel_irq)
> -			reissue_mask |= 0xffff < 4;
> +			reissue_mask |= 0xffff << 4;
>  
>  		XP_IOWRITE(pdata, XP_INT_REISSUE_EN, reissue_mask);
>  	}
> 

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

* Re: [PATCH 2/4] drm/exynos: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:09   ` Wolfram Sang
@ 2018-02-06  0:06     ` Inki Dae
  -1 siblings, 0 replies; 37+ messages in thread
From: Inki Dae @ 2018-02-06  0:06 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: Dan Carpenter, linux-renesas-soc, Joonyoung Shim, Seung-Woo Kim,
	Kyungmin Park, David Airlie, Kukjin Kim, Krzysztof Kozlowski,
	dri-devel, linux-arm-kernel, linux-samsung-soc



2018년 02월 06일 05:09에 Wolfram Sang 이(가) 쓴 글:
> Due to a typo, the mask was destroyed by a comparison instead of a bit
> shift.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> Only build tested. To be applied individually per subsystem.
> 
>  drivers/gpu/drm/exynos/regs-fimc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/exynos/regs-fimc.h b/drivers/gpu/drm/exynos/regs-fimc.h
> index 30496134a3d072..d7cbe53c4c01f4 100644
> --- a/drivers/gpu/drm/exynos/regs-fimc.h
> +++ b/drivers/gpu/drm/exynos/regs-fimc.h
> @@ -569,7 +569,7 @@
>  #define EXYNOS_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
>  #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE		(5 << 26)
>  #define EXYNOS_CIIMGEFF_FIN_MASK			(7 << 26)
> -#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff < 13) | (0xff < 0))
> +#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff << 13) | (0xff << 0))
>  

Oops. Picked it up.

Thanks,
Inki Dae

>  /* Real input DMA size register */
>  #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE	(1 << 31)
> 

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

* [PATCH 2/4] drm/exynos: fix comparison to bitshift when dealing with a mask
@ 2018-02-06  0:06     ` Inki Dae
  0 siblings, 0 replies; 37+ messages in thread
From: Inki Dae @ 2018-02-06  0:06 UTC (permalink / raw)
  To: linux-arm-kernel



2018? 02? 06? 05:09? Wolfram Sang ?(?) ? ?:
> Due to a typo, the mask was destroyed by a comparison instead of a bit
> shift.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> Only build tested. To be applied individually per subsystem.
> 
>  drivers/gpu/drm/exynos/regs-fimc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/exynos/regs-fimc.h b/drivers/gpu/drm/exynos/regs-fimc.h
> index 30496134a3d072..d7cbe53c4c01f4 100644
> --- a/drivers/gpu/drm/exynos/regs-fimc.h
> +++ b/drivers/gpu/drm/exynos/regs-fimc.h
> @@ -569,7 +569,7 @@
>  #define EXYNOS_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
>  #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE		(5 << 26)
>  #define EXYNOS_CIIMGEFF_FIN_MASK			(7 << 26)
> -#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff < 13) | (0xff < 0))
> +#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff << 13) | (0xff << 0))
>  

Oops. Picked it up.

Thanks,
Inki Dae

>  /* Real input DMA size register */
>  #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE	(1 << 31)
> 

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:09 ` Wolfram Sang
  (?)
@ 2018-02-06  8:20   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 37+ messages in thread
From: Geert Uytterhoeven @ 2018-02-06  8:20 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Linux Kernel Mailing List, Dan Carpenter, Linux-Renesas,
	DRI Development, linux-arm-kernel, Linux Media Mailing List,
	linux-samsung-soc, netdev

Hi Wolfram,

On Mon, Feb 5, 2018 at 9:09 PM, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> similar patterns. This small patch series is the outcome.
>
> Buildbot and checkpatch are happy. Only compile-tested. To be applied
> individually per sub-system, I think. I'd think only the net: amd: patch needs
> to be conisdered for stable, but I leave this to people who actually know this
> driver.
>
> CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> cppcheck reported a 'coding style' issue with a low prio.

I found two more using "git grep 'define.*0x[0-9a-f]* < '":

drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n)
(0x00100 < (n))         /* 0 < n < 4 */

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06  8:20   ` Geert Uytterhoeven
  0 siblings, 0 replies; 37+ messages in thread
From: Geert Uytterhoeven @ 2018-02-06  8:20 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-samsung-soc, netdev, Linux Kernel Mailing List,
	DRI Development, Linux-Renesas, linux-arm-kernel, Dan Carpenter,
	Linux Media Mailing List

Hi Wolfram,

On Mon, Feb 5, 2018 at 9:09 PM, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> similar patterns. This small patch series is the outcome.
>
> Buildbot and checkpatch are happy. Only compile-tested. To be applied
> individually per sub-system, I think. I'd think only the net: amd: patch needs
> to be conisdered for stable, but I leave this to people who actually know this
> driver.
>
> CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> cppcheck reported a 'coding style' issue with a low prio.

I found two more using "git grep 'define.*0x[0-9a-f]* < '":

drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n)
(0x00100 < (n))         /* 0 < n < 4 */

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06  8:20   ` Geert Uytterhoeven
  0 siblings, 0 replies; 37+ messages in thread
From: Geert Uytterhoeven @ 2018-02-06  8:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Wolfram,

On Mon, Feb 5, 2018 at 9:09 PM, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> similar patterns. This small patch series is the outcome.
>
> Buildbot and checkpatch are happy. Only compile-tested. To be applied
> individually per sub-system, I think. I'd think only the net: amd: patch needs
> to be conisdered for stable, but I leave this to people who actually know this
> driver.
>
> CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> cppcheck reported a 'coding style' issue with a low prio.

I found two more using "git grep 'define.*0x[0-9a-f]* < '":

drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n)
(0x00100 < (n))         /* 0 < n < 4 */

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06  8:20   ` Geert Uytterhoeven
@ 2018-02-06  8:28     ` Wolfram Sang
  -1 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-06  8:28 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Wolfram Sang, Linux Kernel Mailing List, Dan Carpenter,
	Linux-Renesas, DRI Development, linux-arm-kernel,
	Linux Media Mailing List, linux-samsung-soc, netdev

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]


> I found two more using "git grep 'define.*0x[0-9a-f]* < '":

I added '[0-9]\+' at the end of the regex to reduce the number of false
positives...

> drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
> drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n)
> (0x00100 < (n))         /* 0 < n < 4 */

... but you found those two true positives in there. Nice, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06  8:28     ` Wolfram Sang
  0 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-06  8:28 UTC (permalink / raw)
  To: linux-arm-kernel


> I found two more using "git grep 'define.*0x[0-9a-f]* < '":

I added '[0-9]\+'@the end of the regex to reduce the number of false
positives...

> drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
> drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n)
> (0x00100 < (n))         /* 0 < n < 4 */

... but you found those two true positives in there. Nice, thanks!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180206/17969e2b/attachment.sig>

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:09 ` Wolfram Sang
  (?)
@ 2018-02-06 13:10   ` Dan Carpenter
  -1 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:10 UTC (permalink / raw)
  To: Wolfram Sang, Julia Lawall
  Cc: linux-kernel, linux-renesas-soc, dri-devel, linux-arm-kernel,
	linux-media, linux-samsung-soc, netdev

On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> similar patterns. This small patch series is the outcome.
> 
> Buildbot and checkpatch are happy. Only compile-tested. To be applied
> individually per sub-system, I think. I'd think only the net: amd: patch needs
> to be conisdered for stable, but I leave this to people who actually know this
> driver.
> 
> CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> cppcheck reported a 'coding style' issue with a low prio.
> 

Most of these are inside macros so it makes it complicated for Smatch
to warn about them.  It might be easier in Coccinelle.  Julia the bugs
look like this:

-			reissue_mask |= 0xffff < 4;
+			reissue_mask |= 0xffff << 4;

regards,
dan carpenter

> Wolfram Sang (4):
>   v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
>   drm/exynos: fix comparison to bitshift when dealing with a mask
>   v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing
>     with a mask
>   net: amd-xgbe: fix comparison to bitshift when dealing with a mask
> 
>  drivers/gpu/drm/exynos/regs-fimc.h        | 2 +-
>  drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
>  drivers/media/platform/vsp1/vsp1_regs.h   | 2 +-
>  drivers/net/ethernet/amd/xgbe/xgbe-drv.c  | 2 +-
>  4 files changed, 7 insertions(+), 7 deletions(-)
> 
> -- 
> 2.11.0

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:10   ` Dan Carpenter
  0 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:10 UTC (permalink / raw)
  To: Wolfram Sang, Julia Lawall
  Cc: linux-samsung-soc, netdev, linux-kernel, dri-devel,
	linux-renesas-soc, linux-arm-kernel, linux-media

On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> similar patterns. This small patch series is the outcome.
> 
> Buildbot and checkpatch are happy. Only compile-tested. To be applied
> individually per sub-system, I think. I'd think only the net: amd: patch needs
> to be conisdered for stable, but I leave this to people who actually know this
> driver.
> 
> CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> cppcheck reported a 'coding style' issue with a low prio.
> 

Most of these are inside macros so it makes it complicated for Smatch
to warn about them.  It might be easier in Coccinelle.  Julia the bugs
look like this:

-			reissue_mask |= 0xffff < 4;
+			reissue_mask |= 0xffff << 4;

regards,
dan carpenter

> Wolfram Sang (4):
>   v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
>   drm/exynos: fix comparison to bitshift when dealing with a mask
>   v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing
>     with a mask
>   net: amd-xgbe: fix comparison to bitshift when dealing with a mask
> 
>  drivers/gpu/drm/exynos/regs-fimc.h        | 2 +-
>  drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
>  drivers/media/platform/vsp1/vsp1_regs.h   | 2 +-
>  drivers/net/ethernet/amd/xgbe/xgbe-drv.c  | 2 +-
>  4 files changed, 7 insertions(+), 7 deletions(-)
> 
> -- 
> 2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:10   ` Dan Carpenter
  0 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> similar patterns. This small patch series is the outcome.
> 
> Buildbot and checkpatch are happy. Only compile-tested. To be applied
> individually per sub-system, I think. I'd think only the net: amd: patch needs
> to be conisdered for stable, but I leave this to people who actually know this
> driver.
> 
> CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> cppcheck reported a 'coding style' issue with a low prio.
> 

Most of these are inside macros so it makes it complicated for Smatch
to warn about them.  It might be easier in Coccinelle.  Julia the bugs
look like this:

-			reissue_mask |= 0xffff < 4;
+			reissue_mask |= 0xffff << 4;

regards,
dan carpenter

> Wolfram Sang (4):
>   v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
>   drm/exynos: fix comparison to bitshift when dealing with a mask
>   v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing
>     with a mask
>   net: amd-xgbe: fix comparison to bitshift when dealing with a mask
> 
>  drivers/gpu/drm/exynos/regs-fimc.h        | 2 +-
>  drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
>  drivers/media/platform/vsp1/vsp1_regs.h   | 2 +-
>  drivers/net/ethernet/amd/xgbe/xgbe-drv.c  | 2 +-
>  4 files changed, 7 insertions(+), 7 deletions(-)
> 
> -- 
> 2.11.0

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:10   ` Dan Carpenter
@ 2018-02-06 13:15     ` Julia Lawall
  -1 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 13:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, dri-devel,
	linux-arm-kernel, linux-media, linux-samsung-soc, netdev



On Tue, 6 Feb 2018, Dan Carpenter wrote:

> On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> > In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> > into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> > similar patterns. This small patch series is the outcome.
> >
> > Buildbot and checkpatch are happy. Only compile-tested. To be applied
> > individually per sub-system, I think. I'd think only the net: amd: patch needs
> > to be conisdered for stable, but I leave this to people who actually know this
> > driver.
> >
> > CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> > cppcheck reported a 'coding style' issue with a low prio.
> >
>
> Most of these are inside macros so it makes it complicated for Smatch
> to warn about them.  It might be easier in Coccinelle.  Julia the bugs
> look like this:
>
> -			reissue_mask |= 0xffff < 4;
> +			reissue_mask |= 0xffff << 4;

Thanks.  I'll take a look.  Do you have an example of the macro issue
handy?

julia

>
> regards,
> dan carpenter
>
> > Wolfram Sang (4):
> >   v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
> >   drm/exynos: fix comparison to bitshift when dealing with a mask
> >   v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing
> >     with a mask
> >   net: amd-xgbe: fix comparison to bitshift when dealing with a mask
> >
> >  drivers/gpu/drm/exynos/regs-fimc.h        | 2 +-
> >  drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
> >  drivers/media/platform/vsp1/vsp1_regs.h   | 2 +-
> >  drivers/net/ethernet/amd/xgbe/xgbe-drv.c  | 2 +-
> >  4 files changed, 7 insertions(+), 7 deletions(-)
> >
> > --
> > 2.11.0
>

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:15     ` Julia Lawall
  0 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 13:15 UTC (permalink / raw)
  To: linux-arm-kernel



On Tue, 6 Feb 2018, Dan Carpenter wrote:

> On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> > In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> > into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> > similar patterns. This small patch series is the outcome.
> >
> > Buildbot and checkpatch are happy. Only compile-tested. To be applied
> > individually per sub-system, I think. I'd think only the net: amd: patch needs
> > to be conisdered for stable, but I leave this to people who actually know this
> > driver.
> >
> > CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> > cppcheck reported a 'coding style' issue with a low prio.
> >
>
> Most of these are inside macros so it makes it complicated for Smatch
> to warn about them.  It might be easier in Coccinelle.  Julia the bugs
> look like this:
>
> -			reissue_mask |= 0xffff < 4;
> +			reissue_mask |= 0xffff << 4;

Thanks.  I'll take a look.  Do you have an example of the macro issue
handy?

julia

>
> regards,
> dan carpenter
>
> > Wolfram Sang (4):
> >   v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
> >   drm/exynos: fix comparison to bitshift when dealing with a mask
> >   v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing
> >     with a mask
> >   net: amd-xgbe: fix comparison to bitshift when dealing with a mask
> >
> >  drivers/gpu/drm/exynos/regs-fimc.h        | 2 +-
> >  drivers/media/dvb-frontends/stb0899_reg.h | 8 ++++----
> >  drivers/media/platform/vsp1/vsp1_regs.h   | 2 +-
> >  drivers/net/ethernet/amd/xgbe/xgbe-drv.c  | 2 +-
> >  4 files changed, 7 insertions(+), 7 deletions(-)
> >
> > --
> > 2.11.0
>

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:15     ` Julia Lawall
@ 2018-02-06 13:23       ` Dan Carpenter
  -1 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:23 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, dri-devel,
	linux-arm-kernel, linux-media, linux-samsung-soc, netdev

On Tue, Feb 06, 2018 at 02:15:51PM +0100, Julia Lawall wrote:
> 
> 
> On Tue, 6 Feb 2018, Dan Carpenter wrote:
> 
> > On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> > > In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> > > into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> > > similar patterns. This small patch series is the outcome.
> > >
> > > Buildbot and checkpatch are happy. Only compile-tested. To be applied
> > > individually per sub-system, I think. I'd think only the net: amd: patch needs
> > > to be conisdered for stable, but I leave this to people who actually know this
> > > driver.
> > >
> > > CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> > > cppcheck reported a 'coding style' issue with a low prio.
> > >
> >
> > Most of these are inside macros so it makes it complicated for Smatch
> > to warn about them.  It might be easier in Coccinelle.  Julia the bugs
> > look like this:
> >
> > -			reissue_mask |= 0xffff < 4;
> > +			reissue_mask |= 0xffff << 4;
> 
> Thanks.  I'll take a look.  Do you have an example of the macro issue
> handy?
> 

It's the same:

#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK          ((0xff < 13) | (0xff < 0)) 

Smatch only sees the outside of the macro (where it is used in the code)
and the pre-processed code.

regards,
dan carpenter

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:23       ` Dan Carpenter
  0 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Feb 06, 2018 at 02:15:51PM +0100, Julia Lawall wrote:
> 
> 
> On Tue, 6 Feb 2018, Dan Carpenter wrote:
> 
> > On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> > > In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> > > into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> > > similar patterns. This small patch series is the outcome.
> > >
> > > Buildbot and checkpatch are happy. Only compile-tested. To be applied
> > > individually per sub-system, I think. I'd think only the net: amd: patch needs
> > > to be conisdered for stable, but I leave this to people who actually know this
> > > driver.
> > >
> > > CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> > > cppcheck reported a 'coding style' issue with a low prio.
> > >
> >
> > Most of these are inside macros so it makes it complicated for Smatch
> > to warn about them.  It might be easier in Coccinelle.  Julia the bugs
> > look like this:
> >
> > -			reissue_mask |= 0xffff < 4;
> > +			reissue_mask |= 0xffff << 4;
> 
> Thanks.  I'll take a look.  Do you have an example of the macro issue
> handy?
> 

It's the same:

#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK          ((0xff < 13) | (0xff < 0)) 

Smatch only sees the outside of the macro (where it is used in the code)
and the pre-processed code.

regards,
dan carpenter

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:23       ` Dan Carpenter
@ 2018-02-06 13:40         ` Julia Lawall
  -1 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 13:40 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, dri-devel,
	linux-arm-kernel, linux-media, linux-samsung-soc, netdev



On Tue, 6 Feb 2018, Dan Carpenter wrote:

> On Tue, Feb 06, 2018 at 02:15:51PM +0100, Julia Lawall wrote:
> >
> >
> > On Tue, 6 Feb 2018, Dan Carpenter wrote:
> >
> > > On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> > > > In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> > > > into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> > > > similar patterns. This small patch series is the outcome.
> > > >
> > > > Buildbot and checkpatch are happy. Only compile-tested. To be applied
> > > > individually per sub-system, I think. I'd think only the net: amd: patch needs
> > > > to be conisdered for stable, but I leave this to people who actually know this
> > > > driver.
> > > >
> > > > CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> > > > cppcheck reported a 'coding style' issue with a low prio.
> > > >
> > >
> > > Most of these are inside macros so it makes it complicated for Smatch
> > > to warn about them.  It might be easier in Coccinelle.  Julia the bugs
> > > look like this:
> > >
> > > -			reissue_mask |= 0xffff < 4;
> > > +			reissue_mask |= 0xffff << 4;
> >
> > Thanks.  I'll take a look.  Do you have an example of the macro issue
> > handy?
> >
>
> It's the same:
>
> #define EXYNOS_CIIMGEFF_PAT_CBCR_MASK          ((0xff < 13) | (0xff < 0))
>
> Smatch only sees the outside of the macro (where it is used in the code)
> and the pre-processed code.

I wrote the following rule:

@@
constant int x,y;
identifier i;
type T;
@@

(
i < x
|
x < i
|
 (T)i < x
|
x < (T)i
|
* x < y
)

and got the results below.  I can make a version for the kernel shortly.

julia

diff -u -p /run/shm/linux-next/drivers/gpu/drm/exynos/regs-fimc.h /tmp/nothing/drivers/gpu/drm/exynos/regs-fimc.h
--- /run/shm/linux-next/drivers/gpu/drm/exynos/regs-fimc.h
+++ /tmp/nothing/drivers/gpu/drm/exynos/regs-fimc.h
@@ -569,7 +569,6 @@
 #define EXYNOS_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
 #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE		(5 << 26)
 #define EXYNOS_CIIMGEFF_FIN_MASK			(7 << 26)
-#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff < 13) | (0xff < 0))

 /* Real input DMA size register */
 #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE	(1 << 31)
diff -u -p /run/shm/linux-next/drivers/net/ethernet/amd/xgbe/xgbe-drv.c /tmp/nothing/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
--- /run/shm/linux-next/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ /tmp/nothing/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -595,7 +595,6 @@ isr_done:

 		reissue_mask = 1 << 0;
 		if (!pdata->per_channel_irq)
-			reissue_mask |= 0xffff < 4;

 		XP_IOWRITE(pdata, XP_INT_REISSUE_EN, reissue_mask);
 	}
diff -u -p /run/shm/linux-next/drivers/video/fbdev/mxsfb.c /tmp/nothing/drivers/video/fbdev/mxsfb.c
--- /run/shm/linux-next/drivers/video/fbdev/mxsfb.c
+++ /tmp/nothing/drivers/video/fbdev/mxsfb.c
@@ -133,8 +133,6 @@
 #define VDCTRL4_SYNC_SIGNALS_ON		(1 << 18)
 #define SET_DOTCLK_H_VALID_DATA_CNT(x)	((x) & 0x3ffff)

-#define DEBUG0_HSYNC			(1 < 26)
-#define DEBUG0_VSYNC			(1 < 25)

 #define MIN_XRES			120
 #define MIN_YRES			120
diff -u -p /run/shm/linux-next/include/drm/drm_scdc_helper.h /tmp/nothing/include/drm/drm_scdc_helper.h
--- /run/shm/linux-next/include/drm/drm_scdc_helper.h
+++ /tmp/nothing/include/drm/drm_scdc_helper.h
@@ -50,9 +50,6 @@
 #define  SCDC_READ_REQUEST_ENABLE (1 << 0)

 #define SCDC_STATUS_FLAGS_0 0x40
-#define  SCDC_CH2_LOCK (1 < 3)
-#define  SCDC_CH1_LOCK (1 < 2)
-#define  SCDC_CH0_LOCK (1 < 1)
 #define  SCDC_CH_LOCK_MASK (SCDC_CH2_LOCK | SCDC_CH1_LOCK | SCDC_CH0_LOCK)
 #define  SCDC_CLOCK_DETECT (1 << 0)

diff -u -p /run/shm/linux-next/arch/um/drivers/vector_user.h /tmp/nothing/arch/um/drivers/vector_user.h
--- /run/shm/linux-next/arch/um/drivers/vector_user.h
+++ /tmp/nothing/arch/um/drivers/vector_user.h
@@ -61,8 +61,6 @@ struct vector_fds {
 };

 #define VECTOR_READ	1
-#define VECTOR_WRITE	(1 < 1)
-#define VECTOR_HEADERS	(1 < 2)

 extern struct arglist *uml_parse_vector_ifspec(char *arg);

diff -u -p /run/shm/linux-next/drivers/gpu/drm/mxsfb/mxsfb_regs.h /tmp/nothing/drivers/gpu/drm/mxsfb/mxsfb_regs.h
--- /run/shm/linux-next/drivers/gpu/drm/mxsfb/mxsfb_regs.h
+++ /tmp/nothing/drivers/gpu/drm/mxsfb/mxsfb_regs.h
@@ -91,8 +91,6 @@
 #define VDCTRL4_SYNC_SIGNALS_ON		(1 << 18)
 #define SET_DOTCLK_H_VALID_DATA_CNT(x)	((x) & 0x3ffff)

-#define DEBUG0_HSYNC			(1 < 26)
-#define DEBUG0_VSYNC			(1 < 25)

 #define MXSFB_MIN_XRES			120
 #define MXSFB_MIN_YRES			120
diff -u -p /run/shm/linux-next/drivers/media/platform/vsp1/vsp1_regs.h /tmp/nothing/drivers/media/platform/vsp1/vsp1_regs.h
--- /run/shm/linux-next/drivers/media/platform/vsp1/vsp1_regs.h
+++ /tmp/nothing/drivers/media/platform/vsp1/vsp1_regs.h
@@ -225,7 +225,6 @@
 #define VI6_RPF_MULT_ALPHA_P_MMD_RATIO	(1 << 8)
 #define VI6_RPF_MULT_ALPHA_P_MMD_IMAGE	(2 << 8)
 #define VI6_RPF_MULT_ALPHA_P_MMD_BOTH	(3 << 8)
-#define VI6_RPF_MULT_ALPHA_RATIO_MASK	(0xff < 0)
 #define VI6_RPF_MULT_ALPHA_RATIO_SHIFT	0

 /* -----------------------------------------------------------------------------
diff -u -p /run/shm/linux-next/drivers/media/dvb-frontends/stb0899_reg.h /tmp/nothing/drivers/media/dvb-frontends/stb0899_reg.h
--- /run/shm/linux-next/drivers/media/dvb-frontends/stb0899_reg.h
+++ /tmp/nothing/drivers/media/dvb-frontends/stb0899_reg.h
@@ -374,22 +374,18 @@

 #define STB0899_OFF0_IF_AGC_GAIN		0xf30c
 #define STB0899_BASE_IF_AGC_GAIN		0x00000000
-#define STB0899_IF_AGC_GAIN			(0x3fff < 0)
 #define STB0899_OFFST_IF_AGC_GAIN		0
 #define STB0899_WIDTH_IF_AGC_GAIN		14

 #define STB0899_OFF0_BB_AGC_GAIN		0xf310
 #define STB0899_BASE_BB_AGC_GAIN		0x00000000
-#define STB0899_BB_AGC_GAIN			(0x3fff < 0)
 #define STB0899_OFFST_BB_AGC_GAIN		0
 #define STB0899_WIDTH_BB_AGC_GAIN		14

 #define STB0899_OFF0_DC_OFFSET			0xf314
 #define STB0899_BASE_DC_OFFSET			0x00000000
-#define STB0899_I				(0xff < 8)
 #define STB0899_OFFST_I				8
 #define STB0899_WIDTH_I				8
-#define STB0899_Q				(0xff < 0)
 #define STB0899_OFFST_Q				8
 #define STB0899_WIDTH_Q				8

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:40         ` Julia Lawall
  0 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 13:40 UTC (permalink / raw)
  To: linux-arm-kernel



On Tue, 6 Feb 2018, Dan Carpenter wrote:

> On Tue, Feb 06, 2018 at 02:15:51PM +0100, Julia Lawall wrote:
> >
> >
> > On Tue, 6 Feb 2018, Dan Carpenter wrote:
> >
> > > On Mon, Feb 05, 2018 at 09:09:57PM +0100, Wolfram Sang wrote:
> > > > In one Renesas driver, I found a typo which turned an intended bit shift ('<<')
> > > > into a comparison ('<'). Because this is a subtle issue, I looked tree wide for
> > > > similar patterns. This small patch series is the outcome.
> > > >
> > > > Buildbot and checkpatch are happy. Only compile-tested. To be applied
> > > > individually per sub-system, I think. I'd think only the net: amd: patch needs
> > > > to be conisdered for stable, but I leave this to people who actually know this
> > > > driver.
> > > >
> > > > CCing Dan. Maybe he has an idea how to add a test to smatch? In my setup, only
> > > > cppcheck reported a 'coding style' issue with a low prio.
> > > >
> > >
> > > Most of these are inside macros so it makes it complicated for Smatch
> > > to warn about them.  It might be easier in Coccinelle.  Julia the bugs
> > > look like this:
> > >
> > > -			reissue_mask |= 0xffff < 4;
> > > +			reissue_mask |= 0xffff << 4;
> >
> > Thanks.  I'll take a look.  Do you have an example of the macro issue
> > handy?
> >
>
> It's the same:
>
> #define EXYNOS_CIIMGEFF_PAT_CBCR_MASK          ((0xff < 13) | (0xff < 0))
>
> Smatch only sees the outside of the macro (where it is used in the code)
> and the pre-processed code.

I wrote the following rule:

@@
constant int x,y;
identifier i;
type T;
@@

(
i < x
|
x < i
|
 (T)i < x
|
x < (T)i
|
* x < y
)

and got the results below.  I can make a version for the kernel shortly.

julia

diff -u -p /run/shm/linux-next/drivers/gpu/drm/exynos/regs-fimc.h /tmp/nothing/drivers/gpu/drm/exynos/regs-fimc.h
--- /run/shm/linux-next/drivers/gpu/drm/exynos/regs-fimc.h
+++ /tmp/nothing/drivers/gpu/drm/exynos/regs-fimc.h
@@ -569,7 +569,6 @@
 #define EXYNOS_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
 #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE		(5 << 26)
 #define EXYNOS_CIIMGEFF_FIN_MASK			(7 << 26)
-#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff < 13) | (0xff < 0))

 /* Real input DMA size register */
 #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE	(1 << 31)
diff -u -p /run/shm/linux-next/drivers/net/ethernet/amd/xgbe/xgbe-drv.c /tmp/nothing/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
--- /run/shm/linux-next/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ /tmp/nothing/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -595,7 +595,6 @@ isr_done:

 		reissue_mask = 1 << 0;
 		if (!pdata->per_channel_irq)
-			reissue_mask |= 0xffff < 4;

 		XP_IOWRITE(pdata, XP_INT_REISSUE_EN, reissue_mask);
 	}
diff -u -p /run/shm/linux-next/drivers/video/fbdev/mxsfb.c /tmp/nothing/drivers/video/fbdev/mxsfb.c
--- /run/shm/linux-next/drivers/video/fbdev/mxsfb.c
+++ /tmp/nothing/drivers/video/fbdev/mxsfb.c
@@ -133,8 +133,6 @@
 #define VDCTRL4_SYNC_SIGNALS_ON		(1 << 18)
 #define SET_DOTCLK_H_VALID_DATA_CNT(x)	((x) & 0x3ffff)

-#define DEBUG0_HSYNC			(1 < 26)
-#define DEBUG0_VSYNC			(1 < 25)

 #define MIN_XRES			120
 #define MIN_YRES			120
diff -u -p /run/shm/linux-next/include/drm/drm_scdc_helper.h /tmp/nothing/include/drm/drm_scdc_helper.h
--- /run/shm/linux-next/include/drm/drm_scdc_helper.h
+++ /tmp/nothing/include/drm/drm_scdc_helper.h
@@ -50,9 +50,6 @@
 #define  SCDC_READ_REQUEST_ENABLE (1 << 0)

 #define SCDC_STATUS_FLAGS_0 0x40
-#define  SCDC_CH2_LOCK (1 < 3)
-#define  SCDC_CH1_LOCK (1 < 2)
-#define  SCDC_CH0_LOCK (1 < 1)
 #define  SCDC_CH_LOCK_MASK (SCDC_CH2_LOCK | SCDC_CH1_LOCK | SCDC_CH0_LOCK)
 #define  SCDC_CLOCK_DETECT (1 << 0)

diff -u -p /run/shm/linux-next/arch/um/drivers/vector_user.h /tmp/nothing/arch/um/drivers/vector_user.h
--- /run/shm/linux-next/arch/um/drivers/vector_user.h
+++ /tmp/nothing/arch/um/drivers/vector_user.h
@@ -61,8 +61,6 @@ struct vector_fds {
 };

 #define VECTOR_READ	1
-#define VECTOR_WRITE	(1 < 1)
-#define VECTOR_HEADERS	(1 < 2)

 extern struct arglist *uml_parse_vector_ifspec(char *arg);

diff -u -p /run/shm/linux-next/drivers/gpu/drm/mxsfb/mxsfb_regs.h /tmp/nothing/drivers/gpu/drm/mxsfb/mxsfb_regs.h
--- /run/shm/linux-next/drivers/gpu/drm/mxsfb/mxsfb_regs.h
+++ /tmp/nothing/drivers/gpu/drm/mxsfb/mxsfb_regs.h
@@ -91,8 +91,6 @@
 #define VDCTRL4_SYNC_SIGNALS_ON		(1 << 18)
 #define SET_DOTCLK_H_VALID_DATA_CNT(x)	((x) & 0x3ffff)

-#define DEBUG0_HSYNC			(1 < 26)
-#define DEBUG0_VSYNC			(1 < 25)

 #define MXSFB_MIN_XRES			120
 #define MXSFB_MIN_YRES			120
diff -u -p /run/shm/linux-next/drivers/media/platform/vsp1/vsp1_regs.h /tmp/nothing/drivers/media/platform/vsp1/vsp1_regs.h
--- /run/shm/linux-next/drivers/media/platform/vsp1/vsp1_regs.h
+++ /tmp/nothing/drivers/media/platform/vsp1/vsp1_regs.h
@@ -225,7 +225,6 @@
 #define VI6_RPF_MULT_ALPHA_P_MMD_RATIO	(1 << 8)
 #define VI6_RPF_MULT_ALPHA_P_MMD_IMAGE	(2 << 8)
 #define VI6_RPF_MULT_ALPHA_P_MMD_BOTH	(3 << 8)
-#define VI6_RPF_MULT_ALPHA_RATIO_MASK	(0xff < 0)
 #define VI6_RPF_MULT_ALPHA_RATIO_SHIFT	0

 /* -----------------------------------------------------------------------------
diff -u -p /run/shm/linux-next/drivers/media/dvb-frontends/stb0899_reg.h /tmp/nothing/drivers/media/dvb-frontends/stb0899_reg.h
--- /run/shm/linux-next/drivers/media/dvb-frontends/stb0899_reg.h
+++ /tmp/nothing/drivers/media/dvb-frontends/stb0899_reg.h
@@ -374,22 +374,18 @@

 #define STB0899_OFF0_IF_AGC_GAIN		0xf30c
 #define STB0899_BASE_IF_AGC_GAIN		0x00000000
-#define STB0899_IF_AGC_GAIN			(0x3fff < 0)
 #define STB0899_OFFST_IF_AGC_GAIN		0
 #define STB0899_WIDTH_IF_AGC_GAIN		14

 #define STB0899_OFF0_BB_AGC_GAIN		0xf310
 #define STB0899_BASE_BB_AGC_GAIN		0x00000000
-#define STB0899_BB_AGC_GAIN			(0x3fff < 0)
 #define STB0899_OFFST_BB_AGC_GAIN		0
 #define STB0899_WIDTH_BB_AGC_GAIN		14

 #define STB0899_OFF0_DC_OFFSET			0xf314
 #define STB0899_BASE_DC_OFFSET			0x00000000
-#define STB0899_I				(0xff < 8)
 #define STB0899_OFFST_I				8
 #define STB0899_WIDTH_I				8
-#define STB0899_Q				(0xff < 0)
 #define STB0899_OFFST_Q				8
 #define STB0899_WIDTH_Q				8

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:40         ` Julia Lawall
@ 2018-02-06 13:53           ` Wolfram Sang
  -1 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-06 13:53 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Dan Carpenter, Wolfram Sang, linux-kernel, linux-renesas-soc,
	dri-devel, linux-arm-kernel, linux-media, linux-samsung-soc,
	netdev

[-- Attachment #1: Type: text/plain, Size: 162 bytes --]

Hi Julia,

> and got the results below.  I can make a version for the kernel shortly.

It should probably take care of right-shifting, too?

Thanks,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:53           ` Wolfram Sang
  0 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-06 13:53 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Julia,

> and got the results below.  I can make a version for the kernel shortly.

It should probably take care of right-shifting, too?

Thanks,

   Wolfram

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180206/8c8020c0/attachment.sig>

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:53           ` Wolfram Sang
@ 2018-02-06 13:54             ` Julia Lawall
  -1 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 13:54 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Dan Carpenter, Wolfram Sang, linux-kernel, linux-renesas-soc,
	dri-devel, linux-arm-kernel, linux-media, linux-samsung-soc,
	netdev



On Tue, 6 Feb 2018, Wolfram Sang wrote:

> Hi Julia,
>
> > and got the results below.  I can make a version for the kernel shortly.
>
> It should probably take care of right-shifting, too?

I did that too but got no results.  Perhaps right shifting constants is
pretty uncommon.  I can put that in the complete rule though.

julia

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:54             ` Julia Lawall
  0 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 13:54 UTC (permalink / raw)
  To: linux-arm-kernel



On Tue, 6 Feb 2018, Wolfram Sang wrote:

> Hi Julia,
>
> > and got the results below.  I can make a version for the kernel shortly.
>
> It should probably take care of right-shifting, too?

I did that too but got no results.  Perhaps right shifting constants is
pretty uncommon.  I can put that in the complete rule though.

julia

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:54             ` Julia Lawall
@ 2018-02-06 13:57               ` Wolfram Sang
  -1 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-06 13:57 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Dan Carpenter, Wolfram Sang, linux-kernel, linux-renesas-soc,
	dri-devel, linux-arm-kernel, linux-media, linux-samsung-soc,
	netdev

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]


> I did that too but got no results.  Perhaps right shifting constants is
> pretty uncommon.  I can put that in the complete rule though.

Please do. Even if rare, we would want this bug pointed out, right? :)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:57               ` Wolfram Sang
  0 siblings, 0 replies; 37+ messages in thread
From: Wolfram Sang @ 2018-02-06 13:57 UTC (permalink / raw)
  To: linux-arm-kernel


> I did that too but got no results.  Perhaps right shifting constants is
> pretty uncommon.  I can put that in the complete rule though.

Please do. Even if rare, we would want this bug pointed out, right? :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180206/154ec951/attachment.sig>

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:40         ` Julia Lawall
  (?)
@ 2018-02-06 13:59           ` Dan Carpenter
  -1 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:59 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, dri-devel,
	linux-arm-kernel, linux-media, linux-samsung-soc, netdev

That found 4 that I think Wolfram's grep missed.

 arch/um/drivers/vector_user.h             |    2 --
 drivers/gpu/drm/mxsfb/mxsfb_regs.h        |    2 --
 drivers/video/fbdev/mxsfb.c               |    2 --
 include/drm/drm_scdc_helper.h             |    3 ---

But it didn't find the two bugs that Geert found where the right side
wasn't a number literal.

drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n) (0x00100 < (n))         /* 0 < n < 4 */

regards,
dan carpenter

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:59           ` Dan Carpenter
  0 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:59 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-samsung-soc, netdev, linux-kernel, dri-devel,
	linux-renesas-soc, Wolfram Sang, linux-arm-kernel, linux-media

That found 4 that I think Wolfram's grep missed.

 arch/um/drivers/vector_user.h             |    2 --
 drivers/gpu/drm/mxsfb/mxsfb_regs.h        |    2 --
 drivers/video/fbdev/mxsfb.c               |    2 --
 include/drm/drm_scdc_helper.h             |    3 ---

But it didn't find the two bugs that Geert found where the right side
wasn't a number literal.

drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n) (0x00100 < (n))         /* 0 < n < 4 */

regards,
dan carpenter

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 13:59           ` Dan Carpenter
  0 siblings, 0 replies; 37+ messages in thread
From: Dan Carpenter @ 2018-02-06 13:59 UTC (permalink / raw)
  To: linux-arm-kernel

That found 4 that I think Wolfram's grep missed.

 arch/um/drivers/vector_user.h             |    2 --
 drivers/gpu/drm/mxsfb/mxsfb_regs.h        |    2 --
 drivers/video/fbdev/mxsfb.c               |    2 --
 include/drm/drm_scdc_helper.h             |    3 ---

But it didn't find the two bugs that Geert found where the right side
wasn't a number literal.

drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)
drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n) (0x00100 < (n))         /* 0 < n < 4 */

regards,
dan carpenter

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

* Re: [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
  2018-02-06 13:59           ` Dan Carpenter
@ 2018-02-06 14:08             ` Julia Lawall
  -1 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 14:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, dri-devel,
	linux-arm-kernel, linux-media, linux-samsung-soc, netdev



On Tue, 6 Feb 2018, Dan Carpenter wrote:

> That found 4 that I think Wolfram's grep missed.
>
>  arch/um/drivers/vector_user.h             |    2 --
>  drivers/gpu/drm/mxsfb/mxsfb_regs.h        |    2 --
>  drivers/video/fbdev/mxsfb.c               |    2 --
>  include/drm/drm_scdc_helper.h             |    3 ---
>
> But it didn't find the two bugs that Geert found where the right side
> wasn't a number literal.
>
> drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)

OK, I can easily add this in - I've got rules to protect against reporting
it at the moment.  It may end up with false positives.

> drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n) (0x00100 < (n))         /* 0 < n < 4 */

This is indeed harder, because one has to look at the usage site.

julia

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

* [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask
@ 2018-02-06 14:08             ` Julia Lawall
  0 siblings, 0 replies; 37+ messages in thread
From: Julia Lawall @ 2018-02-06 14:08 UTC (permalink / raw)
  To: linux-arm-kernel



On Tue, 6 Feb 2018, Dan Carpenter wrote:

> That found 4 that I think Wolfram's grep missed.
>
>  arch/um/drivers/vector_user.h             |    2 --
>  drivers/gpu/drm/mxsfb/mxsfb_regs.h        |    2 --
>  drivers/video/fbdev/mxsfb.c               |    2 --
>  include/drm/drm_scdc_helper.h             |    3 ---
>
> But it didn't find the two bugs that Geert found where the right side
> wasn't a number literal.
>
> drivers/net/can/m_can/m_can.c:#define RXFC_FWM_MASK     (0x7f < RXFC_FWM_SHIFT)

OK, I can easily add this in - I've got rules to protect against reporting
it@the moment.  It may end up with false positives.

> drivers/usb/gadget/udc/goku_udc.h:#define INT_EPnNAK(n) (0x00100 < (n))         /* 0 < n < 4 */

This is indeed harder, because one has to look@the usage site.

julia

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

* Re: [PATCH 4/4] net: amd-xgbe: fix comparison to bitshift when dealing with a mask
  2018-02-05 20:10 ` [PATCH 4/4] net: amd-xgbe: " Wolfram Sang
  2018-02-05 22:35   ` Tom Lendacky
@ 2018-02-06 16:25   ` David Miller
  1 sibling, 0 replies; 37+ messages in thread
From: David Miller @ 2018-02-06 16:25 UTC (permalink / raw)
  To: wsa+renesas
  Cc: linux-kernel, dan.carpenter, linux-renesas-soc, thomas.lendacky, netdev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date: Mon,  5 Feb 2018 21:10:01 +0100

> Due to a typo, the mask was destroyed by a comparison instead of a bit
> shift.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied and queued up for -stable, thanks.

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

* Re: [PATCH 1/4] v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO
  2018-02-05 20:09 ` [PATCH 1/4] v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO Wolfram Sang
@ 2018-02-22 16:07   ` Laurent Pinchart
  0 siblings, 0 replies; 37+ messages in thread
From: Laurent Pinchart @ 2018-02-22 16:07 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Dan Carpenter, linux-renesas-soc,
	Mauro Carvalho Chehab, linux-media

Hi Wolfram,

Thank you for the patch.

On Monday, 5 February 2018 22:09:58 EET Wolfram Sang wrote:
> Due to a typo, the mask was destroyed by a comparison instead of a bit
> shift. No regression since the mask has not been used yet.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Oops.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

and taken in my tree.

> ---
> Only build tested. To be applied individually per subsystem.
> 
>  drivers/media/platform/vsp1/vsp1_regs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_regs.h
> b/drivers/media/platform/vsp1/vsp1_regs.h index
> 26c4ffad2f4656..b1912c83a1dae2 100644
> --- a/drivers/media/platform/vsp1/vsp1_regs.h
> +++ b/drivers/media/platform/vsp1/vsp1_regs.h
> @@ -225,7 +225,7 @@
>  #define VI6_RPF_MULT_ALPHA_P_MMD_RATIO	(1 << 8)
>  #define VI6_RPF_MULT_ALPHA_P_MMD_IMAGE	(2 << 8)
>  #define VI6_RPF_MULT_ALPHA_P_MMD_BOTH	(3 << 8)
> -#define VI6_RPF_MULT_ALPHA_RATIO_MASK	(0xff < 0)
> +#define VI6_RPF_MULT_ALPHA_RATIO_MASK	(0xff << 0)
>  #define VI6_RPF_MULT_ALPHA_RATIO_SHIFT	0
> 
>  /* ------------------------------------------------------------------------

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2018-02-22 16:06 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-05 20:09 [PATCH 0/4] tree-wide: fix comparison to bitshift when dealing with a mask Wolfram Sang
2018-02-05 20:09 ` Wolfram Sang
2018-02-05 20:09 ` [PATCH 1/4] v4l: vsp1: fix mask creation for MULT_ALPHA_RATIO Wolfram Sang
2018-02-22 16:07   ` Laurent Pinchart
2018-02-05 20:09 ` [PATCH 2/4] drm/exynos: fix comparison to bitshift when dealing with a mask Wolfram Sang
2018-02-05 20:09   ` Wolfram Sang
2018-02-06  0:06   ` Inki Dae
2018-02-06  0:06     ` Inki Dae
2018-02-05 20:10 ` [PATCH 3/4] v4l: dvb-frontends: stb0899: " Wolfram Sang
2018-02-05 20:10 ` [PATCH 4/4] net: amd-xgbe: " Wolfram Sang
2018-02-05 22:35   ` Tom Lendacky
2018-02-06 16:25   ` David Miller
2018-02-06  8:20 ` [PATCH 0/4] tree-wide: " Geert Uytterhoeven
2018-02-06  8:20   ` Geert Uytterhoeven
2018-02-06  8:20   ` Geert Uytterhoeven
2018-02-06  8:28   ` Wolfram Sang
2018-02-06  8:28     ` Wolfram Sang
2018-02-06 13:10 ` Dan Carpenter
2018-02-06 13:10   ` Dan Carpenter
2018-02-06 13:10   ` Dan Carpenter
2018-02-06 13:15   ` Julia Lawall
2018-02-06 13:15     ` Julia Lawall
2018-02-06 13:23     ` Dan Carpenter
2018-02-06 13:23       ` Dan Carpenter
2018-02-06 13:40       ` Julia Lawall
2018-02-06 13:40         ` Julia Lawall
2018-02-06 13:53         ` Wolfram Sang
2018-02-06 13:53           ` Wolfram Sang
2018-02-06 13:54           ` Julia Lawall
2018-02-06 13:54             ` Julia Lawall
2018-02-06 13:57             ` Wolfram Sang
2018-02-06 13:57               ` Wolfram Sang
2018-02-06 13:59         ` Dan Carpenter
2018-02-06 13:59           ` Dan Carpenter
2018-02-06 13:59           ` Dan Carpenter
2018-02-06 14:08           ` Julia Lawall
2018-02-06 14:08             ` Julia Lawall

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.