X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fversion.h;h=d7cf68022802a9ea5757641087338f68ea034f61;hp=af61a6f3295996b8d7f160e25fb8e134bbae8751;hb=HEAD;hpb=cf5b38e707b629540b5123124228311a620e3dce diff --git a/utils/mount/version.h b/utils/mount/version.h index af61a6f..d7cf680 100644 --- a/utils/mount/version.h +++ b/utils/mount/version.h @@ -15,16 +15,16 @@ * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA * */ #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 = (unsigned int)atoi(strtok(my_utsname.release, ".")); - q = (unsigned int)atoi(strtok(NULL, ".")); - r = (unsigned int)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); }