All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/signrom: remove Python 2 support, add shebang
@ 2020-02-04 16:00 Paolo Bonzini
  2020-02-04 16:02 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2020-02-04 16:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé

Based-on: <20200130163232.10446-1-philmd@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/signrom.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/scripts/signrom.py b/scripts/signrom.py
index 313ee28a17..9be5dab1cf 100644
--- a/scripts/signrom.py
+++ b/scripts/signrom.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
 from __future__ import print_function
 #
 # Option ROM signing utility
@@ -44,14 +46,8 @@ fout.write(data)
 
 checksum = 0
 for b in data:
-    # catch Python 2 vs. 3 differences
-    if isinstance(b, int):
-        checksum += b
-    else:
-        checksum += ord(b)
-checksum = (256 - checksum) % 256
-
-# Python 3 no longer allows chr(checksum)
+    checksum = (checksum - b) & 255
+
 fout.write(struct.pack('B', checksum))
 
 fin.close()
-- 
2.21.0



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

* Re: [PATCH] scripts/signrom: remove Python 2 support, add shebang
  2020-02-04 16:00 [PATCH] scripts/signrom: remove Python 2 support, add shebang Paolo Bonzini
@ 2020-02-04 16:02 ` Philippe Mathieu-Daudé
  2020-02-04 16:07   ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-04 16:02 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 2/4/20 5:00 PM, Paolo Bonzini wrote:
> Based-on: <20200130163232.10446-1-philmd@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   scripts/signrom.py | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/signrom.py b/scripts/signrom.py
> index 313ee28a17..9be5dab1cf 100644
> --- a/scripts/signrom.py
> +++ b/scripts/signrom.py
> @@ -1,3 +1,5 @@
> +#!/usr/bin/env python3
> +
>   from __future__ import print_function
>   #
>   # Option ROM signing utility
> @@ -44,14 +46,8 @@ fout.write(data)
>   
>   checksum = 0
>   for b in data:
> -    # catch Python 2 vs. 3 differences
> -    if isinstance(b, int):
> -        checksum += b
> -    else:
> -        checksum += ord(b)
> -checksum = (256 - checksum) % 256
> -
> -# Python 3 no longer allows chr(checksum)
> +    checksum = (checksum - b) & 255
> +
>   fout.write(struct.pack('B', checksum))
>   
>   fin.close()
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Also, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next



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

* Re: [PATCH] scripts/signrom: remove Python 2 support, add shebang
  2020-02-04 16:02 ` Philippe Mathieu-Daudé
@ 2020-02-04 16:07   ` Paolo Bonzini
  2020-02-04 16:11     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2020-02-04 16:07 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 04/02/20 17:02, Philippe Mathieu-Daudé wrote:
> On 2/4/20 5:00 PM, Paolo Bonzini wrote:
>> Based-on: <20200130163232.10446-1-philmd@redhat.com>
>> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   scripts/signrom.py | 12 ++++--------
>>   1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/scripts/signrom.py b/scripts/signrom.py
>> index 313ee28a17..9be5dab1cf 100644
>> --- a/scripts/signrom.py
>> +++ b/scripts/signrom.py
>> @@ -1,3 +1,5 @@
>> +#!/usr/bin/env python3
>> +
>>   from __future__ import print_function
>>   #
>>   # Option ROM signing utility
>> @@ -44,14 +46,8 @@ fout.write(data)
>>     checksum = 0
>>   for b in data:
>> -    # catch Python 2 vs. 3 differences
>> -    if isinstance(b, int):
>> -        checksum += b
>> -    else:
>> -        checksum += ord(b)
>> -checksum = (256 - checksum) % 256
>> -
>> -# Python 3 no longer allows chr(checksum)
>> +    checksum = (checksum - b) & 255
>> +
>>   fout.write(struct.pack('B', checksum))
>>     fin.close()
>>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> Also, applied to my python-next tree:
> https://gitlab.com/philmd/qemu/commits/python-next

Oh, good.  So I've unqueued your series on which this is based.

Paolo



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

* Re: [PATCH] scripts/signrom: remove Python 2 support, add shebang
  2020-02-04 16:07   ` Paolo Bonzini
