From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4272 invoked by alias); 11 Jun 2014 02:41:09 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 4222 invoked by uid 89); 11 Jun 2014 02:41:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Jun 2014 02:41:06 +0000 Received: by mail-pa0-f54.google.com with SMTP id rd3so1374714pab.27 for ; Tue, 10 Jun 2014 19:41:05 -0700 (PDT) X-Received: by 10.68.110.3 with SMTP id hw3mr1331255pbb.144.1402454464895; Tue, 10 Jun 2014 19:41:04 -0700 (PDT) Received: from [192.168.1.23] ([124.127.118.42]) by mx.google.com with ESMTPSA id fv2sm72040854pbd.11.2014.06.10.19.41.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 19:41:04 -0700 (PDT) Message-ID: <5397C1BC.5090800@gmail.com> Date: Wed, 11 Jun 2014 02:41:00 -0000 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Andreas Schwab , amodra@gmail.com, matthew.fortune@imgtec.com, nickc@redhat.com, Pedro Alves CC: binutils@sourceware.org Subject: Re: [PATCH v2] gas/config/tc-score7.c: Use strcpy() instead of sprintf() References: <5390D761.6090906@gmail.com> In-Reply-To: <5390D761.6090906@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2014-06/txt/msg00098.txt.bz2 Hello maintainers: Is this patch OK, please help check it when you have free time, thanks. Originally, I could not find the related Changelog for 'gas', so I did not mark change log for it. Thanks. On 06/06/2014 04:47 AM, Chen Gang wrote: > For several simple string copy operation, strcpy() is better than > sprintf(), so instead of. > > Also can avoid one warning (cross compiler score-elf): > > In file included from ../../binutils-gdb/gas/config/tc-score.c:25:0: > ../../binutils-gdb/gas/config/tc-score7.c: In function ‘s7_parse_pce_inst’: > ../../binutils-gdb/gas/config/tc-score7.c:5340:7: warning: format not a string literal and no format arguments [-Wformat-security] > > > Signed-off-by: Chen Gang > --- > gas/config/tc-score7.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c > index 0a0db2d..4719680 100644 > --- a/gas/config/tc-score7.c > +++ b/gas/config/tc-score7.c > @@ -2795,7 +2795,7 @@ s7_parse_16_32_inst (char *insnstr, bfd_boolean gen_frag_p) > *p = c; > > memset (&s7_inst, '\0', sizeof (s7_inst)); > - sprintf (s7_inst.str, "%s", insnstr); > + strcpy (s7_inst.str, insnstr); > if (opcode) > { > s7_inst.instruction = opcode->value; > @@ -2804,7 +2804,7 @@ s7_parse_16_32_inst (char *insnstr, bfd_boolean gen_frag_p) > s7_inst.size = s7_GET_INSN_SIZE (s7_inst.type); > s7_inst.relax_size = 0; > s7_inst.bwarn = 0; > - sprintf (s7_inst.name, "%s", opcode->template_name); > + strcpy (s7_inst.name, opcode->template_name); > strcpy (s7_inst.reg, ""); > s7_inst.error = NULL; > s7_inst.reloc.type = BFD_RELOC_NONE; > @@ -5308,12 +5308,12 @@ s7_parse_pce_inst (char *insnstr) > p = strstr (insnstr, "||"); > c = *p; > *p = '\0'; > - sprintf (first, "%s", insnstr); > + strcpy (first, insnstr); > > /* Get second part string of PCE. */ > *p = c; > p += 2; > - sprintf (second, "%s", p); > + strcpy (second, p); > > s7_parse_16_32_inst (first, FALSE); > if (s7_inst.error) > @@ -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); > + strcpy (s7_inst.str, insnstr); > return; > } > > -- Chen Gang Open, share, and attitude like air, water, and life which God blessed