Patchwork caif: cleanup: remove duplicate checks

login
register
mail settings
Submitter Dan Carpenter
Date May 22, 2010, 8:45 p.m.
Message ID <20100522204519.GW22515@bicker>
Download mbox | patch
Permalink /patch/53288/
State Superseded
Delegated to: David Miller
Headers show

Comments

Dan Carpenter - May 22, 2010, 8:45 p.m.
These checks merely duplicate the things we've asserted already.  In the
case of the checks for null we've already dereferenced those variables
as well.

Signed-off-by: Dan Carpenter <error27@gmail.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
walter harms - May 23, 2010, 8:27 a.m.
Dan Carpenter schrieb:
> These checks merely duplicate the things we've asserted already.  In the
> case of the checks for null we've already dereferenced those variables
> as well.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
> index df43f26..cc2f072 100644
> --- a/net/caif/cfcnfg.c
> +++ b/net/caif/cfcnfg.c
> @@ -313,14 +313,10 @@ cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv,
>  	caif_assert(phyinfo->phy_layer != NULL);
>  	caif_assert(phyinfo->phy_layer->id == phyid);
>  
> -	if (phyinfo != NULL &&
> -	    phyinfo->phy_ref_count++ == 0 &&
> -	    phyinfo->phy_layer != NULL &&
> +	if (phyinfo->phy_ref_count++ == 0 &&
>  	    phyinfo->phy_layer->modemcmd != NULL) {
> -		caif_assert(phyinfo->phy_layer->id == phyid);
>  		phyinfo->phy_layer->modemcmd(phyinfo->phy_layer,
>  					     _CAIF_MODEMCMD_PHYIF_USEFULL);
> -
>  	}
>  	adapt_layer->id = channel_id;
>  


hi Dan,
the phyinfo->phy_ref_count++  is very hidden, perhaps in terms of readability
it is better to move the phyinfo->phy_ref_count++ inside.

just my 2 cents,

re,
 wh
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
index df43f26..cc2f072 100644
--- a/net/caif/cfcnfg.c
+++ b/net/caif/cfcnfg.c
@@ -313,14 +313,10 @@  cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv,
 	caif_assert(phyinfo->phy_layer != NULL);
 	caif_assert(phyinfo->phy_layer->id == phyid);
 
-	if (phyinfo != NULL &&
-	    phyinfo->phy_ref_count++ == 0 &&
-	    phyinfo->phy_layer != NULL &&
+	if (phyinfo->phy_ref_count++ == 0 &&
 	    phyinfo->phy_layer->modemcmd != NULL) {
-		caif_assert(phyinfo->phy_layer->id == phyid);
 		phyinfo->phy_layer->modemcmd(phyinfo->phy_layer,
 					     _CAIF_MODEMCMD_PHYIF_USEFULL);
-
 	}
 	adapt_layer->id = channel_id;