diff options
author | Borislav Petkov <bp@suse.de> | 2020-11-22 18:11:10 +0100 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2021-03-15 12:21:11 +0100 |
commit | a277ce601cd1c75412a82dfcff547b3173098ef0 (patch) | |
tree | c1fb8cf95dd4720051e03e9d9b29f2cb7b95976b /arch/x86 | |
parent | c7e41b099be40112d53daccef8553e99e455e0d6 (diff) | |
download | linux-stable-a277ce601cd1c75412a82dfcff547b3173098ef0.tar.gz linux-stable-a277ce601cd1c75412a82dfcff547b3173098ef0.tar.bz2 linux-stable-a277ce601cd1c75412a82dfcff547b3173098ef0.zip |
x86/tools/insn_sanity: Convert to insn_decode()
Simplify code, no functional changes.
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210304174237.31945-19-bp@alien8.de
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/tools/insn_sanity.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/tools/insn_sanity.c b/arch/x86/tools/insn_sanity.c index c6a0000ae635..213f35f94feb 100644 --- a/arch/x86/tools/insn_sanity.c +++ b/arch/x86/tools/insn_sanity.c @@ -218,8 +218,8 @@ static void parse_args(int argc, char **argv) int main(int argc, char **argv) { + int insns = 0, ret; struct insn insn; - int insns = 0; int errors = 0; unsigned long i; unsigned char insn_buff[MAX_INSN_SIZE * 2]; @@ -237,15 +237,15 @@ int main(int argc, char **argv) continue; /* Decode an instruction */ - insn_init(&insn, insn_buff, sizeof(insn_buff), x86_64); - insn_get_length(&insn); + ret = insn_decode(&insn, insn_buff, sizeof(insn_buff), + x86_64 ? INSN_MODE_64 : INSN_MODE_32); if (insn.next_byte <= insn.kaddr || insn.kaddr + MAX_INSN_SIZE < insn.next_byte) { /* Access out-of-range memory */ dump_stream(stderr, "Error: Found an access violation", i, insn_buff, &insn); errors++; - } else if (verbose && !insn_complete(&insn)) + } else if (verbose && ret < 0) dump_stream(stdout, "Info: Found an undecodable input", i, insn_buff, &insn); else if (verbose >= 2) dump_insn(stdout, &insn); |