From 6db06f94e19d539bb7001a666e7c52672e0682ea Mon Sep 17 00:00:00 2001 From: George McCollister Date: Thu, 30 Mar 2017 09:44:24 -0500 Subject: patman: Convert byte arrays to strings os.read() returns a byte array in Python 3.5.2 and needs to be converted into a string. Check if the returned value is an instance of bytes and if it is decode it as a utf-8 string. If it is not a utf-8 encoded string the decoding may fail with an exception. Prior to this fix the comparisions check data == "" would fail when data was b'' and would cause an infinite memory leaking loop. joins would also fail with an exception below but due to the infinite loop it never made it that far. Signed-off-by: George McCollister Acked-by: Simon Glass --- tools/patman/cros_subprocess.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools') diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py index ebd4300..7c76014 100644 --- a/tools/patman/cros_subprocess.py +++ b/tools/patman/cros_subprocess.py @@ -190,6 +190,8 @@ class Popen(subprocess.Popen): # We will get an error on read if the pty is closed try: data = os.read(self.stdout.fileno(), 1024) + if isinstance(data, bytes): + data = data.decode('utf-8') except OSError: pass if data == "": @@ -205,6 +207,8 @@ class Popen(subprocess.Popen): # We will get an error on read if the pty is closed try: data = os.read(self.stderr.fileno(), 1024) + if isinstance(data, bytes): + data = data.decode('utf-8') except OSError: pass if data == "": -- cgit v1.1 From f156b5b59750f4140ffa2dd6a5eab686ba0212c3 Mon Sep 17 00:00:00 2001 From: George McCollister Date: Thu, 30 Mar 2017 09:44:25 -0500 Subject: dtoc: Decode val if it's a byte string With Python 3.5.2 encode will throw an exception if val is a byte array. Decode it to a string first. This assumes it's utf-8, if it's not valid utf-8 it will throw an exception. Signed-off-by: George McCollister Acked-by: Simon Glass --- tools/dtoc/fdt_util.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools') diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index e6d523b..b9dfae8 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -24,6 +24,8 @@ def fdt32_to_cpu(val): A native-endian integer value """ if sys.version_info > (3, 0): + if isinstance(val, bytes): + val = val.decode('utf-8') val = val.encode('raw_unicode_escape') return struct.unpack('>I', val)[0] -- cgit v1.1 From c47a38b47770887dc9416382207364fb62899fc2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 2 Apr 2017 12:26:44 -0600 Subject: fdtgrep: Cope with the /aliases node being last With skeleton.dtsi being dropped it is more likely that the /aliases node will be last in the device tree. Update fdtgrep to handle this. Signed-off-by: Simon Glass Tested-by: Masahiro Yamada --- tools/fdtgrep.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'tools') diff --git a/tools/fdtgrep.c b/tools/fdtgrep.c index b907827..e373c43 100644 --- a/tools/fdtgrep.c +++ b/tools/fdtgrep.c @@ -810,9 +810,6 @@ static int do_fdtgrep(struct display_info *disp, const char *filename) disp->flags); if (count < 0) { report_error("fdt_find_regions", count); - if (count == -FDT_ERR_BADLAYOUT) - fprintf(stderr, - "/aliases node must come before all other nodes\n"); return -1; } if (count <= max_regions) -- cgit v1.1 From b48bfc74ee410b1e6681c620633ffef32aafaba0 Mon Sep 17 00:00:00 2001 From: Stefano Babic Date: Wed, 5 Apr 2017 17:46:41 +0200 Subject: tools: allow to override python Not force to use python from PATH. Issue was noted when building with Yocto, because python from the distro is always taken instead of python-native built during Yocto process. Signed-off-by: Stefano Babic CC: Simon Glass Reviewed-by: Simon Glass --- tools/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/Makefile b/tools/Makefile index fa1b85b..2fc4a58 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -120,7 +120,7 @@ _libfdt.so-sharedobjs += $(LIBFDT_OBJS) libfdt: tools/_libfdt.so: $(patsubst %.o,%.c,$(LIBFDT_OBJS)) tools/libfdt_wrap.c - LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= python $(srctree)/lib/libfdt/setup.py \ + LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= ${PYTHON} $(srctree)/lib/libfdt/setup.py \ "$(_hostc_flags)" $^ mv _libfdt.so $@ -- cgit v1.1 From 9a6d2e2a6b0561732e52bd98e71432a7f4e9b3e2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 12 Apr 2017 18:23:26 -0600 Subject: buildman: Handle commit subjects containing unicode One of these has crept in in this commit: 40a808f1 ARCv2: SLC: Make sure busy bit is set properly on SLC flushing Adjust buildman to handle it. Signed-off-by: Simon Glass --- tools/buildman/builder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 236e061..b0ea57e 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -95,8 +95,9 @@ u-boot/ source directory # Possible build outcomes OUTCOME_OK, OUTCOME_WARNING, OUTCOME_ERROR, OUTCOME_UNKNOWN = range(4) -# Translate a commit subject into a valid filename -trans_valid_chars = string.maketrans("/: ", "---") +# Translate a commit subject into a valid filename (and handle unicode) +trans_valid_chars = string.maketrans('/: ', '---') +trans_valid_chars = trans_valid_chars.decode('latin-1') BASE_CONFIG_FILENAMES = [ 'u-boot.cfg', 'u-boot-spl.cfg', 'u-boot-tpl.cfg' -- cgit v1.1