diff options
author | Scott Moser <smoser@ubuntu.com> | 2011-07-01 06:40:21 -0400 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2011-07-01 07:09:48 -0600 |
commit | d42b749abfc147b6503ce71f773ffa2742d5ea66 (patch) | |
tree | d0cb5141c4b820a9fe3757ad722d262ee5cdbf67 | |
parent | build: remove dead variables (diff) | |
download | libvirt-d42b749abfc147b6503ce71f773ffa2742d5ea66.tar.gz libvirt-d42b749abfc147b6503ce71f773ffa2742d5ea66.tar.bz2 libvirt-d42b749abfc147b6503ce71f773ffa2742d5ea66.zip |
fix virParseVersionString with linux 3.0
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)
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | src/util/util.c | 8 |
2 files changed, 5 insertions, 4 deletions
@@ -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....] diff --git a/src/util/util.c b/src/util/util.c index 463d2b8ea..da2485998 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -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, µ) < 0) + if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, µ) < 0) return -1; *version = 1000000 * major + 1000 * minor + micro; |