diff mbox series

[2/5] decodetree: Fix empty input files for varinsnwidth

Message ID 20210413211129.457272-3-luis.pires@eldorado.org.br (mailing list archive)
State New
Headers show
Series Base for adding PowerPC 64-bit instructions | expand

Commit Message

Luis Fernando Fujita Pires April 13, 2021, 9:11 p.m. UTC
Decodetree would throw an error when the input file was empty
and --varinsnwidth was specified.

Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
---
 scripts/decodetree.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Richard Henderson April 14, 2021, 7:47 p.m. UTC | #1
On 4/13/21 2:11 PM, Luis Pires wrote:
> Decodetree would throw an error when the input file was empty
> and --varinsnwidth was specified.
> 
> Signed-off-by: Luis Pires<luis.pires@eldorado.org.br>
> ---
>   scripts/decodetree.py | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


> +        if self.width is not None:
> +            if extracted < self.width:

Is it too ugly to use AND here?


r~
diff mbox series

Patch

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index 4e18f52a65..935b2964e0 100644
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -1178,11 +1178,12 @@  def output_code(self, i, extracted, outerbits, outermask):
         ind = str_indent(i)
 
         # If we need to load more bytes, do so now.
-        if extracted < self.width:
-            output(ind, 'insn = ', decode_function,
-                   '_load_bytes(ctx, insn, {0}, {1});\n'
-                   .format(extracted // 8, self.width // 8));
-            extracted = self.width
+        if self.width is not None:
+            if extracted < self.width:
+                output(ind, 'insn = ', decode_function,
+                       '_load_bytes(ctx, insn, {0}, {1});\n'
+                       .format(extracted // 8, self.width // 8));
+                extracted = self.width
         output(ind, 'return insn;\n')
 # end SizeLeaf