Re: [PATCH 1/1] s390/net: Deletion of unnecessary checks before two function calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I agree with your proposed debug_unregister() changes, but not with your
kfree_fsm() change.

Regards, Ursula Braun

On Fri, 2014-10-31 at 18:40 +0100, SF Markus Elfring wrote:
> The functions debug_unregister() and kfree_fsm() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/s390/net/claw.c      |  6 ++----
>  drivers/s390/net/ctcm_main.c |  6 ++----
>  drivers/s390/net/lcs.c       |  6 ++----
>  drivers/s390/net/netiucv.c   | 12 ++++--------
>  4 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
> index 213e54e..d609ca0 100644
> --- a/drivers/s390/net/claw.c
> +++ b/drivers/s390/net/claw.c
> @@ -109,10 +109,8 @@ static debug_info_t *claw_dbf_trace;
>  static void
>  claw_unregister_debug_facility(void)
>  {
> -	if (claw_dbf_setup)
> -		debug_unregister(claw_dbf_setup);
> -	if (claw_dbf_trace)
> -		debug_unregister(claw_dbf_trace);
> +	debug_unregister(claw_dbf_setup);
> +	debug_unregister(claw_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
> index e056dd4..34dc0f3 100644
> --- a/drivers/s390/net/ctcm_main.c
> +++ b/drivers/s390/net/ctcm_main.c
> @@ -1074,8 +1074,7 @@ static void ctcm_free_netdevice(struct net_device *dev)
>  	if (priv) {
>  		grp = priv->mpcg;
>  		if (grp) {
> -			if (grp->fsm)
> -				kfree_fsm(grp->fsm);
> +			kfree_fsm(grp->fsm);
>  			if (grp->xid_skb)
>  				dev_kfree_skb(grp->xid_skb);
>  			if (grp->rcvd_xid_skb)
> @@ -1672,8 +1671,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
>  		ctcm_free_netdevice(dev);
>  	}
> 
> -	if (priv->fsm)
> -		kfree_fsm(priv->fsm);
> +	kfree_fsm(priv->fsm);
> 
>  	ccw_device_set_offline(cgdev->cdev[1]);
>  	ccw_device_set_offline(cgdev->cdev[0]);
> diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
> index 0a7d87c..5dfa7dd 100644
> --- a/drivers/s390/net/lcs.c
> +++ b/drivers/s390/net/lcs.c
> @@ -88,10 +88,8 @@ static debug_info_t *lcs_dbf_trace;
>  static void
>  lcs_unregister_debug_facility(void)
>  {
> -	if (lcs_dbf_setup)
> -		debug_unregister(lcs_dbf_setup);
> -	if (lcs_dbf_trace)
> -		debug_unregister(lcs_dbf_trace);
> +	debug_unregister(lcs_dbf_setup);
> +	debug_unregister(lcs_dbf_trace);
>  }
> 
>  static int
> diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
> index 0a87809..bdcc3fe 100644
> --- a/drivers/s390/net/netiucv.c
> +++ b/drivers/s390/net/netiucv.c
> @@ -487,12 +487,9 @@ DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
> 
>  static void iucv_unregister_dbf_views(void)
>  {
> -	if (iucv_dbf_setup)
> -		debug_unregister(iucv_dbf_setup);
> -	if (iucv_dbf_data)
> -		debug_unregister(iucv_dbf_data);
> -	if (iucv_dbf_trace)
> -		debug_unregister(iucv_dbf_trace);
> +	debug_unregister(iucv_dbf_setup);
> +	debug_unregister(iucv_dbf_data);
> +	debug_unregister(iucv_dbf_trace);
>  }
>  static int iucv_register_dbf_views(void)
>  {
> @@ -1975,8 +1972,7 @@ static void netiucv_free_netdevice(struct net_device *dev)
>  	if (privptr) {
>  		if (privptr->conn)
>  			netiucv_remove_connection(privptr->conn);
> -		if (privptr->fsm)
> -			kfree_fsm(privptr->fsm);
> +		kfree_fsm(privptr->fsm);
>  		privptr->conn = NULL; privptr->fsm = NULL;
>  		/* privptr gets freed by free_netdev() */
>  	}


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




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux