[libvirt] [PATCH] fix virParseVersionString with linux 3.0

Eric Blake eblake at redhat.com
Fri Jul 1 13:11:45 UTC 2011


On 07/01/2011 04:40 AM, Scott Moser wrote:
> 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)
> 
> diff --git a/src/util/util.c b/src/util/util.c
> index 463d2b8..01848a1 100644
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -1598,17 +1598,17 @@ virParseNumber(const char **str)
>  int
>  virParseVersionString(const char *str, unsigned long *version)
>  {
> -    unsigned int major, minor, micro;
> +    unsigned int major, minor=0, micro=0;

Formatting - we tend to put spaces around operators.

>      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 != '.')
> -        return -1;
> +    if ((*tmp == '.') && virStrToLong_ui(tmp + 1, &tmp, 10, &minor) < 0)
> +            return -1;

Spurious whitespace change in the return statements.

ACK (see my other reply in this thread) and pushed with that fixed, as
well as adding you to AUTHORS (let me know if you prefer any alternate
spellings).

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110701/2e759c3e/attachment-0001.sig>


More information about the libvir-list mailing list