linux-3.0.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From f161d047eed634b3380262767f955eb888502e88 Mon Sep 17 00:00:00 2001
  2. From: NeilBrown <neilb@suse.de>
  3. Date: Fri, 17 Jun 2011 22:49:24 +1000
  4. Subject: [PATCH 1/1] util: correctly parse shorter linux version numbers.
  5. The next version of Linux might be 3.0. If it is, get_linux_version
  6. will fail.
  7. So make it more robust.
  8. Reported-by: Namhyung Kim <namhyung@gmail.com>
  9. Reported-by: Milan Broz <mbroz@redhat.com>
  10. Signed-off-by: NeilBrown <neilb@suse.de>
  11. ---
  12. util.c | 10 +++++-----
  13. 1 files changed, 5 insertions(+), 5 deletions(-)
  14. diff --git a/util.c b/util.c
  15. index 10bbe56..55d171a 100644
  16. --- a/util.c
  17. +++ b/util.c
  18. @@ -146,16 +146,16 @@ int get_linux_version()
  19. {
  20. struct utsname name;
  21. char *cp;
  22. - int a,b,c;
  23. + int a = 0, b = 0,c = 0;
  24. if (uname(&name) <0)
  25. return -1;
  26. cp = name.release;
  27. a = strtoul(cp, &cp, 10);
  28. - if (*cp != '.') return -1;
  29. - b = strtoul(cp+1, &cp, 10);
  30. - if (*cp != '.') return -1;
  31. - c = strtoul(cp+1, NULL, 10);
  32. + if (*cp == '.')
  33. + b = strtoul(cp+1, &cp, 10);
  34. + if (*cp == '.')
  35. + c = strtoul(cp+1, &cp, 10);
  36. return (a*1000000)+(b*1000)+c;
  37. }
  38. --
  39. 1.7.2.3