qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: kwolf@redhat.com, qemu-trivial@nongnu.org,
	Michael Tokarev <mjt@tls.msk.ru>,
	qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH trivial] block.c: Correct the return value and the failure object when failure occurs
Date: Mon, 23 Jun 2014 15:38:06 +0800	[thread overview]
Message-ID: <20140623073806.GB13485@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <53A59DD1.2020706@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1371 bytes --]

On Sat, Jun 21, 2014 at 10:59:29PM +0800, Chen Gang wrote:
> When failure occurs, 'ret' need be set, or may return 0 to indicate success.
> And error_propagate() also need be called only one time within a function.
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index 74af8d7..12ce4e4 100644
> --- a/block.c
> +++ b/block.c
> @@ -1497,7 +1497,7 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
>      if (snapshot_flags) {
>          bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
>          if (local_err) {
> -            error_propagate(errp, local_err);
> +            ret = -1;
>              goto close_and_fail;
>          }
>      }

The return value of bdrv_open() is a negative errno.  -1 does not make
sense in this case.

Please add an int return value to bdrv_append_temp_snapshot() so the
caller can determine the real errno.  Then the remainder of the patch
can be:

     if (snapshot_flags) {
-        bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
+        ret = bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
         if (local_err) {
-            error_propagate(errp, local_err);
             goto close_and_fail;
         }
     }

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-06-23  7:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-21 14:59 [Qemu-devel] [PATCH trivial] block.c: Correct the return value and the failure object when failure occurs Chen Gang
2014-06-23  7:38 ` Stefan Hajnoczi [this message]
2014-06-23 15:08   ` Chen Gang

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=20140623073806.GB13485@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).