提交 395a22fa 编写于 作者: J Jeff Cody 提交者: Kevin Wolf

block: vmdk - make ret variable usage clear

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: NStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: NJohn Snow <jsnow@redhat.com>
Signed-off-by: NJeff Cody <jcody@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 f30136b3
...@@ -785,6 +785,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, ...@@ -785,6 +785,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
const char *desc_file_path, Error **errp) const char *desc_file_path, Error **errp)
{ {
int ret; int ret;
int matches;
char access[11]; char access[11];
char type[11]; char type[11];
char fname[512]; char fname[512];
...@@ -796,6 +797,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, ...@@ -796,6 +797,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
BDRVVmdkState *s = bs->opaque; BDRVVmdkState *s = bs->opaque;
VmdkExtent *extent; VmdkExtent *extent;
while (*p) { while (*p) {
/* parse extent line in one of below formats: /* parse extent line in one of below formats:
* *
...@@ -805,23 +807,23 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, ...@@ -805,23 +807,23 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
* RW [size in sectors] VMFSSPARSE "file-name.vmdk" * RW [size in sectors] VMFSSPARSE "file-name.vmdk"
*/ */
flat_offset = -1; flat_offset = -1;
ret = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64, matches = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
access, &sectors, type, fname, &flat_offset); access, &sectors, type, fname, &flat_offset);
if (ret < 4 || strcmp(access, "RW")) { if (matches < 4 || strcmp(access, "RW")) {
goto next_line; goto next_line;
} else if (!strcmp(type, "FLAT")) { } 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); error_setg(errp, "Invalid extent lines: \n%s", p);
return -EINVAL; return -EINVAL;
} }
} else if (!strcmp(type, "VMFS")) { } else if (!strcmp(type, "VMFS")) {
if (ret == 4) { if (matches == 4) {
flat_offset = 0; flat_offset = 0;
} else { } else {
error_setg(errp, "Invalid extent lines:\n%s", p); error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL; return -EINVAL;
} }
} else if (ret != 4) { } else if (matches != 4) {
error_setg(errp, "Invalid extent lines:\n%s", p); error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册