From 74e05e01e2de46dc817d747c646421125e59d6b1 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 19 Apr 2023 11:42:51 +0200 Subject: [PATCH] x86: parse_real_register() does not alter the parsed string Follow the model of strtol() et al - input string is const-qualified to signal that the string isn't altered, but the returned "end" pointer is not const-qualified, requiring const to be cast away (which generally is a bad idea, but the alternative would be more convoluted code). --- gas/config/tc-i386.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index ea5705da4af..063c9705ddd 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -13750,9 +13750,9 @@ static bool check_register (const reg_entry *r) /* REG_STRING starts *before* REGISTER_PREFIX. */ static const reg_entry * -parse_real_register (char *reg_string, char **end_op) +parse_real_register (const char *reg_string, char **end_op) { - char *s = reg_string; + const char *s = reg_string; char *p; char reg_name_given[MAX_REG_NAME_SIZE + 1]; const reg_entry *r; @@ -13775,7 +13775,7 @@ parse_real_register (char *reg_string, char **end_op) if (is_part_of_name (*s)) return (const reg_entry *) NULL; - *end_op = s; + *end_op = (char *) s; r = (const reg_entry *) str_hash_find (reg_hash, reg_name_given); @@ -13803,7 +13803,7 @@ parse_real_register (char *reg_string, char **end_op) ++s; if (*s == ')') { - *end_op = s + 1; + *end_op = (char *) s + 1; know (r[fpr].reg_num == fpr); return r + fpr; } -- 2.30.2