X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fversion.h;h=531cf68d257f13c8f569883195ab4c0bbb207d66;hp=46552a1775be5682b602a85e30f3d25823d118dd;hb=0062bea7159b3c7516d4d361ef1244d727231936;hpb=d5a09b59916d4ef24b15e34eac394149cb7a641a diff --git a/utils/mount/version.h b/utils/mount/version.h index 46552a1..531cf68 100644 --- a/utils/mount/version.h +++ b/utils/mount/version.h @@ -23,8 +23,8 @@ #ifndef _NFS_UTILS_MOUNT_VERSION_H #define _NFS_UTILS_MOUNT_VERSION_H -#include -#include +#include +#include #include @@ -37,14 +37,16 @@ static inline unsigned int MAKE_VERSION(unsigned int p, unsigned int q, static inline unsigned int linux_version_code(void) { struct utsname my_utsname; - unsigned int p, q, r; + unsigned int p, q = 0, r = 0; + /* UINT_MAX as backward compatibility code should not be run */ if (uname(&my_utsname)) - return 0; + return UINT_MAX; - p = atoi(strtok(my_utsname.release, ".")); - q = atoi(strtok(NULL, ".")); - r = atoi(strtok(NULL, ".")); + /* UINT_MAX as future versions might not start with an integer */ + if (sscanf(my_utsname.release, "%u.%u.%u", &p, &q, &r) < 1) + return UINT_MAX; + return MAKE_VERSION(p, q, r); }