[binutils-gdb] RISC-V: riscv_parse_subset_t's isa_spec is only parser input

Jan Beulich via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=413cf36d8e816f8fbbe30d73e118416281c231e4

commit 413cf36d8e816f8fbbe30d73e118416281c231e4
Author: Jan Beulich <[email protected]>
Date:   Fri Jun 5 11:10:12 2026 +0200

    RISC-V: riscv_parse_subset_t's isa_spec is only parser input
    
    Make the field pointer-to-const and drop indirection from
    riscv_get_default_ext_version(). This way it's more clear that parsing
    won't alter the field.
    
    Reviewed-by: Jiawei <[email protected]>

Diff:
---
 bfd/elfxx-riscv.c | 9 ++++-----
 bfd/elfxx-riscv.h | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 4b3b878d6c7..91337013ba3 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1892,14 +1892,13 @@ riscv_add_subset (riscv_subset_list_t *subset_list,
 /* Get the default versions from the riscv_supported_*ext tables.  */
 
 static void
-riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
+riscv_get_default_ext_version (enum riscv_spec_class default_isa_spec,
 			       const char *name,
 			       int *major_version,
 			       int *minor_version)
 {
   if (name == NULL
-      || default_isa_spec == NULL
-      || *default_isa_spec == ISA_SPEC_CLASS_NONE)
+      || default_isa_spec == ISA_SPEC_CLASS_NONE)
     return;
 
   const struct riscv_supported_ext *table = NULL;
@@ -1919,7 +1918,7 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
     {
       if (strcmp (table[i].name, name) == 0
 	  && (table[i].isa_spec_class == ISA_SPEC_CLASS_DRAFT
-	      || table[i].isa_spec_class == *default_isa_spec))
+	      || table[i].isa_spec_class == default_isa_spec))
 	{
 	  *major_version = table[i].major_version;
 	  *minor_version = table[i].minor_version;
@@ -1945,7 +1944,7 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
 
   if (major_version == RISCV_UNKNOWN_VERSION
        || minor_version == RISCV_UNKNOWN_VERSION)
-    riscv_get_default_ext_version (rps->isa_spec, subset,
+    riscv_get_default_ext_version (*rps->isa_spec, subset,
 				   &major_version, &minor_version);
 
   /* We don't care the versions of the implicit extensions.  */
diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
index 787da041178..2241dc3f8b8 100644
--- a/bfd/elfxx-riscv.h
+++ b/bfd/elfxx-riscv.h
@@ -92,7 +92,7 @@ typedef struct
   void (*error_handler) (const char *,
 			 ...) ATTRIBUTE_PRINTF_1;
   unsigned *xlen;
-  enum riscv_spec_class *isa_spec;
+  const enum riscv_spec_class *isa_spec;
   bool check_unknown_prefixed_ext;
 } riscv_parse_subset_t;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.