public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] kernel-2.eclass: Replace bit-shift arithmetic by ver_test
@ 2021-08-26  9:40 Ulrich Müller
  2021-08-26  9:40 ` [gentoo-dev] [PATCH 2/3] kernel-2.eclass: Drop useless unset of local variables Ulrich Müller
  2021-08-26  9:40 ` [gentoo-dev] [PATCH 3/3] linux-info.eclass: Replace bit-shift arithmetic by ver_test Ulrich Müller
  0 siblings, 2 replies; 5+ messages in thread
From: Ulrich Müller @ 2021-08-26  9:40 UTC (permalink / raw
  To: gentoo-dev; +Cc: Ulrich Müller

There are kernel versions like 4.9.280, therefore shifting version
components by 8 bits in kernel_is() may fail.

Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 eclass/kernel-2.eclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index 58e0bae94eee..1913942a679b 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -561,7 +561,7 @@ kernel_is() {
 	unset v n
 
 	# Now we can continue
-	local operator test value
+	local operator
 
 	case ${1#-} in
 	  lt) operator="-lt"; shift;;
@@ -573,9 +573,10 @@ kernel_is() {
 	esac
 	[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
 
-	: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
-	: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
-	[ ${test} ${operator} ${value} ]
+	ver_test \
+		"${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" \
+		"${operator}" \
+		"${1:-${KV_MAJOR}}.${2:-${KV_MINOR}}.${3:-${KV_PATCH}}"
 }
 
 # Capture the sources type and set DEPENDs
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-dev] [PATCH 2/3] kernel-2.eclass: Drop useless unset of local variables
  2021-08-26  9:40 [gentoo-dev] [PATCH 1/3] kernel-2.eclass: Replace bit-shift arithmetic by ver_test Ulrich Müller
@ 2021-08-26  9:40 ` Ulrich Müller
  2021-08-26  9:40 ` [gentoo-dev] [PATCH 3/3] linux-info.eclass: Replace bit-shift arithmetic by ver_test Ulrich Müller
  1 sibling, 0 replies; 5+ messages in thread
From: Ulrich Müller @ 2021-08-26  9:40 UTC (permalink / raw
  To: gentoo-dev; +Cc: Ulrich Müller

Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 eclass/kernel-2.eclass | 1 -
 1 file changed, 1 deletion(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index 1913942a679b..4597da4c96bc 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -558,7 +558,6 @@ kernel_is() {
 	local v n=0
 	for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
 	[[ ${n} -eq 1 ]] && detect_version
-	unset v n
 
 	# Now we can continue
 	local operator
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-dev] [PATCH 3/3] linux-info.eclass: Replace bit-shift arithmetic by ver_test
  2021-08-26  9:40 [gentoo-dev] [PATCH 1/3] kernel-2.eclass: Replace bit-shift arithmetic by ver_test Ulrich Müller
  2021-08-26  9:40 ` [gentoo-dev] [PATCH 2/3] kernel-2.eclass: Drop useless unset of local variables Ulrich Müller
@ 2021-08-26  9:40 ` Ulrich Müller
  2021-08-26 13:41   ` Alice
  1 sibling, 1 reply; 5+ messages in thread
From: Ulrich Müller @ 2021-08-26  9:40 UTC (permalink / raw
  To: gentoo-dev; +Cc: Ulrich Müller

There are kernel versions like 4.9.280, therefore shifting version
components by 8 bits in kernel_is() may fail.

Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 eclass/linux-info.eclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index 6da13cc0b2f5..9a112199f4b5 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -395,7 +395,7 @@ kernel_is() {
 	linux-info_get_any_version
 
 	# Now we can continue
-	local operator test value
+	local operator
 
 	case ${1#-} in
 	  lt) operator="-lt"; shift;;
@@ -407,9 +407,10 @@ kernel_is() {
 	esac
 	[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
 
-	: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
-	: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
-	[ ${test} ${operator} ${value} ]
+	ver_test \
+		"${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" \
+		"${operator}" \
+		"${1:-${KV_MAJOR}}.${2:-${KV_MINOR}}.${3:-${KV_PATCH}}"
 }
 
 get_localversion() {
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [gentoo-dev] [PATCH 3/3] linux-info.eclass: Replace bit-shift arithmetic by ver_test
  2021-08-26  9:40 ` [gentoo-dev] [PATCH 3/3] linux-info.eclass: Replace bit-shift arithmetic by ver_test Ulrich Müller
@ 2021-08-26 13:41   ` Alice
  2021-08-26 13:42     ` Alice
  0 siblings, 1 reply; 5+ messages in thread
From: Alice @ 2021-08-26 13:41 UTC (permalink / raw
  To: gentoo-dev, Ulrich Müller


[-- Attachment #1.1.1: Type: text/plain, Size: 1315 bytes --]

On 8/26/21 6:40 PM, Ulrich Müller wrote:
> There are kernel versions like 4.9.280, therefore shifting version
> components by 8 bits in kernel_is() may fail.
> 
> Signed-off-by: Ulrich Müller <ulm@gentoo.org>
> ---
>   eclass/linux-info.eclass | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
> index 6da13cc0b2f5..9a112199f4b5 100644
> --- a/eclass/linux-info.eclass
> +++ b/eclass/linux-info.eclass
> @@ -395,7 +395,7 @@ kernel_is() {
>   	linux-info_get_any_version
>   
>   	# Now we can continue
> -	local operator test value
> +	local operator
>   
>   	case ${1#-} in
>   	  lt) operator="-lt"; shift;;
> @@ -407,9 +407,10 @@ kernel_is() {
>   	esac
>   	[[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
>   
> -	: $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
> -	: $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
> -	[ ${test} ${operator} ${value} ]
> +	ver_test \
> +		"${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" \
> +		"${operator}" \
> +		"${1:-${KV_MAJOR}}.${2:-${KV_MINOR}}.${3:-${KV_PATCH}}"
>   }
>   
>   get_localversion() {
> 

patch 1 and patch 3 looks the same patch.

-- 
Thanks,
Alicef

[-- Attachment #1.1.2: OpenPGP_0x1D6802D75C10FEF6.asc --]
[-- Type: application/pgp-keys, Size: 0 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-dev] [PATCH 3/3] linux-info.eclass: Replace bit-shift arithmetic by ver_test
  2021-08-26 13:41   ` Alice
@ 2021-08-26 13:42     ` Alice
  0 siblings, 0 replies; 5+ messages in thread
From: Alice @ 2021-08-26 13:42 UTC (permalink / raw
  To: gentoo-dev, Ulrich Müller


[-- Attachment #1.1.1: Type: text/plain, Size: 1572 bytes --]

On 8/26/21 10:41 PM, Alice wrote:
> On 8/26/21 6:40 PM, Ulrich Müller wrote:
>> There are kernel versions like 4.9.280, therefore shifting version
>> components by 8 bits in kernel_is() may fail.
>>
>> Signed-off-by: Ulrich Müller <ulm@gentoo.org>
>> ---
>>   eclass/linux-info.eclass | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
>> index 6da13cc0b2f5..9a112199f4b5 100644
>> --- a/eclass/linux-info.eclass
>> +++ b/eclass/linux-info.eclass
>> @@ -395,7 +395,7 @@ kernel_is() {
>>       linux-info_get_any_version
>>       # Now we can continue
>> -    local operator test value
>> +    local operator
>>       case ${1#-} in
>>         lt) operator="-lt"; shift;;
>> @@ -407,9 +407,10 @@ kernel_is() {
>>       esac
>>       [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many 
>> parameters"
>> -    : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
>> -    : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 
>> 8) + ${3:-${KV_PATCH}} ))
>> -    [ ${test} ${operator} ${value} ]
>> +    ver_test \
>> +        "${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" \
>> +        "${operator}" \
>> +        "${1:-${KV_MAJOR}}.${2:-${KV_MINOR}}.${3:-${KV_PATCH}}"
>>   }
>>   get_localversion() {
>>
> 
> patch 1 and patch 3 looks the same patch.
> 
ah just see that the file is different.
Thanks looks good for me.

-- 
Thanks,
Alicef

[-- Attachment #1.1.2: OpenPGP_0x1D6802D75C10FEF6.asc --]
[-- Type: application/pgp-keys, Size: 0 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-26 13:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-26  9:40 [gentoo-dev] [PATCH 1/3] kernel-2.eclass: Replace bit-shift arithmetic by ver_test Ulrich Müller
2021-08-26  9:40 ` [gentoo-dev] [PATCH 2/3] kernel-2.eclass: Drop useless unset of local variables Ulrich Müller
2021-08-26  9:40 ` [gentoo-dev] [PATCH 3/3] linux-info.eclass: Replace bit-shift arithmetic by ver_test Ulrich Müller
2021-08-26 13:41   ` Alice
2021-08-26 13:42     ` Alice

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox