From 3a83346fba29bf639432908946def3ef0f10cdf9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 28 Mar 2021 14:42:20 +0000 Subject: [PATCH] scripts/specialize-patch: Clamp sublevel to 255 See also Linux kernel commit 9b82f13e7ef3 ("kbuild: clamp SUBLEVEL to 255"; v5.12-rc1). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9369 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/specialize-patch | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/specialize-patch b/scripts/specialize-patch index ce46d06c6..741759e01 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -31,10 +31,14 @@ # Convert a kernel version in the x.y.z format into numeric form, just like # the KERNEL_VERSION() macro. +function version_number(a, b, c) { + return a * 65536 + b * 256 + (c > 255 ? 255 : c); +} + function version_code(kver, array) { if (!match(kver, "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$", array)) match(kver, "^([0-9]+)\\.([0-9]+)$", array) - return 65536*array[1] + 256*array[2] + array[3] + return version_number(array[1], array[2], array[3]); } @@ -172,7 +176,7 @@ function evaluate(stmnt, pattern, arg, op, result) { pattern="KERNEL_VERSION\\([[:blank:]]*([0-9]+)[[:blank:]]*,[[:blank:]]*([0-9]+)[[:blank:]]*,[[:blank:]]*([0-9]+)[[:blank:]]*\\)" while (match(stmnt, pattern, op) != 0) { - sub(pattern, op[1] * 65536 + op[2] * 256 + op[3], stmnt) + sub(pattern, version_number(op[1], op[2], op[3]), stmnt) } gsub("defined\\(INSIDE_KERNEL_TREE\\)", "1", stmnt)