Patchwork [PULL,16/36] block: Save errno before error_setg_errno

login
register
mail settings
Submitter Stefan Hajnoczi
Date Nov. 7, 2013, 1:12 p.m.
Message ID <1383829964-32364-17-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/289350/
State New
Headers show

Comments

Stefan Hajnoczi - Nov. 7, 2013, 1:12 p.m.
From: Max Reitz <mreitz@redhat.com>

error_setg_errno() may overwrite errno; therefore, its value should be
read before calling that function and not afterwards.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/block.c b/block.c
index 58efb5b..0e96a22 100644
--- a/block.c
+++ b/block.c
@@ -1084,8 +1084,8 @@  int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
             snprintf(backing_filename, sizeof(backing_filename),
                      "%s", filename);
         } else if (!realpath(filename, backing_filename)) {
-            error_setg_errno(errp, errno, "Could not resolve path '%s'", filename);
             ret = -errno;
+            error_setg_errno(errp, errno, "Could not resolve path '%s'", filename);
             goto fail;
         }