From: John Snow <jsnow@redhat.com>
To: Jeff Cody <jcody@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/6] block: vmdk - make ret variable usage clear
Date: Tue, 20 Jan 2015 13:37:00 -0500 [thread overview]
Message-ID: <54BEA04C.9070304@redhat.com> (raw)
In-Reply-To: <c34dfe0e60b35fa24730ec1cd1ddf2cc064a083a.1421768887.git.jcody@redhat.com>
On 01/20/2015 12:31 PM, Jeff Cody wrote:
> 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.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> 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;
>
> +
Stray newline.
> 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;
> }
>
Reviewed-by: John Snow <jsnow@redhat.com>
next prev parent reply other threads:[~2015-01-20 18:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 17:31 [Qemu-devel] [PATCH v2 0/6] RESEND - Update filename string sizes in block layer Jeff Cody
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 1/6] block: vmdk - make ret variable usage clear Jeff Cody
2015-01-20 18:37 ` John Snow [this message]
2015-01-22 10:56 ` Stefan Hajnoczi
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 2/6] block: vmdk - move string allocations from stack to the heap Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:17 ` Stefan Hajnoczi
2015-01-22 11:23 ` Daniel P. Berrange
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 3/6] block: qapi - move string allocation " Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:24 ` Stefan Hajnoczi
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 4/6] block: " Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:37 ` Stefan Hajnoczi
2015-01-22 12:15 ` Jeff Cody
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 5/6] block: mirror - change string allocation to 2-bytes Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:41 ` Stefan Hajnoczi
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 6/6] block: update string sizes for filename, backing_file, exact_filename Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:46 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54BEA04C.9070304@redhat.com \
--to=jsnow@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.