[libvirt] [PATCH] parse container id in separate function

Evgeniy Sokolov evg at openvz.org
Mon Jul 21 12:55:04 UTC 2008


> On Mon, Jul 21, 2008 at 03:07:31PM +0400, Evgeniy Sokolov wrote:
>>> On Mon, Jul 21, 2008 at 01:41:27PM +0400, Evgeniy Sokolov wrote:
>>>>> On Fri, Jul 18, 2008 at 07:16:25PM +0100, Daniel P. Berrange wrote:
>>>>> Right, let's reuse it, but I notice we are using strtol() in a lot of
>>>>> places ...openvz driver is not the worse here especially since it has
>>>>> already an encapsulating function.
>>>> I did not know about virStrToLong_i(). Thanks.
>>>> Also, I think it would be convenient to create simple function
>>>>
>>>> int
>>>> virStrToLongSimple_i(const char *str, int *result)
>>>> {
>>>>    char *endptr;
>>>>
>>>>    return virStrToLong_i(str, &endptr, 10, result);
>>>> }
>>> If you don't want to deal wit the  endptr return value, you can simply
>>> pass in NULL for that param.
>> from notes:
>> When END_PTR is NULL, the byte after the final valid digit must be NUL.
>>
>> I don't want to deal the endptr. But I want to parse strings like
>> "   123   abc".
> 
> Why ? Everywhere else in libvirt treats that as mal-formed input and
> rejects it.
> 
Ok. I will follow the same rule.
I rewrited code to parse via virStrToLong_i() function.

patch is attached.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-openvz-strtoi.diff
Type: text/x-patch
Size: 3410 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20080721/9ede6190/attachment-0001.bin>


More information about the libvir-list mailing list