summaryrefslogtreecommitdiff
path: root/libre-testing/mdadm/repos/core-x86_64/linux-3.0.patch
blob: cd9d5473cd8c418dadfdbba6526bd81d9330ecf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From f161d047eed634b3380262767f955eb888502e88 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Fri, 17 Jun 2011 22:49:24 +1000
Subject: [PATCH 1/1] util: correctly parse shorter linux version numbers.

The next version of Linux might be 3.0.  If it is, get_linux_version
will fail.
So make it more robust.

Reported-by: Namhyung Kim <namhyung@gmail.com>
Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
---
 util.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/util.c b/util.c
index 10bbe56..55d171a 100644
--- a/util.c
+++ b/util.c
@@ -146,16 +146,16 @@ int get_linux_version()
 {
 	struct utsname name;
 	char *cp;
-	int a,b,c;
+	int a = 0, b = 0,c = 0;
 	if (uname(&name) <0)
 		return -1;
 
 	cp = name.release;
 	a = strtoul(cp, &cp, 10);
-	if (*cp != '.') return -1;
-	b = strtoul(cp+1, &cp, 10);
-	if (*cp != '.') return -1;
-	c = strtoul(cp+1, NULL, 10);
+	if (*cp == '.')
+		b = strtoul(cp+1, &cp, 10);
+	if (*cp == '.')
+		c = strtoul(cp+1, &cp, 10);
 
 	return (a*1000000)+(b*1000)+c;
 }
-- 
1.7.2.3