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 <ak...@redhat.com>
---
 qemu-img.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
             }
-- 
1.8.3.1


Reply via email to