34b321
From 931d28d0c1c1015df16fbffb8422895497193a78 Mon Sep 17 00:00:00 2001
34b321
From: Fam Zheng <famz@redhat.com>
34b321
Date: Mon, 15 Feb 2016 09:28:21 +0100
34b321
Subject: [PATCH 08/18] block: vmdk - make ret variable usage clear
34b321
34b321
RH-Author: Fam Zheng <famz@redhat.com>
34b321
Message-id: <1455528511-9357-9-git-send-email-famz@redhat.com>
34b321
Patchwork-id: 69174
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH 08/18] block: vmdk - make ret variable usage clear
34b321
Bugzilla: 1299250
34b321
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
34b321
RH-Acked-by: Max Reitz <mreitz@redhat.com>
34b321
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
34b321
34b321
From: Jeff Cody <jcody@redhat.com>
34b321
34b321
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1299250
34b321
34b321
Keep the variable 'ret' something that is returned by the function it is
34b321
defined in.  For the return value of 'sscanf', use a more meaningful
34b321
variable name.
34b321
34b321
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
Reviewed-by: John Snow <jsnow@redhat.com>
34b321
Signed-off-by: Jeff Cody <jcody@redhat.com>
34b321
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
34b321
(cherry picked from commit 395a22fae064df64d987d703cf70ae0f57306be8)
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 block/vmdk.c | 14 ++++++++------
34b321
 1 file changed, 8 insertions(+), 6 deletions(-)
34b321
34b321
diff --git a/block/vmdk.c b/block/vmdk.c
34b321
index 1247ea4..3351782 100644
34b321
--- a/block/vmdk.c
34b321
+++ b/block/vmdk.c
34b321
@@ -788,6 +788,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
34b321
                               const char *desc_file_path, Error **errp)
34b321
 {
34b321
     int ret;
34b321
+    int matches;
34b321
     char access[11];
34b321
     char type[11];
34b321
     char fname[512];
34b321
@@ -799,6 +800,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
34b321
     BDRVVmdkState *s = bs->opaque;
34b321
     VmdkExtent *extent;
34b321
 
34b321
+
34b321
     while (*p) {
34b321
         /* parse extent line in one of below formats:
34b321
          *
34b321
@@ -808,23 +810,23 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
34b321
          * RW [size in sectors] VMFSSPARSE "file-name.vmdk"
34b321
          */
34b321
         flat_offset = -1;
34b321
-        ret = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
34b321
-                access, &sectors, type, fname, &flat_offset);
34b321
-        if (ret < 4 || strcmp(access, "RW")) {
34b321
+        matches = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
34b321
+                         access, &sectors, type, fname, &flat_offset);
34b321
+        if (matches < 4 || strcmp(access, "RW")) {
34b321
             goto next_line;
34b321
         } else if (!strcmp(type, "FLAT")) {
34b321
-            if (ret != 5 || flat_offset < 0) {
34b321
+            if (matches != 5 || flat_offset < 0) {
34b321
                 error_setg(errp, "Invalid extent lines: \n%s", p);
34b321
                 return -EINVAL;
34b321
             }
34b321
         } else if (!strcmp(type, "VMFS")) {
34b321
-            if (ret == 4) {
34b321
+            if (matches == 4) {
34b321
                 flat_offset = 0;
34b321
             } else {
34b321
                 error_setg(errp, "Invalid extent lines:\n%s", p);
34b321
                 return -EINVAL;
34b321
             }
34b321
-        } else if (ret != 4) {
34b321
+        } else if (matches != 4) {
34b321
             error_setg(errp, "Invalid extent lines:\n%s", p);
34b321
             return -EINVAL;
34b321
         }
34b321
-- 
34b321
1.8.3.1
34b321