[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/41] util/error: Save errno from clobbering
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 18/41] util/error: Save errno from clobbering |
Date: |
Fri, 29 Nov 2013 17:45:33 +0100 |
From: Max Reitz <address@hidden>
There may be calls to error_setg() and especially error_setg_errno()
which blindly (and until now wrongly) assume these functions not to
clobber errno (e.g., they pass errno to error_setg_errno() and return
-errno afterwards). Instead of trying to find and fix all of these
constructs, just make sure error_setg() and error_setg_errno() indeed do
not clobber errno.
Suggested-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Benoit Canet <address@hidden
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
util/error.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/util/error.c b/util/error.c
index ec0faa6..3ee362a 100644
--- a/util/error.c
+++ b/util/error.c
@@ -27,6 +27,7 @@ void error_set(Error **errp, ErrorClass err_class, const char
*fmt, ...)
{
Error *err;
va_list ap;
+ int saved_errno = errno;
if (errp == NULL) {
return;
@@ -41,6 +42,8 @@ void error_set(Error **errp, ErrorClass err_class, const char
*fmt, ...)
err->err_class = err_class;
*errp = err;
+
+ errno = saved_errno;
}
void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
@@ -49,6 +52,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass
err_class,
Error *err;
char *msg1;
va_list ap;
+ int saved_errno = errno;
if (errp == NULL) {
return;
@@ -69,6 +73,8 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass
err_class,
err->err_class = err_class;
*errp = err;
+
+ errno = saved_errno;
}
void error_setg_file_open(Error **errp, int os_errno, const char *filename)
--
1.8.1.4
- [Qemu-devel] [PULL 08/41] block/raw: copy BlockLimits on raw_open, (continued)
- [Qemu-devel] [PULL 08/41] block/raw: copy BlockLimits on raw_open, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 09/41] block: honour BlockLimits in bdrv_co_do_write_zeroes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 10/41] block: honour BlockLimits in bdrv_co_discard, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 11/41] iscsi: set limits in BlockDriverState, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 12/41] iscsi: simplify iscsi_co_discard, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 13/41] iscsi: add bdrv_co_write_zeroes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 14/41] block: introduce bdrv_make_zero, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 15/41] block/get_block_status: fix BDRV_BLOCK_ZERO for unallocated blocks, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 16/41] qemu-img: add support for fully allocated images, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 17/41] qemu-img: conditionally zero out target on convert, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 18/41] util/error: Save errno from clobbering,
Kevin Wolf <=
- [Qemu-devel] [PULL 19/41] Test coroutine execution order, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 20/41] sheepdog: implement .bdrv_get_allocated_file_size, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 21/41] block/stream: Don't stream unbacked devices, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 22/41] block: per caller dirty bitmap, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 24/41] COW: Speed up writes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 25/41] COW: Extend checking allocated bits to beyond one sector, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 26/41] MAINTAINERS: add sheepdog development mailing list, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 23/41] qapi: Change BlockDirtyInfo to list, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 27/41] qdict: Fix memory leak in qdict_do_flatten(), Kevin Wolf, 2013/11/29