From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11137 invoked by alias); 23 Feb 2011 08:59:54 -0000 Received: (qmail 11040 invoked by uid 22791); 23 Feb 2011 08:59:52 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qw0-f41.google.com (HELO mail-qw0-f41.google.com) (209.85.216.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Feb 2011 08:59:47 +0000 Received: by qwd7 with SMTP id 7so3571247qwd.0 for ; Wed, 23 Feb 2011 00:59:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.215.70 with SMTP id hd6mr2849395qcb.102.1298451585523; Wed, 23 Feb 2011 00:59:45 -0800 (PST) Received: by 10.229.89.197 with HTTP; Wed, 23 Feb 2011 00:59:45 -0800 (PST) In-Reply-To: <4D63D49D.90101@redhat.com> References: <-8460070221060995487@unknownmsgid> <-6930711422310680743@unknownmsgid> <4D63D49D.90101@redhat.com> Date: Wed, 23 Feb 2011 08:59:00 -0000 Message-ID: Subject: Re: [RFC patch]: Adjust the use of 'long' type in dwarf2.h header From: Kai Tietz To: Nick Clifton Cc: Pierre Muller , GCC Patches , Binutils , gdb , Jakub Jelinek , Joel Brobecker Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 X-SW-Source: 2011-02/txt/msg00279.txt.bz2 2011/2/22 Nick Clifton : > Hi Kai, > > >> So this version uses new function dwarf_vma_print function for >> printf-messages, which are getting localized. >> >> Tested for x86_64-w64-mingw32 and x86_64-pc-linux-gnu. Ok for apply? > >> +static const char * >> +dwarf_vma_print (const char *fmtch, bfd_vma value) > > I think that I prefer your suggestion of dwarf_vmatoa. > >> +{ >> + =A0static int buf_pos =3D 0; >> + =A0static struct dwarf_vma_print_buf { >> + =A0 =A0char place[64]; >> + =A0} buf[16]; > > Ideally you should have a comment here explaining why you have an array of > these string buffers. > >> + =A0char fmt[32]; >> + =A0char *ret; >> + >> + =A0sprintf (fmt, "%%%s%s", BFD_VMA_FMT, fmtch); >> + =A0ret =3D &buf[buf_pos++].place[0]; > > Or, more simply: > > =A0ret =3D buf[buf_pos++].place; > >> + =A0buf_pos &=3D 15; > > That "15" should be: "ARRAY_SIZE (buf) - 1", and it would be safer to wri= te: > > =A0buf_pos %=3D ARRAY_SIZE (buf); > > and leave it to the compiler to optimize this into an AND operation if it > can. > >> snprintf (ret, 64, fmt, value); > > And the "64" here should be "sizeof (buf[0].place)". > > Cheers > =A0Nick > > Hello Nick, adjust the binutils part as you suggested. Applied to binutils and gcc (rev. 170433) tree. Regards, Kai