All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: pbonzini@redhat.com, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 2/2] virtio-scsi: reorder the goto label in init()
Date: Fri, 08 Mar 2013 11:06:51 +1100	[thread overview]
Message-ID: <87mwuewy90.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1362626968-16871-2-git-send-email-gaowanlong@cn.fujitsu.com>

Wanlong Gao <gaowanlong@cn.fujitsu.com> writes:
> Reorder the goto label in init() to make it more clearly, and remove
> the useless NULL pointer reassignment.
>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

These both require Paulo's Ack...

> ---
>  drivers/scsi/virtio_scsi.c | 27 +++++++++++----------------
>  1 file changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index f679b8c..55dfb06 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -774,32 +774,27 @@ static int __init init(void)
>  	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
>  	if (!virtscsi_cmd_cache) {
>  		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
> -		goto error;
> +		return ret;

I mildly prefer the former (or perhaps renamed to "goto out" to match
the other labels.

>  	}
>  
> -
> -	virtscsi_cmd_pool =
> -		mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
> -					 virtscsi_cmd_cache);
> +	virtscsi_cmd_pool = mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
> +						     virtscsi_cmd_cache);
>  	if (!virtscsi_cmd_pool) {
>  		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
> -		goto error;
> +		goto out_destroy_cache;
>  	}
> +
>  	ret = register_virtio_driver(&virtio_scsi_driver);
>  	if (ret < 0)
> -		goto error;
> +		goto out_destroy_pool;
>  
>  	return 0;
>  
> -error:
> -	if (virtscsi_cmd_pool) {
> -		mempool_destroy(virtscsi_cmd_pool);
> -		virtscsi_cmd_pool = NULL;
> -	}
> -	if (virtscsi_cmd_cache) {
> -		kmem_cache_destroy(virtscsi_cmd_cache);
> -		virtscsi_cmd_cache = NULL;
> -	}
> +out_destroy_pool:
> +	mempool_destroy(virtscsi_cmd_pool);
> +out_destroy_cache:
> +	kmem_cache_destroy(virtscsi_cmd_cache);
> +
>  	return ret;
>  }
>  
> -- 
> 1.8.2.rc2

Cheers,
Rusty.

  reply	other threads:[~2013-03-08  0:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07  3:29 [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Wanlong Gao
2013-03-07  3:29 ` [PATCH 2/2] virtio-scsi: reorder the goto label in init() Wanlong Gao
2013-03-08  0:06   ` Rusty Russell [this message]
2013-03-08  1:11     ` [PATCH V2 " Wanlong Gao
2013-03-08  9:48 ` [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Paolo Bonzini
2013-03-08 10:00   ` Wanlong Gao
2013-03-12  3:43   ` Rusty Russell

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=87mwuewy90.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=pbonzini@redhat.com \
    --cc=virtualization@lists.linux-foundation.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.