From: Andreas Schwab <schwab@suse.de>
To: Li Xu <xuli1@eswincomputing.com>
Cc: binutils@sourceware.org, kito.cheng@gmail.com, palmer@dabbelt.com
Subject: Re: [PATCH] RISC-V: Add string length check for operands in AS
Date: Tue, 13 Dec 2022 10:07:55 +0100 [thread overview]
Message-ID: <mvmsfhjsmc4.fsf@suse.de> (raw)
In-Reply-To: <20221213043428.33155-1-xuli1@eswincomputing.com> (Li Xu's message of "Tue, 13 Dec 2022 12:34:28 +0800")
On Dez 13 2022, Li Xu wrote:
> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
> index 0682eb35524..b0989e4b124 100644
> --- 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)
There is no need to read through array[i] twice.
if (array[i] != NULL && strncmp (array[i], *s, len) == 0
&& array[i][len] == '\0')
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
next prev parent reply other threads:[~2022-12-13 9:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 4:34 Li Xu
2022-12-13 7:47 ` Jan Beulich
2022-12-13 9:07 ` Andreas Schwab [this message]
2022-12-14 8:06 ` Li Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mvmsfhjsmc4.fsf@suse.de \
--to=schwab@suse.de \
--cc=binutils@sourceware.org \
--cc=kito.cheng@gmail.com \
--cc=palmer@dabbelt.com \
--cc=xuli1@eswincomputing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).