mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
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)
This commit is contained in:
parent
0ac385bd6c
commit
d42b749abf
1
AUTHORS
1
AUTHORS
@ -179,6 +179,7 @@ Patches have also been contributed by:
|
|||||||
Daniel Gollub <gollub@b1-systems.de>
|
Daniel Gollub <gollub@b1-systems.de>
|
||||||
David S. Wang <dwang2@cisco.com>
|
David S. Wang <dwang2@cisco.com>
|
||||||
Ruben Kerkhof <ruben@rubenkerkhof.com>
|
Ruben Kerkhof <ruben@rubenkerkhof.com>
|
||||||
|
Scott Moser <smoser@ubuntu.com>
|
||||||
|
|
||||||
[....send patches to get your name here....]
|
[....send patches to get your name here....]
|
||||||
|
|
||||||
|
@ -1598,16 +1598,16 @@ virParseNumber(const char **str)
|
|||||||
int
|
int
|
||||||
virParseVersionString(const char *str, unsigned long *version)
|
virParseVersionString(const char *str, unsigned long *version)
|
||||||
{
|
{
|
||||||
unsigned int major, minor, micro;
|
unsigned int major, minor = 0, micro = 0;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if (virStrToLong_ui(str, &tmp, 10, &major) < 0 || *tmp != '.')
|
if (virStrToLong_ui(str, &tmp, 10, &major) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virStrToLong_ui(tmp + 1, &tmp, 10, &minor) < 0 || *tmp != '.')
|
if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, &minor) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virStrToLong_ui(tmp + 1, &tmp, 10, µ) < 0)
|
if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, µ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
*version = 1000000 * major + 1000 * minor + micro;
|
*version = 1000000 * major + 1000 * minor + micro;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user