[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/12] block: vmdk - make ret variable usage clear
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 05/12] block: vmdk - make ret variable usage clear |
Date: |
Fri, 23 Jan 2015 19:20:11 +0100 |
From: Jeff Cody <address@hidden>
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 <address@hidden>
Reviewed-by: John Snow <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vmdk.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 52cb888..dc6459c 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -785,6 +785,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];
@@ -796,6 +797,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:
*
@@ -805,23 +807,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
- [Qemu-devel] [PULL 00/12] Block patches, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 01/12] virtio-blk: Pass req to virtio_blk_handle_scsi_req, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 04/12] iotests: Add tests for more corruption cases, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 05/12] block: vmdk - make ret variable usage clear,
Kevin Wolf <=
- [Qemu-devel] [PULL 02/12] virtio-blk: Use blk_aio_ioctl, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 06/12] block: vmdk - move string allocations from stack to the heap, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 03/12] qcow2: Add two more unalignment checks, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 08/12] block: remove unused variable in bdrv_commit, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 11/12] block: vhdx - force FileOffsetMB field to '0' for certain block states, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 12/12] iotests: Lower 064's memory usage, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 09/12] block: mirror - change string allocation to 2-bytes, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 10/12] block: update string sizes for filename, backing_file, exact_filename, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 07/12] block: qapi - move string allocation from stack to the heap, Kevin Wolf, 2015/01/23
- Re: [Qemu-devel] [PULL 00/12] Block patches, Peter Maydell, 2015/01/26