summaryrefslogtreecommitdiff
path: root/libbb/kernel_version.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/kernel_version.c')
-rw-r--r--libbb/kernel_version.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/libbb/kernel_version.c b/libbb/kernel_version.c
index 7769a09..6bb32ce 100644
--- a/libbb/kernel_version.c
+++ b/libbb/kernel_version.c
@@ -19,15 +19,17 @@ int FAST_FUNC get_linux_version_code(void)
{
struct utsname name;
char *t;
- int i, r;
+ int r;
uname(&name); /* never fails */
- t = name.release;
- r = 0;
- for (i = 0; i < 3; i++) {
- t = strtok(t, ".");
- r = r * 256 + (t ? atoi(t) : 0);
- t = NULL;
- }
- return r;
+ t = name.release - 1;
+ r = 1;
+ do {
+ r <<= 8;
+ if (t) {
+ r += atoi(++t);
+ t = strchr(t, '.');
+ }
+ } while (r < 0x1000000);
+ return r - 0x1000000;
}