qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>,
	qemu-trivial@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno
Date: Sat, 2 Mar 2019 19:12:25 -0600	[thread overview]
Message-ID: <26f2a83e-588a-c26c-86dc-51d5b8170ae9@redhat.com> (raw)
In-Reply-To: <20190302223825.11192-3-philmd@redhat.com>

On 3/2/19 4:38 PM, Philippe Mathieu-Daudé wrote:
> Since 552375088a8, error_set_errno() calls error_setv() which
> already protect errno for clobbering.
> Remove the now unnecessary saved_errno.
> 
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  util/error.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/util/error.c b/util/error.c
> index 934a78e1b1..0402fa1b9d 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -101,14 +101,11 @@ void error_setg_errno_internal(Error **errp,
>                                 int os_errno, const char *fmt, ...)
>  {
>      va_list ap;
> -    int saved_errno = errno;
>  
>      va_start(ap, fmt);
>      error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
>                 os_errno != 0 ? strerror(os_errno) : NULL);
>      va_end(ap);
> -
> -    errno = saved_errno;

NACK. strerror() can clobber errno, so you still need to restore
saved_errno, regardless of what error_setv() does internally.
-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2019-03-03  1:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02 22:38 [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 1/2] util/error: Remove an unnecessary NULL check Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno Philippe Mathieu-Daudé
2019-03-03  1:12   ` Eric Blake [this message]
2019-03-03  2:00     ` Philippe Mathieu-Daudé
2019-03-04 15:36 ` [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Markus Armbruster

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=26f2a83e-588a-c26c-86dc-51d5b8170ae9@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@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).