qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] error: error_setg_errno(): errno gets preserved
@ 2016-07-27  9:24 Sascha Silbe
  2016-07-27 11:02 ` Markus Armbruster
  2016-07-27 20:42 ` Eric Blake
  0 siblings, 2 replies; 15+ messages in thread
From: Sascha Silbe @ 2016-07-27  9:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Max Reitz, Halil Pasic, Kevin Wolf,
	Cornelia Huck, Michael Roth, Eric Blake

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>
---

Alternative approach to "error: error_setg_errno(): errno may be
clobbered" [1].

[1] mid:1469558699-23314-1-git-send-email-silbe@linux.vnet.ibm.com
    "[Qemu-devel] [PATCH] error: error_setg_errno(): errno may be
    clobbered" by Sascha Silbe <silbe@linux.vnet.ibm.com>, sent on
    2016-07-26.

 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__,     \
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-01-09 21:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-27  9:24 [Qemu-devel] [PATCH] error: error_setg_errno(): errno gets preserved Sascha Silbe
2016-07-27 11:02 ` Markus Armbruster
2016-07-27 20:42 ` Eric Blake
2016-07-28 10:19   ` Markus Armbruster
2016-07-28 10:46     ` Halil Pasic
2016-07-28 14:56       ` Eric Blake
2016-07-28 15:29         ` Halil Pasic
2016-07-28 21:03           ` Eric Blake
2016-07-29 13:38             ` Halil Pasic
2017-01-09 14:50               ` Eric Blake
2017-01-09 18:27                 ` Halil Pasic
2017-01-09 21:13                   ` Eric Blake
2016-07-28 10:35   ` Sascha Silbe
2016-08-05  8:24     ` Markus Armbruster
2017-01-09  9:57       ` Markus Armbruster

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).