qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: Chegu Vinod <chegu_vinod@hp.com>,
	qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [Qemu-devel] [PATCH 1/8] cutils: unsigned int parsing functions
Date: Thu, 17 Jan 2013 19:29:17 +0100	[thread overview]
Message-ID: <50F842FD.9060204@redhat.com> (raw)
In-Reply-To: <1358360933-5323-2-git-send-email-ehabkost@redhat.com>

On 01/16/13 19:28, Eduardo Habkost wrote:

> +static void test_parse_uint_negative(void)
> +{
> +    unsigned long long i = 999;
> +    char f = 'X';
> +    char *endptr = &f;
> +    const char *str = " \t -321";
> +    int r;
> +
> +    r = parse_uint(str, &i, &endptr, 0);
> +
> +    g_assert_cmpint(r, ==, -ERANGE);
> +    g_assert_cmpint(i, ==, 0);
> +    g_assert(endptr == str + 3);
> +}

I think it would be more true to the strtol() family if in this case

(a) we reported -EINVAL (invalid subject sequence) -- but I certainly
don't insist on that,

(b) and, independently,

(b1) we either consumed all of the whitespace sequence *and* the subject
sequence (which would be consistent with ERANGE; see
test_parse_uint_overflow()),

(b2) or we didn't consume anything (not even part of the whitespace
sequence). This would be easy to implement and also consistent with the
strtol() family's behavior when it sees an invalid subject sequence:

"If the subject sequence is empty or does not have the expected form, no
conversion is performed; the value of /str/ is stored in the object
pointed to by /endptr/, provided that /endptr/ is not a null pointer."

But I don't insist on (b) either :)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

  reply	other threads:[~2013-01-17 18:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 18:28 [Qemu-devel] [PATCH 0/8] -numa option parsing fixes (v3) Eduardo Habkost
2013-01-16 18:28 ` [Qemu-devel] [PATCH 1/8] cutils: unsigned int parsing functions Eduardo Habkost
2013-01-17 18:29   ` Laszlo Ersek [this message]
2013-01-17 18:50     ` Eduardo Habkost
2013-01-17 19:06       ` [Qemu-devel] [PATCH 1/8 v4] " Eduardo Habkost
2013-01-17 19:25         ` Eduardo Habkost
2013-01-17 19:31         ` Laszlo Ersek
2013-01-17 19:55         ` Eric Blake
2013-01-17 21:04         ` Blue Swirl
2013-01-18 10:01   ` [Qemu-devel] [PATCH 1/8] " Markus Armbruster
2013-01-18 13:26     ` Eduardo Habkost
2013-01-18 13:32       ` Andreas Färber
2013-01-18 17:57       ` [Qemu-devel] [PATCH 1/8 v5] " Eduardo Habkost
2013-01-18 18:11         ` Eric Blake
2013-01-18 19:41           ` [Qemu-devel] [PATCH 1/8 v6] " Eduardo Habkost
2013-01-18 20:20             ` Eric Blake
2013-01-18 18:06       ` [Qemu-devel] [PATCH 1/8] " Markus Armbruster
2013-01-16 18:28 ` [Qemu-devel] [PATCH 2/8] vl.c: Fix off-by-one bug when handling "-numa node" argument Eduardo Habkost
2013-01-16 18:28 ` [Qemu-devel] [PATCH 3/8] vl.c: Abort on unknown -numa option type Eduardo Habkost
2013-01-16 18:28 ` [Qemu-devel] [PATCH 4/8] vl.c: Check for NUMA node limit inside numa_add() Eduardo Habkost
2013-01-16 18:28 ` [Qemu-devel] [PATCH 5/8] vl.c: numa_add(): Validate nodeid before using it Eduardo Habkost
2013-01-16 18:28 ` [Qemu-devel] [PATCH 6/8] vl.c: Use parse_uint_full() for NUMA nodeid Eduardo Habkost
2013-01-16 18:28 ` [Qemu-devel] [PATCH 7/8] vl.c: Extract -numa "cpus" parsing to separate function Eduardo Habkost
2013-01-16 18:28 ` [Qemu-devel] [PATCH 8/8] vl.c: validate -numa "cpus" parameter properly Eduardo Habkost
2013-01-16 20:07 ` [Qemu-devel] [PATCH 0/8] -numa option parsing fixes (v3) Eric Blake
     [not found] ` <20130128165559.GA6849@otherpad.lan.raisama.net>
     [not found]   ` <20130131154227.GH6849@otherpad.lan.raisama.net>
2013-02-01 20:45     ` [Qemu-devel] [PATCH for-1.4 " Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2013-01-16 15:24 [Qemu-devel] [PATCH 0/8] -numa option parsing fixes (v2) Eduardo Habkost
2013-01-16 15:24 ` [Qemu-devel] [PATCH 1/8] cutils: unsigned int parsing functions Eduardo Habkost
2013-01-16 17:10   ` Eric Blake
2013-01-16 17:33     ` Eduardo Habkost
2013-01-16 17:50       ` Eric Blake
2013-01-16 17:56         ` Eduardo Habkost

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=50F842FD.9060204@redhat.com \
    --to=lersek@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=chegu_vinod@hp.com \
    --cc=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).