[PATCH] gas/config/tc-score7.c: Use "%s" parameter instead of string parameter in sprintf().

Chen Gang gang.chen.5i5j@gmail.com
Wed Jun 4 10:24:00 GMT 2014


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



More information about the Binutils mailing list