qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Sascha Silbe <silbe@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PULL 1/2] error: error_setg_errno(): errno gets preserved
Date: Thu, 19 Jan 2017 15:53:56 +0100	[thread overview]
Message-ID: <1484837637-16896-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1484837637-16896-1-git-send-email-armbru@redhat.com>

From: Sascha Silbe <silbe@linux.vnet.ibm.com>

C11 allows errno to be clobbered by pretty much any library function
call, so in general callers need to take care to save errno before
calling other functions.

However, for error reporting functions this is rather awkward and can
make the code on the caller side more complicated than
necessary. error_setg_errno() already takes care of preserving errno
and some functions rely on that, so just promise that we continue to
do so in the future.

Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Message-Id: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qapi/error.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 0576659..7e532d0 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -170,6 +170,9 @@ void error_setg_internal(Error **errp,
  * Just like error_setg(), with @os_error info added to the message.
  * If @os_error is non-zero, ": " + strerror(os_error) is appended to
  * the human-readable error message.
+ *
+ * The value of errno (which usually can get clobbered by almost any
+ * function call) will be preserved.
  */
 #define error_setg_errno(errp, os_error, fmt, ...)                      \
     error_setg_errno_internal((errp), __FILE__, __LINE__, __func__,     \
-- 
2.7.4

  reply	other threads:[~2017-01-19 14:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19 14:53 [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Markus Armbruster
2017-01-19 14:53 ` Markus Armbruster [this message]
2017-01-19 14:53 ` [Qemu-devel] [PULL 2/2] error: Report certain hints on stderr when no monitor Markus Armbruster
2017-01-20 14:04 ` [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Peter Maydell

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=1484837637-16896-2-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=silbe@linux.vnet.ibm.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).