[PATCH] RISC-V: Add string length check for operands in AS
Jan Beulich
jbeulich@suse.com
Tue Dec 13 07:47:17 GMT 2022
On 13.12.2022 05:34, Li Xu wrote:
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -1206,7 +1206,7 @@ arg_lookup (char **s, const char *const *array, size_t size, unsigned *regnop)
> return false;
>
> for (i = 0; i < size; i++)
> - if (array[i] != NULL && strncmp (array[i], *s, len) == 0)
> + if (array[i] != NULL && (strlen(array[i]) == len) && strncmp (array[i], *s, len) == 0)
A couple of remarks: First of all this looks like another case where
startswith() might better be used. And then style aspects: There's
a blank missing after "strlen", and you will want to be consistent
with the use of parentheses: Both pre-existing comparisons aren't
wrapped in any, so any new one shouldn't be either (or, less desirably
imo, all three should be). Plus finally the resulting line is overly
long.
Jan
More information about the Binutils
mailing list