On Fri, Jul 18, 2008 at 07:16:25PM +0100, Daniel P. Berrange wrote:
On Fri, Jul 18, 2008 at 06:02:00PM +0400, Evgeniy Sokolov wrote:
There were several places with parsing container id from code.
Separate function is used now.
Index: src/openvz_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/openvz_conf.c,v
retrieving revision 1.29
diff -u -p -r1.29 openvz_conf.c
--- src/openvz_conf.c 11 Jul 2008 08:56:16 -0000 1.29
+++ src/openvz_conf.c 18 Jul 2008 13:21:07 -0000
@@ -134,9 +134,7 @@ strtoI(const char *str)
val = (int) strtol(str, &endptr, base);
/* Check for various possible errors */
- if ((endptr == str) /* "No digits were found" */
- ||((*endptr != '\0')
- && (*endptr != ' ')) /*"Name contain characters other than integers" */ )
+ if (endptr == str) /* "No digits were found" */
return 0;
return val;
}
I'd not noticed this function before, but it looks like you could
probably just call virStrToLong_i() from the util.h file.
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);
}
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list