qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 3/4] sockets: add AF_VSOCK support


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 3/4] sockets: add AF_VSOCK support
Date: Mon, 17 Oct 2016 09:25:46 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

On 10/16/2016 08:35 AM, Stefan Hajnoczi wrote:

>>> +
>>> +    if (sscanf(str, "%32[^:]:%32[^,]%n", cid, port, &n) != 2) {
>>
>> This says stop at the first comma after the colon...
>>
>>> +        error_setg(errp, "error parsing address '%s'", str);
>>> +        return NULL;
>>> +    }
>>> +    if (str[n] != '\0') {
>>> +        error_setg(errp, "trailing characters in address '%s'", str);
>>
>> ...but this rejects a trailing comma.  Is a trailing comma possible base
>> on how QemuOpts work? If so, do you need to handle it here?
> 
> Actually I just wanted to grab characters up until the end of string.
> It wasn't clear from the sscanf(3) man page what the best way to do that
> was, so I kept the comma which is also used in tcp addresses (because
> they support additional comma-separated options).

%32s instead of %32[^,] should grab up to all 32 remaining characters in
the string; your %n trick then ensures there is no garbage.  I guess
it's still a question of whether we want to always treat a comma as
trailing garbage.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]