From: Sascha Silbe <silbe@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>,
Halil Pasic <pasic@linux.vnet.ibm.com>,
Kevin Wolf <kwolf@redhat.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH] error: error_setg_errno(): errno may be clobbered
Date: Tue, 26 Jul 2016 20:44:59 +0200 [thread overview]
Message-ID: <1469558699-23314-1-git-send-email-silbe@linux.vnet.ibm.com> (raw)
As a general policy, we want callers to save errno
themselves. error_setg_internal() currently goes out of its way to
preserve errno, so with the API documentation not mentioning it either
way, callers might come to rely on the current behaviour of the
implementation. Spell out that we don't want to make that promise.
Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
---
This came up during review of Halil's patch "block: improve error
handling in raw_open" [1].
[1] mid:1469532873-78542-1-git-send-email-pasic@linux.vnet.ibm.com
"[Qemu-devel] [PATCH v2 1/1] block: improve error handling in
raw_open" by Halil Pasic <pasic@linux.vnet.ibm.com>, sent on
2016-07-26.
include/qapi/error.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/qapi/error.h b/include/qapi/error.h
index 0576659..e5417e9 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -170,6 +170,11 @@ 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.
+ *
+ * Reminder: errno may get clobbered by almost any function call. If
+ * you need the value of errno for another purpose, save it before
+ * invoking error_setg_errno() (or any other function for that
+ * matter).
*/
#define error_setg_errno(errp, os_error, fmt, ...) \
error_setg_errno_internal((errp), __FILE__, __LINE__, __func__, \
--
1.9.1
next reply other threads:[~2016-07-26 18:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-26 18:44 Sascha Silbe [this message]
2016-07-26 18:54 ` [Qemu-devel] [PATCH] error: error_setg_errno(): errno may be clobbered Eric Blake
2016-07-27 8:02 ` Markus Armbruster
2016-07-27 9:26 ` Sascha Silbe
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=1469558699-23314-1-git-send-email-silbe@linux.vnet.ibm.com \
--to=silbe@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=cornelia.huck@de.ibm.com \
--cc=kwolf@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mreitz@redhat.com \
--cc=pasic@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.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 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).