From: Jan Beulich Date: Fri, 5 Jun 2026 09:10:12 +0000 (+0200) Subject: RISC-V: riscv_parse_subset_t's isa_spec is only parser input X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=413cf36d8e816f8fbbe30d73e118416281c231e4;p=thirdparty%2Fbinutils-gdb.git 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 --- 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;