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