diff mbox

[RESEND] Eliminate extra 'out_free' label from fcoe_init function

Message ID 8e1e75c4-3a80-00c3-2697-37fb1c86f7a1@redhat.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Milan P. Gandhi June 2, 2017, 12:39 p.m. UTC
Simplify the check for return code of fcoe_if_init routine
in fcoe_init function such that we could eliminate need for
extra 'out_free' label and duplicate mutex_unlock statement.

Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
---
 drivers/scsi/fcoe/fcoe.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Walter Harms June 2, 2017, 1:01 p.m. UTC | #1
Am 02.06.2017 14:39, schrieb Milan P. Gandhi:
> Simplify the check for return code of fcoe_if_init routine
> in fcoe_init function such that we could eliminate need for
> extra 'out_free' label and duplicate mutex_unlock statement.
> 
> Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
> ---
>  drivers/scsi/fcoe/fcoe.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> index ea21e7b..a2cf3d0 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -2523,14 +2523,13 @@ static int __init fcoe_init(void)
>  	fcoe_dev_setup();
>  
>  	rc = fcoe_if_init();
> +	mutex_unlock(&fcoe_config_mutex);
> +
>  	if (rc)
> -		goto out_free;
> +		goto out_destroy;
>  
> -	mutex_unlock(&fcoe_config_mutex);
>  	return 0;
>  
if you do that, why not
if (!rc) return 0;

re,
 wh



> -out_free:
> -	mutex_unlock(&fcoe_config_mutex);
>  out_destroy:
>  	destroy_workqueue(fcoe_wq);
>  	return rc;
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Julia Lawall June 2, 2017, 4:06 p.m. UTC | #2
On Fri, 2 Jun 2017, Milan P. Gandhi wrote:

> Simplify the check for return code of fcoe_if_init routine
> in fcoe_init function such that we could eliminate need for
> extra 'out_free' label and duplicate mutex_unlock statement.
>
> Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
> ---
>  drivers/scsi/fcoe/fcoe.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> index ea21e7b..a2cf3d0 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -2523,14 +2523,13 @@ static int __init fcoe_init(void)
>  	fcoe_dev_setup();
>
>  	rc = fcoe_if_init();
> +	mutex_unlock(&fcoe_config_mutex);
> +
>  	if (rc)
> -		goto out_free;
> +		goto out_destroy;
>
> -	mutex_unlock(&fcoe_config_mutex);

That's what I was thinking of, but it's not a RESEND, but rather a v2.
You need to explain under the --- what is the change since the original
submission.

julia

>  	return 0;
>
> -out_free:
> -	mutex_unlock(&fcoe_config_mutex);
>  out_destroy:
>  	destroy_workqueue(fcoe_wq);
>  	return rc;
>
Julia Lawall June 2, 2017, 4:07 p.m. UTC | #3
On Fri, 2 Jun 2017, walter harms wrote:

>
>
> Am 02.06.2017 14:39, schrieb Milan P. Gandhi:
> > Simplify the check for return code of fcoe_if_init routine
> > in fcoe_init function such that we could eliminate need for
> > extra 'out_free' label and duplicate mutex_unlock statement.
> >
> > Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
> > ---
> >  drivers/scsi/fcoe/fcoe.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> > index ea21e7b..a2cf3d0 100644
> > --- a/drivers/scsi/fcoe/fcoe.c
> > +++ b/drivers/scsi/fcoe/fcoe.c
> > @@ -2523,14 +2523,13 @@ static int __init fcoe_init(void)
> >  	fcoe_dev_setup();
> >
> >  	rc = fcoe_if_init();
> > +	mutex_unlock(&fcoe_config_mutex);
> > +
> >  	if (rc)
> > -		goto out_free;
> > +		goto out_destroy;
> >
> > -	mutex_unlock(&fcoe_config_mutex);
> >  	return 0;
> >
> if you do that, why not
> if (!rc) return 0;

I agree with Dan.  If's should be for failures.

julia

>
> re,
>  wh
>
>
>
> > -out_free:
> > -	mutex_unlock(&fcoe_config_mutex);
> >  out_destroy:
> >  	destroy_workqueue(fcoe_wq);
> >  	return rc;
> > --
> > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Dan Carpenter June 3, 2017, 2:34 a.m. UTC | #4
I'm fine with this version...

regards,
dan carpenter
Dan Carpenter June 3, 2017, 2:35 a.m. UTC | #5
On Fri, Jun 02, 2017 at 03:01:29PM +0200, walter harms wrote:
> 
> 
> Am 02.06.2017 14:39, schrieb Milan P. Gandhi:
> > Simplify the check for return code of fcoe_if_init routine
> > in fcoe_init function such that we could eliminate need for
> > extra 'out_free' label and duplicate mutex_unlock statement.
> > 
> > Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
> > ---
> >  drivers/scsi/fcoe/fcoe.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> > index ea21e7b..a2cf3d0 100644
> > --- a/drivers/scsi/fcoe/fcoe.c
> > +++ b/drivers/scsi/fcoe/fcoe.c
> > @@ -2523,14 +2523,13 @@ static int __init fcoe_init(void)
> >  	fcoe_dev_setup();
> >  
> >  	rc = fcoe_if_init();
> > +	mutex_unlock(&fcoe_config_mutex);
> > +
> >  	if (rc)
> > -		goto out_free;
> > +		goto out_destroy;
> >  
> > -	mutex_unlock(&fcoe_config_mutex);
> >  	return 0;
> >  
> if you do that, why not
> if (!rc) return 0;

Gar...  No.  Please don't get creative with the last if statement.

regards,
dan carpenter
Milan P. Gandhi June 5, 2017, 4:12 a.m. UTC | #6
On 06/03/2017 08:04 AM, Dan Carpenter wrote:
> I'm fine with this version...
> 
> regards,
> dan carpenter
> 
Thanks everyone for the review and suggestions!!

Regards,

Milan.
diff mbox

Patch

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index ea21e7b..a2cf3d0 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -2523,14 +2523,13 @@  static int __init fcoe_init(void)
 	fcoe_dev_setup();
 
 	rc = fcoe_if_init();
+	mutex_unlock(&fcoe_config_mutex);
+
 	if (rc)
-		goto out_free;
+		goto out_destroy;
 
-	mutex_unlock(&fcoe_config_mutex);
 	return 0;
 
-out_free:
-	mutex_unlock(&fcoe_config_mutex);
 out_destroy:
 	destroy_workqueue(fcoe_wq);
 	return rc;