]> xenbits.xensource.com Git - libvirt.git/commitdiff
fix virParseVersionString with linux 3.0
authorScott Moser <smoser@ubuntu.com>
Fri, 1 Jul 2011 10:40:21 +0000 (06:40 -0400)
committerEric Blake <eblake@redhat.com>
Fri, 1 Jul 2011 13:09:48 +0000 (07:09 -0600)
linux 3.0 has no micro version number, and that is causing problems
for virParseVersionString.  The patch below should allow for:
  major
  major.minor
  major.minor.micro

If major or minor are not present they just default to zero.
We found this in Ubuntu (https://bugs.launchpad.net/bugs/802977)

AUTHORS
src/util/util.c

diff --git a/AUTHORS b/AUTHORS
index 172648e515846a6d698a567e9f87365863d7ffe9..074dace720e6019d1c46348b55c081829643adcb 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -179,6 +179,7 @@ Patches have also been contributed by:
   Daniel Gollub        <gollub@b1-systems.de>
   David S. Wang        <dwang2@cisco.com>
   Ruben Kerkhof        <ruben@rubenkerkhof.com>
+  Scott Moser          <smoser@ubuntu.com>
 
   [....send patches to get your name here....]
 
index 463d2b8eaa1a489327ef3e691344434b8af4589c..da2485998a4f0c0cc9b8bc0eae4d904dbb8ed7e1 100644 (file)
@@ -1598,16 +1598,16 @@ virParseNumber(const char **str)
 int
 virParseVersionString(const char *str, unsigned long *version)
 {
-    unsigned int major, minor, micro;
+    unsigned int major, minor = 0, micro = 0;
     char *tmp;
 
-    if (virStrToLong_ui(str, &tmp, 10, &major) < 0 || *tmp != '.')
+    if (virStrToLong_ui(str, &tmp, 10, &major) < 0)
         return -1;
 
-    if (virStrToLong_ui(tmp + 1, &tmp, 10, &minor) < 0 || *tmp != '.')
+    if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, &minor) < 0)
         return -1;
 
-    if (virStrToLong_ui(tmp + 1, &tmp, 10, &micro) < 0)
+    if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, &micro) < 0)
         return -1;
 
     *version = 1000000 * major + 1000 * minor + micro;