get_linux_version_code: don't fail on Linux version strints like "3.0-foo"
authorAndreas Oberritter <obi@opendreambox.org>
Sat, 5 May 2012 15:47:23 +0000 (17:47 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 5 May 2012 15:47:23 +0000 (17:47 +0200)
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/kernel_version.c

index a168a1e4ef2b28dc18b16b70cad36b2f9427f270..738ed022b3bb16313ee6e65b576caef789ae8358 100644 (file)
 int FAST_FUNC get_linux_version_code(void)
 {
        struct utsname name;
-       char *s;
+       char *s, *t;
        int i, r;
 
-       if (uname(&name) == -1) {
-               bb_perror_msg("can't get system information");
-               return 0;
-       }
-
+       uname(&name); /* never fails */
        s = name.release;
        r = 0;
        for (i = 0; i < 3; i++) {
-               r = r * 256 + atoi(strtok(s, "."));
+               t = strtok(s, ".");
+               r = r * 256 + (t ? atoi(t) : 0);
                s = NULL;
        }
        return r;