linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] adjust double test
@ 2012-01-12 21:33 Julia Lawall
  2012-01-12 21:33 ` [PATCH 1/4] drivers/staging: " Julia Lawall
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Julia Lawall @ 2012-01-12 21:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

These patches fix cases where there are two tests of the same expression.


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

* [PATCH 1/4] drivers/staging: adjust double test
  2012-01-12 21:33 [PATCH 0/4] adjust double test Julia Lawall
@ 2012-01-12 21:33 ` Julia Lawall
  2012-01-18 17:18   ` walter harms
  2012-01-12 21:33 ` [PATCH 2/4] drivers/media/video/s5p-fimc/fimc-capture.c: " Julia Lawall
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2012-01-12 21:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: kernel-janitors, devel, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Rewrite a duplicated test to test the correct value

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E;
@@

(
* E
  || ... || E
|
* E
  && ... && E
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/staging/gma500/mdfld_dsi_pkg_sender.c |    6 ++----
 drivers/staging/rtl8192e/rtllib_rx.c          |    2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 6c5061f..13979b5 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -2453,7 +2453,7 @@ static inline void update_network(struct rtllib_network *dst,
 	if (src->wmm_param[0].ac_aci_acm_aifsn ||
 	   src->wmm_param[1].ac_aci_acm_aifsn ||
 	   src->wmm_param[2].ac_aci_acm_aifsn ||
-	   src->wmm_param[1].ac_aci_acm_aifsn)
+	   src->wmm_param[3].ac_aci_acm_aifsn)
 		memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
 
 	dst->SignalStrength = src->SignalStrength;
diff --git a/drivers/staging/gma500/mdfld_dsi_pkg_sender.c b/drivers/staging/gma500/mdfld_dsi_pkg_sender.c
index 9b96a5c..3a9f44f 100644
--- a/drivers/staging/gma500/mdfld_dsi_pkg_sender.c
+++ b/drivers/staging/gma500/mdfld_dsi_pkg_sender.c
@@ -1249,8 +1249,7 @@ int mdfld_dsi_read_gen_hs(struct mdfld_dsi_pkg_sender *sender,
 			u32 *data,
 			u16 len)
 {
-	if (!sender || !data || param_num < 0 || param_num > 2
-		|| !data || !len) {
+	if (!sender || param_num < 0 || param_num > 2 || !data || !len) {
 		DRM_ERROR("Invalid parameters\n");
 		return -EINVAL;
 	}
@@ -1267,8 +1266,7 @@ int mdfld_dsi_read_gen_lp(struct mdfld_dsi_pkg_sender *sender,
 			u32 *data,
 			u16 len)
 {
-	if (!sender || !data || param_num < 0 || param_num > 2
-		|| !data || !len) {
+	if (!sender || param_num < 0 || param_num > 2 || !data || !len) {
 		DRM_ERROR("Invalid parameters\n");
 		return -EINVAL;
 	}


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

* [PATCH 2/4] drivers/media/video/s5p-fimc/fimc-capture.c: adjust double test
  2012-01-12 21:33 [PATCH 0/4] adjust double test Julia Lawall
  2012-01-12 21:33 ` [PATCH 1/4] drivers/staging: " Julia Lawall
@ 2012-01-12 21:33 ` Julia Lawall
  2012-01-12 21:33 ` [PATCH 3/4] drivers/dma/amba-pl08x.c: " Julia Lawall
  2012-01-12 21:33 ` [PATCH 4/4] drivers/media/video/s5p-mfc/s5p_mfc.c: " Julia Lawall
  3 siblings, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2012-01-12 21:33 UTC (permalink / raw)
  To: Kyungmin Park
  Cc: kernel-janitors, Sylwester Nawrocki, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-media, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Rewrite a duplicated test to test the correct value

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E;
@@

(
* E
  || ... || E
|
* E
  && ... && E
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/media/video/s5p-fimc/fimc-capture.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index 2cc3b91..eb38ae5 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -689,7 +689,7 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
 			mf->code = 0;
 			continue;
 		}
-		if (mf->width != tfmt->width || mf->width != tfmt->width) {
+		if (mf->width != tfmt->width || mf->height != tfmt->height) {
 			u32 fcc = ffmt->fourcc;
 			tfmt->width  = mf->width;
 			tfmt->height = mf->height;
@@ -698,7 +698,7 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
 					       NULL, &fcc, FIMC_SD_PAD_SOURCE);
 			if (ffmt && ffmt->mbus_code)
 				mf->code = ffmt->mbus_code;
-			if (mf->width != tfmt->width || mf->width != tfmt->width)
+			if (mf->width != tfmt->width || mf->height != tfmt->height)
 				continue;
 			tfmt->code = mf->code;
 		}
@@ -706,7 +706,7 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
 			ret = v4l2_subdev_call(csis, pad, set_fmt, NULL, &sfmt);
 
 		if (mf->code == tfmt->code &&
-		    mf->width == tfmt->width && mf->width == tfmt->width)
+		    mf->width == tfmt->width && mf->height == tfmt->height)
 			break;
 	}
 


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

* [PATCH 3/4] drivers/dma/amba-pl08x.c: adjust double test
  2012-01-12 21:33 [PATCH 0/4] adjust double test Julia Lawall
  2012-01-12 21:33 ` [PATCH 1/4] drivers/staging: " Julia Lawall
  2012-01-12 21:33 ` [PATCH 2/4] drivers/media/video/s5p-fimc/fimc-capture.c: " Julia Lawall
@ 2012-01-12 21:33 ` Julia Lawall
  2012-01-12 21:33 ` [PATCH 4/4] drivers/media/video/s5p-mfc/s5p_mfc.c: " Julia Lawall
  3 siblings, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2012-01-12 21:33 UTC (permalink / raw)
  To: Dan Williams; +Cc: kernel-janitors, Vinod Koul, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Rewrite a duplicated test to test the correct value

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E;
@@

(
* E
  || ... || E
|
* E
  && ... && E
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/dma/amba-pl08x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index 8a28158..840c6c0 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -649,7 +649,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
 			}
 
 			if ((bd.srcbus.addr % bd.srcbus.buswidth) ||
-					(bd.srcbus.addr % bd.srcbus.buswidth)) {
+					(bd.dstbus.addr % bd.dstbus.buswidth)) {
 				dev_err(&pl08x->adev->dev,
 					"%s src & dst address must be aligned to src"
 					" & dst width if peripheral is flow controller",


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

* [PATCH 4/4] drivers/media/video/s5p-mfc/s5p_mfc.c: adjust double test
  2012-01-12 21:33 [PATCH 0/4] adjust double test Julia Lawall
                   ` (2 preceding siblings ...)
  2012-01-12 21:33 ` [PATCH 3/4] drivers/dma/amba-pl08x.c: " Julia Lawall
@ 2012-01-12 21:33 ` Julia Lawall
  2012-01-13  5:33   ` Kyungmin Park
  3 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2012-01-12 21:33 UTC (permalink / raw)
  To: Kyungmin Park
  Cc: kernel-janitors, Kamil Debski, Jeongtae Park,
	Mauro Carvalho Chehab, linux-arm-kernel, linux-media,
	linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Rewrite a duplicated test to test the correct value

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E;
@@

(
* E
  || ... || E
|
* E
  && ... && E
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/media/video/s5p-mfc/s5p_mfc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/video/s5p-mfc/s5p_mfc.c b/drivers/media/video/s5p-mfc/s5p_mfc.c
index 8be8b54..53126f2 100644
--- a/drivers/media/video/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/video/s5p-mfc/s5p_mfc.c
@@ -475,7 +475,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
 			ctx->mv_size = 0;
 		}
 		ctx->dpb_count = s5p_mfc_get_dpb_count();
-		if (ctx->img_width == 0 || ctx->img_width == 0)
+		if (ctx->img_width == 0 || ctx->img_height == 0)
 			ctx->state = MFCINST_ERROR;
 		else
 			ctx->state = MFCINST_HEAD_PARSED;


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

* Re: [PATCH 4/4] drivers/media/video/s5p-mfc/s5p_mfc.c: adjust double test
  2012-01-12 21:33 ` [PATCH 4/4] drivers/media/video/s5p-mfc/s5p_mfc.c: " Julia Lawall
@ 2012-01-13  5:33   ` Kyungmin Park
  0 siblings, 0 replies; 7+ messages in thread
From: Kyungmin Park @ 2012-01-13  5:33 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Kamil Debski, kernel-janitors, linux-kernel,
	Mauro Carvalho Chehab, Jeongtae Park, linux-arm-kernel,
	linux-media, Marek Szyprowski

All patches.

Acked-by: Kyungmin Park <kyungmin.park@samsung.com>

To Marek,
Please collect all patches and send git request pull.

Thank you,
Kyungmin Park

On 1/13/12, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Rewrite a duplicated test to test the correct value
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression E;
> @@
>
> (
> * E
>   || ... || E
> |
> * E
>   && ... && E
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/media/video/s5p-mfc/s5p_mfc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/video/s5p-mfc/s5p_mfc.c
> b/drivers/media/video/s5p-mfc/s5p_mfc.c
> index 8be8b54..53126f2 100644
> --- a/drivers/media/video/s5p-mfc/s5p_mfc.c
> +++ b/drivers/media/video/s5p-mfc/s5p_mfc.c
> @@ -475,7 +475,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx
> *ctx,
>  			ctx->mv_size = 0;
>  		}
>  		ctx->dpb_count = s5p_mfc_get_dpb_count();
> -		if (ctx->img_width == 0 || ctx->img_width == 0)
> +		if (ctx->img_width == 0 || ctx->img_height == 0)
>  			ctx->state = MFCINST_ERROR;
>  		else
>  			ctx->state = MFCINST_HEAD_PARSED;
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

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

* Re: [PATCH 1/4] drivers/staging: adjust double test
  2012-01-12 21:33 ` [PATCH 1/4] drivers/staging: " Julia Lawall
@ 2012-01-18 17:18   ` walter harms
  0 siblings, 0 replies; 7+ messages in thread
From: walter harms @ 2012-01-18 17:18 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Greg Kroah-Hartman, kernel-janitors, devel, linux-kernel



Am 12.01.2012 22:33, schrieb Julia Lawall:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Rewrite a duplicated test to test the correct value
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression E;
> @@
> 
> (
> * E
>   || ... || E
> |
> * E
>   && ... && E
> )
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/staging/gma500/mdfld_dsi_pkg_sender.c |    6 ++----
>  drivers/staging/rtl8192e/rtllib_rx.c          |    2 +-
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
> index 6c5061f..13979b5 100644
> --- a/drivers/staging/rtl8192e/rtllib_rx.c
> +++ b/drivers/staging/rtl8192e/rtllib_rx.c
> @@ -2453,7 +2453,7 @@ static inline void update_network(struct rtllib_network *dst,
>  	if (src->wmm_param[0].ac_aci_acm_aifsn ||
>  	   src->wmm_param[1].ac_aci_acm_aifsn ||
>  	   src->wmm_param[2].ac_aci_acm_aifsn ||
> -	   src->wmm_param[1].ac_aci_acm_aifsn)
> +	   src->wmm_param[3].ac_aci_acm_aifsn)
>  		memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
>  
>  	dst->SignalStrength = src->SignalStrength;
> diff --git a/drivers/staging/gma500/mdfld_dsi_pkg_sender.c b/drivers/staging/gma500/mdfld_dsi_pkg_sender.c
> index 9b96a5c..3a9f44f 100644
> --- a/drivers/staging/gma500/mdfld_dsi_pkg_sender.c
> +++ b/drivers/staging/gma500/mdfld_dsi_pkg_sender.c
> @@ -1249,8 +1249,7 @@ int mdfld_dsi_read_gen_hs(struct mdfld_dsi_pkg_sender *sender,
>  			u32 *data,
>  			u16 len)
>  {
> -	if (!sender || !data || param_num < 0 || param_num > 2
> -		|| !data || !len) {
> +	if (!sender || param_num < 0 || param_num > 2 || !data || !len) {
>  		DRM_ERROR("Invalid parameters\n");
>  		return -EINVAL;
>  	}
> @@ -1267,8 +1266,7 @@ int mdfld_dsi_read_gen_lp(struct mdfld_dsi_pkg_sender *sender,
>  			u32 *data,
>  			u16 len)
>  {
> -	if (!sender || !data || param_num < 0 || param_num > 2
> -		|| !data || !len) {
> +	if (!sender || param_num < 0 || param_num > 2 || !data || !len) {
>  		DRM_ERROR("Invalid parameters\n");
>  		return -EINVAL;
>  	}
> 
> --
Hi,
this is obviously correct but what is about readability ?
would it be an option to break it into two line (or two if) like:
  if (!sender || !data || !len)
	if ( param_num < 0 || param_num > 2 )

re,
 wh



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

end of thread, other threads:[~2012-01-18 17:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-12 21:33 [PATCH 0/4] adjust double test Julia Lawall
2012-01-12 21:33 ` [PATCH 1/4] drivers/staging: " Julia Lawall
2012-01-18 17:18   ` walter harms
2012-01-12 21:33 ` [PATCH 2/4] drivers/media/video/s5p-fimc/fimc-capture.c: " Julia Lawall
2012-01-12 21:33 ` [PATCH 3/4] drivers/dma/amba-pl08x.c: " Julia Lawall
2012-01-12 21:33 ` [PATCH 4/4] drivers/media/video/s5p-mfc/s5p_mfc.c: " Julia Lawall
2012-01-13  5:33   ` Kyungmin Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).