From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-block@nongnu.org, mitake.hitoshi@lab.ntt.co.jp,
Jeff Cody <jcody@redhat.com>,
qemu-devel@nongnu.org, v.tolstov@selfip.ru, mreitz@redhat.com,
namei.unix@gmail.com
Subject: Re: [Qemu-devel] [PATCH v2 1/1] block/sheepdog: fix argument passed to qemu_strtoul()
Date: Wed, 2 Mar 2016 17:22:08 +0100 [thread overview]
Message-ID: <20160302162208.GE4494@noname.redhat.com> (raw)
In-Reply-To: <56D71109.7060009@redhat.com>
Am 02.03.2016 um 17:12 hat Paolo Bonzini geschrieben:
>
>
> On 02/03/2016 17:09, Jeff Cody wrote:
> > + ret = qemu_strtoul(snapshot_id, NULL, 10, &snap_id);
> > + if (ret) {
> > + error_setg_errno(errp, -ret, "Invalid snapshot ID: %s",
> > + snapshot_id ? snapshot_id : "<null>");
> > + return ret;
> > + }
> > +
> > + if (snap_id > UINT32_MAX) {
> > + error_setg_errno(errp, EINVAL, "Snapshot ID numeric value %" PRId64
> > + " exceeds Sheepdog maximum of %" PRId32, snap_id,
> > + UINT32_MAX);
> > + return -EINVAL;
> > }
>
> I think including the errno produces a worse error message ("Invalid
> snapshot ID: foo: Invalid argument" or something like that)
Yes. Rule of thumb: If you call error_setg_errno() with a constant
errno, there's something wrong.
Kevin
> , and also
> the error should be the same for an id of 10^10 (within uint64_t bounds)
> or 10^30 (outside the bounds). So you could just use
>
> if (ret < 0 || snap_id > UINT32_MAX) {
> error_setg(errp, "Invalid snapshot ID: %s",
> snapshot_id ? snapshot_id : "<null>");
> return -EINVAL;
> }
>
> Thanks,
>
> Paolo
next prev parent reply other threads:[~2016-03-02 16:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 16:09 [Qemu-devel] [PATCH v2 1/1] block/sheepdog: fix argument passed to qemu_strtoul() Jeff Cody
2016-03-02 16:12 ` Jeff Cody
2016-03-02 16:12 ` Paolo Bonzini
2016-03-02 16:22 ` Kevin Wolf [this message]
2016-03-02 16:27 ` Jeff Cody
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=20160302162208.GE4494@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=jcody@redhat.com \
--cc=mitake.hitoshi@lab.ntt.co.jp \
--cc=mreitz@redhat.com \
--cc=namei.unix@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=v.tolstov@selfip.ru \
/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.