qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] error: error_setg_errno(): errno may be clobbered


From: Sascha Silbe
Subject: [Qemu-devel] [PATCH] error: error_setg_errno(): errno may be clobbered
Date: Tue, 26 Jul 2016 20:44:59 +0200

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 <address@hidden>
---

This came up during review of Halil's patch "block: improve error
handling in raw_open" [1].

[1] mid:address@hidden
    "[Qemu-devel] [PATCH v2 1/1] block: improve error handling in
    raw_open" by Halil Pasic <address@hidden>, 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]