All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	kernel-janitors@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] drivers/staging: adjust double test
Date: Wed, 18 Jan 2012 17:18:00 +0000	[thread overview]
Message-ID: <4F16FEC8.1080901@bfs.de> (raw)
In-Reply-To: <1326403988-872-2-git-send-email-Julia.Lawall@lip6.fr>



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



WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	kernel-janitors@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] drivers/staging: adjust double test
Date: Wed, 18 Jan 2012 18:18:00 +0100	[thread overview]
Message-ID: <4F16FEC8.1080901@bfs.de> (raw)
In-Reply-To: <1326403988-872-2-git-send-email-Julia.Lawall@lip6.fr>



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



  reply	other threads:[~2012-01-18 17:18 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 21:33 [PATCH 0/4] adjust double test Julia Lawall
2012-01-12 21:33 ` Julia Lawall
2012-01-12 21:33 ` [PATCH 1/4] drivers/staging: " Julia Lawall
2012-01-12 21:33   ` Julia Lawall
2012-01-18 17:18   ` walter harms [this message]
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   ` 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   ` Julia Lawall
2012-01-12 21:33 ` [PATCH 4/4] drivers/media/video/s5p-mfc/s5p_mfc.c: " Julia Lawall
2012-01-12 21:33   ` Julia Lawall
2012-01-12 21:33   ` Julia Lawall
2012-01-13  5:33   ` Kyungmin Park
2012-01-13  5:33     ` Kyungmin Park
2012-01-13  5:33     ` Kyungmin Park
2012-01-12 21:49 ` [PATCH 0/4] " Julia Lawall
2012-01-12 21:49   ` Julia Lawall
2012-01-12 21:49   ` [PATCH v2 1/5] drivers/staging: " Julia Lawall
2012-01-12 21:49     ` Julia Lawall
2012-01-12 21:49   ` [PATCH v2 2/5] drivers/media/video/s5p-fimc/fimc-capture.c: " Julia Lawall
2012-01-12 21:49     ` Julia Lawall
2012-01-12 21:49     ` Julia Lawall
2012-01-12 21:49   ` [PATCH v2 3/5] drivers/dma/amba-pl08x.c: " Julia Lawall
2012-01-12 21:49     ` Julia Lawall
2012-01-31  3:26     ` Vinod Koul
2012-01-31  3:38       ` Vinod Koul
2012-01-12 21:49   ` [PATCH 4/5] drivers/media/video/s5p-mfc/s5p_mfc.c: " Julia Lawall
2012-01-12 21:49     ` Julia Lawall
2012-01-12 21:49     ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F16FEC8.1080901@bfs.de \
    --to=wharms@bfs.de \
    --cc=Julia.Lawall@lip6.fr \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.