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