@ 2020-02-04 16:11     ` Philippe Mathieu-Daudé
  2020-02-04 16:18       ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-04 16:11 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 2/4/20 5:07 PM, Paolo Bonzini wrote:
> On 04/02/20 17:02, Philippe Mathieu-Daudé wrote:
>> On 2/4/20 5:00 PM, Paolo Bonzini wrote:
>>> Based-on: <20200130163232.10446-1-philmd@redhat.com>
>>> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> ---
>>>    scripts/signrom.py | 12 ++++--------
>>>    1 file changed, 4 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/scripts/signrom.py b/scripts/signrom.py
>>> index 313ee28a17..9be5dab1cf 100644
>>> --- a/scripts/signrom.py
>>> +++ b/scripts/signrom.py
>>> @@ -1,3 +1,5 @@
>>> +#!/usr/bin/env python3
>>> +
>>>    from __future__ import print_function
>>>    #
>>>    # Option ROM signing utility
>>> @@ -44,14 +46,8 @@ fout.write(data)
>>>      checksum = 0
>>>    for b in data:
>>> -    # catch Python 2 vs. 3 differences
>>> -    if isinstance(b, int):
>>> -        checksum += b
>>> -    else:
>>> -        checksum += ord(b)
>>> -checksum = (256 - checksum) % 256
>>> -
>>> -# Python 3 no longer allows chr(checksum)
>>> +    checksum = (checksum - b) & 255
>>> +
>>>    fout.write(struct.pack('B', checksum))
>>>      fin.close()
>>>
>>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> Also, applied to my python-next tree:
>> https://gitlab.com/philmd/qemu/commits/python-next
> 
> Oh, good.  So I've unqueued your series on which this is based.

Aargh I received your "series queued" mail _after_ this patch.

As you prefer, but I have various python patches pending already.
If I keep "Explicit usage of Python 3" do you mind Acking it?

Thanks!

Phil.



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

* Re: [PATCH] scripts/signrom: remove Python 2 support, add shebang
  2020-02-04 16:11     ` Philippe Mathieu-Daudé
@ 2020-02-04 16:18       ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2020-02-04 16:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 04/02/20 17:11, Philippe Mathieu-Daudé wrote:
>>>>
>>>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>
>>> Also, applied to my python-next tree:
>>> https://gitlab.com/philmd/qemu/commits/python-next
>>
>> Oh, good.  So I've unqueued your series on which this is based.
> 
> Aargh I received your "series queued" mail _after_ this patch.
> 
> As you prefer, but I have various python patches pending already.
> If I keep "Explicit usage of Python 3" do you mind Acking it?

Sure, the least patches I queue the better.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo



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

* [PATCH] scripts/signrom: remove Python 2 support, add shebang
@ 2020-02-04 15:58 Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2020-02-04 15:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/signrom.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/scripts/signrom.py b/scripts/signrom.py
index 313ee28a17..9be5dab1cf 100644
--- a/scripts/signrom.py
+++ b/scripts/signrom.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
 from __future__ import print_function
 #
 # Option ROM signing utility
@@ -44,14 +46,8 @@ fout.write(data)
 
 checksum = 0
 for b in data:
-    # catch Python 2 vs. 3 differences
-    if isinstance(b, int):
-        checksum += b
-    else:
-        checksum += ord(b)
-checksum = (256 - checksum) % 256
-
-# Python 3 no longer allows chr(checksum)
+    checksum = (checksum - b) & 255
+
 fout.write(struct.pack('B', checksum))
 
 fin.close()
-- 
2.21.0



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

end of thread, other threads:[~2020-02-04 16:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 16:00 [PATCH] scripts/signrom: remove Python 2 support, add shebang Paolo Bonzini
2020-02-04 16:02 ` Philippe Mathieu-Daudé
2020-02-04 16:07   ` Paolo Bonzini
2020-02-04 16:11     ` Philippe Mathieu-Daudé
2020-02-04 16:18       ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2020-02-04 15:58 Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.