public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: kvx_dis_init
Date: Tue, 22 Aug 2023 09:35:31 +0930	[thread overview]
Message-ID: <ZOP7y8+6yksOVZAK@squeak.grove.modra.org> (raw)

kvx_dis_init currently always returns true, but error conditions do so
by "return -1" which converts to true.  The return status is ignored
anyway, and it doesn't make much sense to error on unexpected arch or
mach:  If print_insn_kvx is called then the atch is known to be kvx,
and it's better to choose some default for a user passing an unknown
mach value rather than segfaulting in decode_insn when env.opc_table
is NULL.

I've chosen the default mach to be bfd_mach_kv3_1, the default in
bfd/cpu-kvx.c, not that it matters very much.  In normal objdump/gdb
usage, info->mach won't be an unexpected value.

	* kvx-dis.c (kvx_dis_init): Return void.  Don't error on
	unexpected arch or mach.  Default to bfd_mach_kv3_1 for
	unknown mach.  Don't clear info->disassembler_options.

diff --git a/opcodes/kvx-dis.c b/opcodes/kvx-dis.c
index eabef4af171..d7b86791c30 100644
--- a/opcodes/kvx-dis.c
+++ b/opcodes/kvx-dis.c
@@ -207,15 +207,9 @@ static struct kvx_dis_env env = {
   .kvx_max_dec_registers = 0
 };
 
-static bool
+static void
 kvx_dis_init (struct disassemble_info *info)
 {
-  if (info->arch != bfd_arch_kvx)
-    {
-      (*info->fprintf_func) (info->stream, "error: Unknown architecture\n");
-      return -1;
-    }
-
   env.kvx_arch_size = 32;
   switch (info->mach)
     {
@@ -224,6 +218,7 @@ kvx_dis_init (struct disassemble_info *info)
       /* fallthrough */
     case bfd_mach_kv3_1_usr:
     case bfd_mach_kv3_1:
+    default:
       env.opc_table = kvx_kv3_v1_optab;
       env.kvx_regfiles = kvx_kv3_v1_regfiles;
       env.kvx_registers = kvx_kv3_v1_registers;
@@ -252,26 +247,14 @@ kvx_dis_init (struct disassemble_info *info)
       env.kvx_modifiers = kvx_kv4_v1_modifiers;
       env.kvx_dec_registers = kvx_kv4_v1_dec_registers;
       break;
-
-    default:
-      /* Core not supported.  */
-      (*info->fprintf_func) (info->stream, "disassembling not supported for "
-			     "this KVX core! (core:%d)", (int) info->mach);
-      return -1;
     }
 
   env.kvx_max_dec_registers = env.kvx_regfiles[KVX_REGFILE_DEC_REGISTERS];
 
   if (info->disassembler_options)
-    {
-      parse_kvx_dis_options (info->disassembler_options);
+    parse_kvx_dis_options (info->disassembler_options);
 
-      /* To avoid repeated parsing of these options, we remove them here.  */
-      info->disassembler_options = NULL;
-    }
   env.initialized_p = 1;
-
-  return env.initialized_p;
 }
 
 static int

-- 
Alan Modra
Australia Development Lab, IBM

                 reply	other threads:[~2023-08-22  0:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOP7y8+6yksOVZAK@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).