qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block: Save errno before error_setg_errno
Date: Tue, 05 Nov 2013 12:26:41 -0700	[thread overview]
Message-ID: <52794671.7000001@redhat.com> (raw)
In-Reply-To: <1383678213-2497-1-git-send-email-mreitz@redhat.com>

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

On 11/05/2013 12:03 PM, Max Reitz wrote:
> error_setg_errno() may overwrite errno; therefore, its value should be
> read before calling that function and not afterwards.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

Still, wouldn't it be easier to patch error_setg_errno (and friends) to
guarantee that errno is unchanged on exit compared to its value on
entrance, rather than having to audit for other mistakes like this?

> 
> diff --git a/block.c b/block.c
> index 58efb5b..0e96a22 100644
> --- a/block.c
> +++ b/block.c
> @@ -1084,8 +1084,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
>              snprintf(backing_filename, sizeof(backing_filename),
>                       "%s", filename);
>          } else if (!realpath(filename, backing_filename)) {
> -            error_setg_errno(errp, errno, "Could not resolve path '%s'", filename);
>              ret = -errno;
> +            error_setg_errno(errp, errno, "Could not resolve path '%s'", filename);
>              goto fail;
>          }
>  
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

  reply	other threads:[~2013-11-05 19:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 19:03 [Qemu-devel] [PATCH] block: Save errno before error_setg_errno Max Reitz
2013-11-05 19:26 ` Eric Blake [this message]
2013-11-06 10:32   ` Stefan Hajnoczi
2013-11-05 20:04 ` Benoît Canet
2013-11-06 10:32 ` Stefan Hajnoczi

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=52794671.7000001@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@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).