This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] gas/config/tc-score7.c: Use "%s" parameter instead of string parameter in sprintf().
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: amodra at gmail dot com, matthew dot fortune at imgtec dot com, nickc at redhat dot com, binutils at sourceware dot org, palves at redhat dot com
- Date: Wed, 04 Jun 2014 18:23:50 +0800
- Subject: Re: [PATCH] gas/config/tc-score7.c: Use "%s" parameter instead of string parameter in sprintf().
- Authentication-results: sourceware.org; auth=none
- References: <538E72E5 dot 4040503 at gmail dot com> <mvma99tdsxg dot fsf at hawking dot suse dot de>
On 06/04/2014 03:39 PM, Andreas Schwab wrote:
> Chen Gang <gang.chen.5i5j@gmail.com> writes:
>
>> diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c
>> index 0a0db2d..0bae545 100644
>> --- a/gas/config/tc-score7.c
>> +++ b/gas/config/tc-score7.c
>> @@ -5337,7 +5337,7 @@ s7_parse_pce_inst (char *insnstr)
>> || ((pec_part_1.size == s7_INSN16_SIZE) && (s7_inst.size == s7_INSN_SIZE)))
>> {
>> s7_inst.error = _("pce instruction error (16 bit || 16 bit)'");
>> - sprintf (s7_inst.str, insnstr);
>> + sprintf (s7_inst.str, "%s", insnstr);
>
> Just use strcpy.
>
Hmm... originally, I considered about it, but after read the related
code (at line 2798 of this file which still use sprintf()), I followed
the original author's 'habit'.
But for me, strcpy() which you mentioned is better than sprintf() in
this case. And if we use strcpy() instead of this line, we also need use
strcpy() instead of the sprintf() at line 2798.
If no additional reply within 2 days, I shall send patch v2 for it.
Thanks.
--
Chen Gang
Open, share, and attitude like air, water, and life which God blessed