Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Cc: "Ulrich Müller" <ulm@g.o>
Subject: [gentoo-dev] [PATCH v2 2/2] linux-info.eclass: Replace bit-shift arithmetic by ver_test
Date: Sat, 28 Aug 2021 05:42:56
Message-Id: 20210828054115.28686-2-ulm@gentoo.org
In Reply to: [gentoo-dev] [PATCH v2 1/2] kernel-2.eclass: Replace bit-shift arithmetic by ver_test by "Ulrich Müller"
1 There are kernel versions like 4.9.280, therefore shifting version
2 components by 8 bits in kernel_is() may fail.
3
4 Signed-off-by: Ulrich Müller <ulm@g.o>
5 ---
6 v2: Protect against empty KV_{MAJOR,MINOR,PATCH}
7
8 eclass/linux-info.eclass | 9 +++++----
9 1 file changed, 5 insertions(+), 4 deletions(-)
10
11 diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
12 index 124fb70e78ad..8edd17c317d4 100644
13 --- a/eclass/linux-info.eclass
14 +++ b/eclass/linux-info.eclass
15 @@ -395,7 +395,7 @@ kernel_is() {
16 linux-info_get_any_version
17
18 # Now we can continue
19 - local operator test value
20 + local operator
21
22 case ${1#-} in
23 lt) operator="-lt"; shift;;
24 @@ -407,9 +407,10 @@ kernel_is() {
25 esac
26 [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
27
28 - : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
29 - : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
30 - [ ${test} ${operator} ${value} ]
31 + ver_test \
32 + "${KV_MAJOR:-0}.${KV_MINOR:-0}.${KV_PATCH:-0}" \
33 + "${operator}" \
34 + "${1:-${KV_MAJOR:-0}}.${2:-${KV_MINOR:-0}}.${3:-${KV_PATCH:-0}}"
35 }
36
37 get_localversion() {
38 --
39 2.33.0