[parted-devel] Problem with Linux "3.0"

H. Peter Anvin hpa at zytor.com
Mon Jun 6 20:17:39 UTC 2011


On 06/05/2011 09:17 AM, Jim Meyering wrote:
> 
> diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> index aeaf98f..111816c 100644
> --- a/libparted/arch/linux.c
> +++ b/libparted/arch/linux.c
> @@ -610,7 +610,11 @@ _get_linux_version ()
> 
>          if (uname (&uts))
>                  return kver = 0;
> -        if (sscanf (uts.release, "%u.%u.%u", &major, &minor, &teeny) != 3)
> +        if (sscanf (uts.release, "%u.%u.%u", &major, &minor, &teeny) == 3)
> +                ; /* ok */
> +        else if (sscanf (uts.release, "%u.%u", &major, &minor) == 2)
> +                teeny = 0;
> +        else
>                  return kver = 0;
> 

How about:

major = minor = teeny = 0;
sscanf(uts.release, "%u.%u.%u", &major, &minor, &teeny);

return kver = KERNEL_VERSION(major, minor, teeny);



More information about the parted-devel mailing list