diff mbox

qemu-img: re-assign ret after reporting original error

Message ID 1384320296-22812-1-git-send-email-akong@redhat.com
State New
Headers show

Commit Message

Amos Kong Nov. 13, 2013, 5:24 a.m. UTC
Currently the output error is always:
  strerror(-4) -> Unknown error -4

This patch moves ret assignment after reporting original error.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 qemu-img.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kevin Wolf Nov. 13, 2013, 9:25 a.m. UTC | #1
Am 13.11.2013 um 06:24 hat Amos Kong geschrieben:
> Currently the output error is always:
>   strerror(-4) -> Unknown error -4
> 
> This patch moves ret assignment after reporting original error.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>

Fam and Amos, can you consolidate the fixes in one patch, and update the
test case in the same patch as well?

Kevin
diff mbox

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 926f0a0..1fd664f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1045,9 +1045,9 @@  static int img_compare(int argc, char **argv)
             }
             if (ret) {
                 if (ret < 0) {
-                    ret = 4;
                     error_report("Error while reading offset %" PRId64 ": %s",
                                  sectors_to_bytes(sector_num), strerror(-ret));
+                    ret = 4;
                 }
                 goto out;
             }