Yilin Yang has uploaded this change for review.

View Change

util/exynos: Port *_cksum.py to python3

BUG=chromium:1023662
TEST=1. Create a tiny file `in.txt` as input
2. Run `fixed_cksum.py in.txt out.txt 20` with py2 and py3 version,
the output is the same
3. Run `variable_cksum.py in.txt out.txt` with py2 and py3 version,
the output is the same

Signed-off-by: Yilin Yang <kerker@google.com>
Change-Id: I9428269dfb826a3a95fffef9ea3f7c1a7107ef84
---
M util/exynos/fixed_cksum.py
M util/exynos/variable_cksum.py
2 files changed, 4 insertions(+), 4 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/45460/1
diff --git a/util/exynos/fixed_cksum.py b/util/exynos/fixed_cksum.py
index c6a9ddae..0ae7e4f 100755
--- a/util/exynos/fixed_cksum.py
+++ b/util/exynos/fixed_cksum.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# SPDX-License-Identifier: BSD-3-Clause

@@ -28,7 +28,7 @@
checksum_size = struct.calcsize(checksum_format)
data_size = size - checksum_size
assert len(data) <= data_size
- checksum = struct.pack(checksum_format, sum(map(ord, data)))
+ checksum = struct.pack(checksum_format, sum(data))
out_file.write(data + bytearray(data_size - len(data)) + checksum)


diff --git a/util/exynos/variable_cksum.py b/util/exynos/variable_cksum.py
index 62a76cc..4321f8e 100755
--- a/util/exynos/variable_cksum.py
+++ b/util/exynos/variable_cksum.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# SPDX-License-Identifier: BSD-3-Clause

@@ -27,7 +27,7 @@
data = in_file.read()
header = struct.pack(header_format,
struct.calcsize(header_format) + len(data),
- sum(map(ord, data)),
+ sum(data),
0, 0)
out_file.write(header + data)


To view, visit change 45460. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I9428269dfb826a3a95fffef9ea3f7c1a7107ef84
Gerrit-Change-Number: 45460
Gerrit-PatchSet: 1
Gerrit-Owner: Yilin Yang <kerker@google.com>
Gerrit-MessageType: newchange