[binutils-gdb] RISC-V: drop dead code from subset parsing

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=de7a82d53376d4652996e38090eccb0dcb9ad01a

commit de7a82d53376d4652996e38090eccb0dcb9ad01a
Author: Jan Beulich <[email protected]>
Date:   Fri Jun 5 11:11:40 2026 +0200

    RISC-V: drop dead code from subset parsing
    
    In riscv_update_subset1(), when explicit_subset is NULL, errmsg_internal
    is the empty string. There's no need then to pass this as an extra
    argument to the error handler.
    
    riscv_parsing_subset_version() can't return NULL. Dropping the respective
    checks clarifies that there is no issue with a missing error message (gas
    would rely on one being emitted when parsing fails).
    
    Reviewed-by: Jiawei <[email protected]>

Diff:
---
 bfd/elfxx-riscv.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index c0439102e8d..b8297ba86f1 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -2141,11 +2141,6 @@ riscv_parse_extensions (riscv_parse_subset_t *rps,
       end_of_version =
 	riscv_parsing_subset_version (q, &major_version, &minor_version);
       *q = '\0';
-      if (end_of_version == NULL)
-	{
-	  free (subset);
-	  return NULL;
-	}
 
       /* Check if the prefixed extension name is well-formed.  */
       if (class != RV_ISA_CLASS_SINGLE
@@ -2700,11 +2695,6 @@ riscv_update_subset1 (riscv_parse_subset_t *rps,
       end_of_version =
 	riscv_parsing_subset_version (q, &major_version, &minor_version);
       *q = '\0';
-      if (end_of_version == NULL)
-	{
-	  free (subset);
-	  return false;
-	}
 
       if (strlen (subset) == 0
 	  || (strlen (subset) == 1
@@ -2725,8 +2715,8 @@ riscv_update_subset1 (riscv_parse_subset_t *rps,
 	  if (removed)
 	    {
 	      rps->error_handler
-		(_("%sdeprecated - extension `%s' in %s `%s'"),
-		   errmsg_internal, subset, errmsg_caller, implicit_exts);
+		(_("deprecated - extension `%s' in %s `%s'"),
+		   subset, errmsg_caller, implicit_exts);
 	      free (subset);
 	      return false;
 	    }
@@ -2735,8 +2725,8 @@ riscv_update_subset1 (riscv_parse_subset_t *rps,
 		   || strcmp (subset, "g") == 0)
 	    {
 	      rps->error_handler
-		(_("%scannot + base extension `%s' in %s `%s'"),
-		   errmsg_internal, subset, errmsg_caller, implicit_exts);
+		(_("cannot + base extension `%s' in %s `%s'"),
+		   subset, errmsg_caller, implicit_exts);
 	      free (subset);
 	      return false;
 	    }
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.