All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Carlos L. Torres" <cltorrespr@gmail.com>, qemu-devel@nongnu.org
Cc: stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 5/5] qmp: Add example usage of strto*l() qemu wrapper
Date: Sun, 19 Jul 2015 19:51:00 +0200	[thread overview]
Message-ID: <55ABE384.2040905@redhat.com> (raw)
In-Reply-To: <5b903011386171258cca188ac2b35ae320cdb340.1437263259.git.carlos.torres@rackspace.com>



On 19/07/2015 01:52, Carlos L. Torres wrote:
> +    int err;
>  
>      info->qemu = g_new0(VersionTriple, 1);
> -    info->qemu->major = strtol(version, &tmp, 10);
> +    err = qemu_strtol(version, &tmp, 10, &(info->qemu->major));

There are usually no parentheses around the argument of the & operator.

> +    if (err) {
> +        error_setg(errp, "There was a problem retrieving QEMU major version.");
> +    }

I think it's okay to just assert that err is zero.  Otherwise, this
simple example is okay.  Thanks!

Paolo

>      tmp++;
> -    info->qemu->minor = strtol(tmp, &tmp, 10);
> +
> +    err = qemu_strtol(tmp, &tmp, 10, &(info->qemu->minor));
> +    if (err) {
> +        error_setg(errp, "There was a problem retrieving QEMU minor version.");
> +    }
>      tmp++;
> -    info->qemu->micro = strtol(tmp, &tmp, 10);
> +
> +    err = qemu_strtol(tmp, &tmp, 10, &(info->qemu->micro));
> +    if (err) {
> +        error_setg(errp, "There was a problem retrieving QEMU micro version.");
> +    }

  reply	other threads:[~2015-07-19 17:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-18 23:52 [Qemu-devel] [PATCH v2 0/5] cutils: Add qemu_strto*() wrappers Carlos L. Torres
2015-07-18 23:52 ` [Qemu-devel] [PATCH v2 1/5] cutils: Add qemu_strtol() wrapper Carlos L. Torres
2015-07-18 23:52 ` [Qemu-devel] [PATCH v2 2/5] cutils: Add qemu_strtoul() wrapper Carlos L. Torres
2015-07-18 23:52 ` [Qemu-devel] [PATCH v2 3/5] cutils: Add qemu_strtoll() wrapper Carlos L. Torres
2015-07-18 23:52 ` [Qemu-devel] [PATCH v2 4/5] cutils: Add qemu_strtoull() wrapper Carlos L. Torres
2015-07-18 23:52 ` [Qemu-devel] [PATCH v2 5/5] qmp: Add example usage of strto*l() qemu wrapper Carlos L. Torres
2015-07-19 17:51   ` Paolo Bonzini [this message]
2015-07-19 18:27     ` Carlos L. Torres

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=55ABE384.2040905@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=cltorrespr@gmail.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.